Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Condition true for 2 bars.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Condition true for 2 bars.

    Hi everyone,

    I would like to ask you an advice on the following:

    I am testing some ideas with the PSAR indicator. I would like to enter a long position when certain conditions are met and price breaks above the PSAR.

    I also would like that the strategy would be executed if price breaks above PSAR within 2 bars from the point in time where the conditions are met, but not after the 2nd bar.

    How could I do that (possibly with the strategy wizard?).

    Thank you!

    John.

    #2
    Hi johnlucas,

    Thanks for the post. If all conditions need to be true for the same bar, then you join multiple conditions by adding them within a set. The strategy won't take action until all conditions within a set are true.

    If you want to set it up where one condition is only evaluated after another condition is true, you can define sequences. Sequences are commonly defined using bool flags by code or with user variables for the strategy wizard. This sample is made for strategy wizard and uses user variables to setup sequences.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,
      thanks for your reply.
      I've had a look at the sample, and it clarifies the usage of user variable to set a sequence.
      My question now is how to define "this bar" or " the next one".
      BarsAgo = 0 means "now",
      BarsAgo= 1 means "1 bar ago"
      but how to set "1 bar in the future" from now?

      thank you!

      regards,

      John.

      Comment


        #4
        All bar referencing is done with current bar[0] and prior bars([1][2], etc). There is no support for referencing future bars.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X