Select Page

# help creating criteria for scanning

Optuma Forums Optuma Scripting help creating criteria for scanning

This topic contains 3 replies, has 2 voices, and was last updated by  Darren 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
• Author
Posts
• #46531

Trevor
• Topics: 2
• Replies: 1
• Posts: 3

Could someone help me create this criteria for scanning and backtesting

3 period momentum of 20 day ema offset -3 periods

Trevor

#46575

Darren
• Topics: 25
• Replies: 110
• Posts: 135

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?

#46579

Trevor
• Topics: 2
• Replies: 1
• Posts: 3

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.

#46587

Darren
• Topics: 25
• Replies: 110
• Posts: 135

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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.