Can't get correct ema(o,5) of 15 minutes frame time in chart 1 minute , why?

Please , help me to get ema(o,5) of 15 minutes frame time in chart 1 minute. my code is
TimeFrameSet( in15Minute); // switch to 15 minute frame
le05=5;
in01=LastValue(ema(O, le05));
in02=ema(in01, le05);
d5=in01-in02;
li5=Prec(in01+d5,1);
TimeFrameRestore(); // restore time frame to original

@lekhoa1234567890 please learn how to properly post your code on this forum.

Get familiar with how to use Mutiple Time Frame functions. Try making a few examples. It is all well explained in the User Guide.
https://www.amibroker.com/guide/h_timeframe.html

Then for your particular problem, here is a start.

TimeFrameSet( in15Minute ); // switch now to 15 minute data

ma5 = EMA( Open, 5 ); // 5 bar moving average of OPEN from 15 minute data 

TimeFrameRestore(); // restore time frame to original 

Plot( Close, "Price", colorWhite, styleCandle ); 

// plot expanded average 
Plot( TimeFrameExpand( ma5, in15Minute), "5 bar moving average from 15 min bars", colorRed );

image

1 Like

All yours Larry, thought post may go unanswered :wink:

1 Like

Thanks, I actually only spent about 3 minutes on it. I hope it is correct! :grinning:

Thank Larry , well done .it's great.:heart_eyes: