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 Darren 6 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

    Thanks in advance

    Trevor

    #46575
    Darren
    Darren
    • Topics: 28
    • Replies: 145
    • Posts: 173

    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?

    Capture

     

     

     

    #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
    Darren
    • Topics: 28
    • Replies: 145
    • Posts: 173

    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.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close