Moving average range filter

Posted By: SPIRIT777

Moving average range filter - 11/29/20 09:56

Dear All,

Please help with code for calculation of range between 2 emas (8 and 21 EMAs), I have the following code below, but it seems doesn't work.
Please comment. Thanks a lot!


//Filter MA range

vars close = series(priceClose());

vars EMAF = series(EMA(close,8));
vars EMAM = series(EMA(close,21));
vars EMAS = series(EMA(close,34));


// MA range
vars rangeMA = series(EMAF[1]-EMAM[1]); // calculate range between ema 8 and 21 (for previous 1 bar)
vars rangeMA2 = series(EMAM[1] - EMAS[1]); // calculate range between ema 21 and 34 (for previous 1 bar)

vars ruleMAR = (abs(rangeMA[1]) >= 7*PIP); // filter range more than 7 pips between ema 8 and 21 (previous 1 bar)
vars ruleMAR2 = (abs(rangeMA2[1]) >= 7*PIP); // filter range more than 7 pips between ema 21 and 34 (previous 1 bar)
Posted By: MatPed

Re: Moving average range filter - 11/29/20 23:13

Not an expert but
vars ruleMAR = (abs(rangeMA[1]) >= 7*PIP); // filter range more than 7 pips between ema 8 and 21 (previous 1 bar)
vars ruleMAR2 = (abs(rangeMA2[1]) >= 7*PIP); // filter range more than 7 pips between ema 21 and 34 (previous 1 bar)

Are not vars, but var.

ciao
Posted By: SPIRIT777

Re: Moving average range filter - 11/30/20 07:22

Thanks a lot for the comment!

But when I changed to var it generates error and code doesnt works.

How to debug the formula and see the result of it? is there some kind of debugging instrument.

Many thanks.
Posted By: MatPed

Re: Moving average range filter - 11/30/20 14:38

sorry I missed a piece of the previous comment, it is a comparison they are bool or int. Not var. The test wil result in a 0 or 1
© 2024 lite-C Forums