Different timeframe and exploration?

I am trying to make an Multiple timeframe AFL. I need you guys for some help. So here I want to use 2 timeframes ie 15 min and 5 min
I am using moving average crossover on both the timeframe (with 5 min as my entry timeframe)
So i ran exploration with moving average on both the timeframes through this code.

movingaverage = MA(Close,20);

callma = TimeFrameExpand(movingaverage,in15Minute);
realma = MA(Close,20);
Filter = 1 ;

These are the results that I am getting when running 5 min exploration


I believe the moving average calculated under 15minma is wrong since, the moving average should be same for 9:15, 9:20 and 9:25 and it makes one 15 min candle.

These are results under 15 min exploration

So in a way, the first 2 values i.e 24552.81 and 24589.41 are coming extra.
Please help me

That's your misconception of AB's liberty. :slightly_smiling_face:

Please follow the syntax of TimeFrameExpand function carefully.

Syntax: TimeFrameExpand( array, interval, mode )

Available modes:

  • expandLast - the compressed value is expanded starting from last bar within given period (so for example weekly close/high/low is available on Friday's bar)
  • expandFirst - the compressed value is expanded starting from first bar within given period (so for example weekly open is available from Monday's bar)
  • expandPoint - the resulting array gets not empty values only for the last bar within given period (all remaining bars are Null (empty)).

The default mode is expandLast. If we specify the mode as expandFirst in the code we will have your desired results. But would you like to expand data before a candle forms from the compressed timeframe or after, that's your choice.

TimeFrameSet( in15Minute );
movingaverage = MA( Close, 20 );

callma = TimeFrameExpand( movingaverage, in15Minute, expandFirst );
realma = MA( Close, 20 );
Filter = 1 ;
AddColumn( callma, "15minma", 1.22 );
AddColumn( realma, "5minma", 1.22 );