How to display MA from another timeframe?

 

I am trying to write indicator that shows Daily EMA disregarding to current chart timeframe. And i found that i have no idea how to accomplish it.

Code:

for(int i=0; i<limit; i++)
{
ExtMapBuffer1[i]=iMA(NULL,PERIOD_D1,9,0,MODE_EMA,PRICE_CLOSE,i);
}

Does not work, because BarNumber (variable i) has a different meaning in current timeframe and D1.

Any help?

 

You have to use iBarShift to get the index value from another timeframe.

//z

 

Thank you zzuegg. Sorry can't check at the moment, but as i am understand code should be like following:

for(int i=0; i<limit; i++)
{
ExtMapBuffer1[i]=iMA(NULL,PERIOD_D1,9,0,MODE_EMA,PRICE_CLOSE,iBarShift(NULL, PERIOD_D1, Time[i], false));
}


Am I right?
 
looks good
 
zzuegg:
looks good

Thanks a lot!
Reason: