Related Multi Time Frame MACD trend filter

Dear Experts
I am trying to create a trend filter using existing MACD indicators. Here, I am trying to find the trend in higher time frame( 15 Minutes); further, i want to make trading decision on lower time frame(1 min).
I have implemented the afl for that but it was not working as i expected.

AFL Code:

TimeFrameSet( tfrm );
mArray = MACD(r1, r2);
signalArray = Signal(r1,r2,r3);
isBull = IIf( mArray > signalArray,True,False);
histrogram = mArray-signalArray;
mTrend = TimeFrameExpand(mArray, tfrm );
signalTrend = TimeFrameExpand(signalArray, tfrm );

Problem here,
I do calculate the macd and signal array in higher time frame, and in lower time frame, I am expanding the array, but these values(mArray != mTrend and signalArray != signalTrend ) are not matching

I tried to debug this problem, but not getting any idea about it.

Can anyone help me to understand the problem here.


mArray and signalArray arrays contain compressed values in smaller interval!
So of course they can not match with mTrend and signalTrend at same array index if smaller interval is selected.

And in your code mTrend and signalTrend do match the values of last (previous) completed longer interval's bar's values since default expand mode is expandLast.

Read about expanding modes (three ones) in manual carefully.

So long story short... there isn't a problem.

BTW in your example isBull and histrogram are not expanded yet.

But instead of expanding them you may do like this

TimeFrameSet( tfrm );
mArray = MACD(r1, r2);
signalArray = Signal(r1,r2,r3);

expandmode = expandLast;// read about expansion modes in manual!
mTrend = TimeFrameExpand(mArray, tfrm, expandmode );
signalTrend = TimeFrameExpand(signalArray, tfrm, expandmode );

isBull = mTrend > signalTrend;
histrogram = mTrend-signalTrend;

Thanks fxshrat for the quick response. I faced the problem with barindex as you mentioned.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.