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;
}
}
AddColumn(duration, "duration");
@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.
causes me to recommend that you read the following: Understanding How AFL Works
AFL reminds me of Linux wherein "everything is a file", except in AFL, "everything is an array."