How to create a horizontal line based on first 3 candle of 3 min duration


Hello All,

I wanted to create a horizontal line based on first 3 candlestick.

Means from first 3 candle whichever has the highest value want to draw a straight line top of it till market close.


you can use valuewhen() to calculate highest high of first 3 candles

hh= Max(ValueWhen(Day()!=Ref(Day(),-1), H), Max(ValueWhen(Day()!=Ref(Day(),-2), H),ValueWhen(Day()!=Ref(Day(),-3), H)));


Thanks for your reply but its not working for me…
I am trying to plot horizontal line on “hh” values but it not like what I am expecting…

I want a straight horizontal line on max candle from first three candles and then that line should draw straight to the last calendar.


Hello Saurabh,
Till what i have seen, you have been replying to a lot of post here. That’s a good thing actually, but not so encouraging for the forum at large.

Anyway, coming to subject at hand!

Of late, i was trying to write code for the first 30 mins ORB strategy. Googling a lot of places, even the KB and official AB forum, i was getting a 10% error. So a 100% fit code i was unable to find. At some places, it was still looking into the previous day even though Newday function was added. At other places, it was missing out on the current days candle in case of a spike.

Now that i see your code and tried, for the first 2 15m candle on 15m tf, i adjusted the code given below.
hh= Max(ValueWhen(Day()!=Ref(Day(),-1), H), ValueWhen(Day()!=Ref(Day(),-2), H)); ll= Min(ValueWhen(Day()!=Ref(Day(),-1), L), ValueWhen(Day()!=Ref(Day(),-2), L));

Yet as you can see in the pic attached below, it has failed to encompass the first candle.

What could be the error or am i missing something. Please guide.

ps. Sorry! i can’t figure out how to quote the code. please guide there too. TY!