How to buy in multiple time frame (inhourly and 15 mins)?

Hi All,

I want to buy in 2 condition : condition 1 MACD > SIGNAL in hourly
condition 2 MACD > SIGNAL in 15 min

_SECTION_BEGIN("MACDH");
TimeFrameSet(inHourly);
MACDH = Cross(MACD(),Signal());
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("MACD15");
TimeFrameSet(in15Minute);
MACD15 = Cross(MACD(),Signal());
TimeFrameRestore();
_SECTION_END();

Buy = MACDH AND MACD15;

Can I code this condition on AFL? When I done it seem don't work.

Are you using this AFL in indicator or AA window?
You need to mention the base interval or which timeframe it is, aka Periodicity.
It should be less than or equal to 15m.

After that, you need to TimeFrameExpand() to align the bars correctly.
https://www.amibroker.com/guide/afl/timeframeexpand.html

Decompressing is required to properly display the array created in different time frame

1 Like

Dear travick

thanks, it work