Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        41 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        27 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X