inter timeframe indicator

 

I want to use a inter timeframe indicator with iAD, part of code goes as:

int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

//----


for(int i=0; i<limit; i++)

ExtMapBuffer1[i]=iAD(NULL,PERIOD_M1,i);


//- ExtMapBuffer2[i]=iAD(NULL,PERIOD_M5,i);
//- ExtMapBuffer3[i]=iAD(NULL,PERIOD_M15,i);

//----
return(0);

}

If i try to use M5 or M15 in a M1 Period chart, the plot won't reflect what it would normally in a corresponding timeframe.

For example, if the M5 chart is opened and I use PERIOD_M1 in my code, it won't reflect the same as if it is the M! opened.

I imagine it is because of the bars that have to be counted?

Something Like this that I haven't tried yet?: =iAD(NULL,PERIOD_M5,i/PERIOD_M5);

, someone has a solution to my problem?

thanks in advance

Reason: