Could someone help me create this criteria for scanning and backtesting

3 period momentum of 20 day ema offset -3 periods

Thanks in advance

Trevor

Could someone help me create this criteria for scanning and backtesting

3 period momentum of 20 day ema offset -3 periods

Thanks in advance

Trevor

Hi Trevor,

To be able to scan the formula will require a true/false condition, so what would be the signal in your example? If it’s when the momentum crosses above zero this would be the formula:

**// calculate the 20EMA;**

**V1 = MA(BARS=20, STYLE=Exponential, CALC=Close);**

**// calculate the 3 perdiod momentum of V1;V2 = MOMENTUM(V1, BARS=3);**

**// Create the true/false condition, offset 3 bars;**

**V2[3] CrossesAbove 0**

Here’s the above used as a Show Bar tool (blue lines) showing 3 days after the indicator crossed 0. Is that what you had in mind?

Hi Darren

The zero line would be the signal line. My thought on the offset was to have the indicator offset -3 periods to get the signal a little bit earlier. On the day of or 3 days later would be too late of a signal.

I copied and pasted the above criteria into the script box and it said to still enter a valid criteria?

Thanks for your help with this.

Sorry Trevor - V2 should have been on it's own line:

**// calculate the 20EMA;****V1 = MA(BARS=20, STYLE=Exponential, CALC=Close);****// calculate the 3 perdiod momentum of V1;****V2 = MOMENTUM(V1, BARS=3);****// Create the true/false condition, offset 3 bars;****V2[3] CrossesAbove 0**

You can change the offset to 3 days before V2[-3] but you can't really test on that because you won't know that the cross will actually happen 3 days later. Hope that makes sense.