Logic For Multiple Inside Bars
-
Hi guys, I need to get the loop logic for Multiple Inside Bars.
The condition is this: Mother Bar has initial 2 candle inside.
so Basically it will be Candle 1 & 2 High/Low is inside Mother Bar High/Low
Now, if new candles formed high/low is still inside the Mother Bar Range I should Get its candle IDs.
Now if a latest candle CLOSES below or above mother bar range, I need to get the ATR Average Value from the breakout candle to the Mother Bar.
-
Not sure I fully understand. Do you mean you need 2 consecutive candles to define one only 'mother bar? Some images would definitely help.
-
technically sir, to define the Mother Bar, I need minimum of 2 inside bars. Now, not all the time after 2 bars the next candle will be breakout candle right?
that is why, I need to check if the next formed candle closed is a breakout candle, another inside bar or a candle that Invalidates the mother bar

-
Ok. I understand now. One more question. Are open price and close price the levels defining the 'inside' limits, right? According to your image, highs and lows can be ignored, right?
-
@l-andorrà no sir, inside bars high && low should be inside on Mother Bars High && low too..
-
Ok. And how is the mother bar defined? I mean, how do you know candle ID 0 is a mother bar, for example? I can see that looking back at past bars. Is there a specific number of bars back to look for?
-
No sir, the Initial Range from the Mothers Bar is 3 Candles. 1 Mother Bar 2 Inside Bars, after that it will be just a loop that as long as the new formed candles stayed inside the range of the mother bar it will be still inside bar, then if the candle closes above or below the range of the mother bar it will be the break out candle
-
I think you have written the candle ID numbers wrong, 0 is the current forming candle, 1 is the closed candle before etc, so in your picture if 3 is the current forming candle (so actually 0) the range candle would be 3
-
That's a complex structure that will need variables. are you familiar with loops and variables?