Multiple criteria over several bars

Optuma Forums Optuma Scripting Multiple criteria over several bars

This topic contains 1 reply, has 2 voices, and was last updated by Mathew Mathew 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #53795
    Avatar
    Steve
    • Topics: 12
    • Replies: 17
    • Posts: 29

    Hello

     

    How do I check if two criteria are met over x number of bars?

     

    For example, I would like to see if I get a MA crossover near (say within 3 bars) when another MA turns down?  I can get a result if both events occur on the same bar, but how do I see those instances where both events happen within 3 bars?

     

    Thanks
    Steve

     

    #53799
    Mathew
    Mathew
    • Topics: 16
    • Replies: 1,035
    • Posts: 1,051

    Hi Steve,

    You can use the “TimeSinceSignal()” function to get how many bars since the event occurred. So with this we just need to make sure that each TimeSince is less than 4 bars.

    eg

    Sig1 = {Signal Script 1};
    Sig2 = {Signal Script 2};

    (TimeSinceSignal(Sig1) < 4) AND (TimeSinceSignal(Sig2) < 4)

    This will only trigger if they are both within 3 days of each other. Note that you may get multiple results. If that is the case you can use a NoRepeat() function to limit it to 1.

    See https://help.optuma.com/kb/faq.php?id=1030 for more info on the function.

    Hope that helps

    Mathew

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

You must be logged in to reply to this topic.

Pin It on Pinterest

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