High/LowPaintBar Indicator - Code question.  [SOLVED]

Questions about MultiCharts and user contributed studies.
brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

High/LowPaintBar Indicator - Code question.

Postby brunor » 14 Jan 2014

This indicator paints a bar if it is the highest high or lowest low of the last 20 bars.
Is there a more efficient method of coding conditions 1 and 2?
And how would you paint only the current bar and reset previous bars to standard colors?
I would appreciate any assistance.
Thanks.
Bruno

Code: Select all

Condition1 = High > High[1] and High > High[2] and High > High[3] and High > High[4]
and High > High[5] and High > High[6] and High > High[7] and High > High[8]
and High > High[9] and High > High[10] and High > High[11] and High > High[12]
and High > High[13] and High > High[14] and High > High[15] and High > High[16]
and High > High[17] and High > High[18] and High > High[19] and High > High[20];

Condition2 = Low < Low[1] and Low < Low[2] and Low < Low[3] and Low < Low[4]
and Low < Low[5] and Low < Low[6] and Low < Low[7] and Low < Low[8]
and Low < Low[9] and Low < Low[10] and Low < Low[11] and Low < Low[12]
and Low < Low[13] and Low < Low[14] and Low < Low[15] and Low < Low[16]
and Low < Low[17] and Low < Low[18] and Low < Low[19]
and Low < Low[20];

If Condition1 then
BEGIN
PlotPaintBar(High,Low,Open,Close,"",blue);
END
else
If Condition2 then
BEGIN
PlotPaintBar(High,Low,Open,Close,"",red);
END

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

Re: High/LowPaintBar Indicator - Code question.

Postby TJ » 14 Jan 2014

look up the following keywords:

HIGHEST
LOWEST



while you are at it, look up these keywords too... they will come in handy in the future:

MAXLIST
MINLIST

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: High/LowPaintBar Indicator - Code question.

Postby brunor » 15 Jan 2014

This works, but also paints the current bar if the high equals the highest high from the previous bar. Any suggestions?
And thank you kindly for your help TJ.

Code: Select all

Value1 = Highest(High,20);
Value2 = Lowest(Low,20);

Condition1 = Value1 = High;
Condition2 = Value2 = Low;
Condition3 = Condition1 = false and condition2 = false;

If Condition1 then
BEGIN
PlotPaintBar(High,Low,Open,Close,"",blue);
END
else
If Condition2 then
BEGIN
PlotPaintBar(High,Low,Open,Close,"",rgb(128,0,255));
END
Else
If Condition3 then
Begin
NoPlot(1);
End

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

Re: High/LowPaintBar Indicator - Code question.

Postby TJ » 15 Jan 2014

this is how i would code it:

Code: Select all


input:
Look.back(20),
upcolor(blue),
dncolor(red),
nucolor(black);

if High = highest(h, Look.back)
then
PlotPaintBar(High,Low,Open,Close,"", upcolor)
else
if Low = lowest(L, Look.back)
then
PlotPaintBar(High,Low,Open,Close,"", dncolor)
else
PlotPaintBar(High,Low,Open,Close,"", nucolor);
The NoPlot is not needed.
The last ELSE is optional.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: High/LowPaintBar Indicator - Code question.  [SOLVED]

Postby brunor » 15 Jan 2014

Thank you very much TJ.


Return to “MultiCharts”