Paintbar and Alert study  [SOLVED]

Questions about MultiCharts and user contributed studies.
olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Paintbar and Alert study

Postby olobay » 19 Sep 2012

Hi,

I modified the custom 1 line study but it's not working well. I just want to paint a bar and have an audio alert every time volume is greater than 2000 contracts on a 1 min chart. Here's the code which compiles well and a picture of the result. Help is greatly appreciated.

Code: Select all

inputs:
Criteria( Volume > 2000 ) , AlertCondition( true ) ;

if Criteria then
begin
PlotPaintBar( High, Low, "CustomPB" ) ;
Alert ;
end
else
NoPlot( 1 ) ;

if AlertCondition then
Alert ;
Attachments
help.png
(55 KiB) Downloaded 759 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

You have to be more specific.
What do you mean by: "not working well"?


Suggestion

Look up the definition of:

Volume
Ticks


ps. it is a legacy thing.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

You have to be more specific.
What do you mean by: "not working well"?
I attached a chart to show what the indicator is doing. It paints bars that do not meet the criteria.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

You have to be more specific.
What do you mean by: "not working well"?
I attached a chart to show what the indicator is doing. It paints bars that do not meet the criteria.
You have to be more specific than that.
What do you mean by "do not meet the criteria"?

I am not playing words with you, this is a debugging process... you have to spell out exactly what are you trying to achieve, what steps you are taking to achieve it, and what results you are getting. simply saying "do not meet the criteria" does not tell yourself what you are looking for, and does not help you to find the solution. This is a very simple code, it is a good place to develop good coding practices. When you have 10,000 lines of code, you don't want to be scratching your head and wondering where to start.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Sorry. What I am trying to achieve is for a bar to be painted and a sound alert to go off, every time volume trades above 2000 contracts on a 1 minute chart but the chart resolution does not really matter. I do not understand what the indicator is doing as it coded right now.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Sorry. What I am trying to achieve is for a bar to be painted and a sound alert to go off, every time volume trades above 2000 contracts on a 1 minute chart but the chart resolution does not really matter. I do not understand what the indicator is doing as it coded right now.
Please take my suggestion in post #2.

Please review the code in your subchart #2.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Still does not help me as I have no understanding of what to do next.

Volume
Returns the volume of the current bar.
For tick and volume-based charts, and time-based charts with resolutions of 24 hours or less:

- the volume traded on Up ticks will be returned if Build Volume On is set to Trade Volume
- the number of Up ticks in the current bar will be returned if Build Volume On is set to Tick Count

For time-based charts with resolutions of 1 day or more:

- the total volume traded will be returned if Build Volume On is set to Trade Volume
- the total number of ticks in the current bar will be returned if Build Volume On is set to Tick Count

Please note that most data feeds provide only a limited history of volume and tick data; storing real-time feed data will ensure the availability of historical volume and tick data.

Usage
Volume

Note
The range of returned values is limited by the MaxBarsBack setting.

Example
Plot the volume of the current bar:

Plot1(Volume,"Volume");

Plot the volume of the previous bar:

Plot1(Volume Of 1 Bar Ago,"Previous bar's volume");

Plot the volume of two bars ago:

Plot1(Volume[2],"Volume 2 bars ago");



Ticks
Returns the total number of ticks for the current bar if Build Volume On is set to Tick Count.
Returns the total volume for the current bar if Build Volume On is set to Trade Volume.

With Build Volume On is set to Tick Count:

- the value of 1 will be returned for 1-tick charts
- the total number of ticks in the current bar will be returned for multi-tick, volume, and time-based charts

With Build Volume On is set to Trade Volume:

- the volume of the current tick will be returned for 1-tick charts
- the total volume of the current bar will be returned for multi-tick, volume, and time-based charts

Please note that most data feeds provide only a limited history of tick and volume data; storing real-time feed data will ensure the availability of historical tick and volume data.

Usage
Ticks

Note
The range of returned values is limited by the MaxBarsBack setting.

Example
Plot the number of ticks in the current bar (Build Volume On is set to Tick Count):

Plot1(Ticks,"Ticks");

Plot the volume of the current bar (Build Volume On is set to Trade Volume):

Plot1(Ticks,"Volume");

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Still does not help me as I have no understanding of what to do next.
Please post the code for your subchart #2 indicator.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

