Multiple criteria over several bars

Optuma Forums Optuma Scripting Multiple criteria over several bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #53795
    • Topics: 15
    • Replies: 18
    • Posts: 33



    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?




    • Topics: 28
    • Replies: 1,276
    • Posts: 1,304

    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.


    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 for more info on the function.

    Hope that helps


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.