I am testing a simple breakout system to learn AFL looping and I wish to find out the average duration where the trade closes above the 10-exponential MA in explore without using the Backtest (the #bars column in Backtest). I am getting durations of over 900 which do not make sense. May I know why this section of code has an issue? Thank you.
TenEMA = EMA(Close, 10);
Duration = 0;
for ( i = 0 ; i < BarCount - 1 ; i++)
if (Close[i] > TenEMA[i])
Duration = i + 1;
@Mocazilla Thanks for asking the question and thanks to @fxshrat for your clear thinking and explanation. Connecting BarsSince and duration is a simple concept, I realize, but significant to my enlightenment.