It's the default Volume study in MC.

Code: Select all

if BarType >= 2 and BarType < 5 then
Plot1( Volume, "Volume" )
else
Plot1( Ticks, "Volume" ) ;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Bypass the fluff and read what is applicable.
I have trimmed the fluff for you for easy reading.
Still does not help me as I have no understanding of what to do next.

Volume
Returns the volume of the current bar.
For ... time-based charts with resolutions of 24 hours or less:

- the volume traded on Up ticks will be returned if Build Volume On is set to Trade Volume

[snipped]

Ticks

Returns the total volume for the current bar if Build Volume On is set to Trade Volume.

[snipped]

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

It's the default Volume study in MC.

Code: Select all

if BarType >= 2 and BarType < 5 then
Plot1( Volume, "Volume" )
else
Plot1( Ticks, "Volume" ) ;
Have you checked the bartype you are using?

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Have you checked the bartype you are using?
I am using OHLC 1 minute bars. I don't know where to see what value that type of bar is.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

I want total volume on current bar so I should replace Volume with Ticks in my Criteria?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Have you checked the bartype you are using?
I am using OHLC 1 minute bars. I don't know where to see what value that type of bar is.
https://www.multicharts.com/trading-sof ... _Reference

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Ok I am using bar type 1. Does that mean I have to change the volume indicator to

Code: Select all

if BarType >= 1 and BarType < 5 then
Plot1( Volume, "Volume" )
else
Plot1( Ticks, "Volume" ) ;

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Code: Select all

if BarType >= 1 and BarType < 5 then
Plot1( Volume, "Volume" )
else
Plot1( Ticks, "Volume" ) ;
I tried this but it put my volume indicator in exponents or something. I don't understand what it did.
Attachments
exponents.png
(30.32 KiB) Downloaded 748 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Ok I am using bar type 1. Does that mean I have to change the volume indicator to

Code: Select all

if BarType >= 1 and BarType < 5 then
Plot1( Volume, "Volume" )
else
Plot1( Ticks, "Volume" ) ;
No. You do not change the code. This indicator is supplied by MultiCharts.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

read the code carefully...
I have modified it for your easy understanding


if BarType >= 2 and BarType < 5 then use this code:
Plot1( Volume, "Volume" )

or else
for all the other BarType (e.g. BarType=1), use this code:
Plot1( Ticks, "Volume" ) ;

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Thanks for all the help. So I am using bar type 1 so I should change my code to

Code: Select all

inputs:
Criteria( Ticks >= 2000 ) , AlertCondition( true ) ;

if Criteria then
begin
PlotPaintBar( High, Low, "CustomPB" ) ;
Alert ;
end
else
NoPlot( 1 ) ;

if AlertCondition then
Alert ;
I tried this but it does not achieve what I am trying to.

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

My instrument setting is Build Volume On Trade Volume.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study  [SOLVED]

Postby TJ » 19 Sep 2012

Thanks for all the help. So I am using bar type 1 so I should change my code to

Code: Select all

inputs:
Criteria( Ticks >= 2000 ) , AlertCondition( true ) ;

if Criteria then
begin
PlotPaintBar( High, Low, "CustomPB" ) ;
Alert ;
end
else
NoPlot( 1 ) ;

if AlertCondition then
Alert ;
I tried this but it does not achieve what I am trying to.
Back to square one;
What do you mean by "it does not achieve what I am trying to"?

No alert?
No Paint?
Paint the wrong bar?
Does not paint the right bar?
No sugar in coffee?

olobay
Posts: 47
Joined: 28 Dec 2011
Has thanked: 17 times

Re: Paintbar and Alert study

Postby olobay » 19 Sep 2012

Ok I see what the issue was. For some reason, even though I had changed the inputs in the code in PLE, it did not change it in the indicator that was on my chart. Now it is working great. I really do appreciate the help and I apologize for being slow. I am a total noob when it comes to Easylanguage.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Paintbar and Alert study

Postby TJ » 19 Sep 2012

Ok I see what the issue was. For some reason, even though I had changed the inputs in the code in PLE, it did not change it in the indicator that was on my chart. Now it is working great. I really do appreciate the help and I apologize for being slow. I am a total noob when it comes to Easylanguage.
No problem, everybody started as a noob.
Your questions are very welcomed.

Good trading to you.


Return to “MultiCharts”