Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bool time constraint

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

    Bool time constraint

    I am trying to figure out if there is a way to make a time constraint embedded in my strategy, not just using specific time periods (like between 9:30 and 2pm)

    For example, I have a condition in my script, that if it is true, it will change a bool variable to true. I then want to build another condition around the first one, (if bool = true, then) but I only want the bool to be valid for say 45mins (or 15 bars assuming i use 5 min bars) and then re-set it to false.

    Is there an easy way to do this? Any suggestions or ideas would be greatly appreciated.

    Here is the pseudo - code I am thinking about

    If Low[0] < SwingLow(5)
    {
    print low under swing low;
    breakout = true; // but reset breakout to false after 45 mins from the first time this condition triggered true
    }

    if breakout = true && High[0] > SwingLow(5)
    {
    print price retraced to breakout level
    }

    if breakout= true
    reset breakout to false after 45mins

    #2
    eurostoxx trader, have you seen the reference sample that deals with using and manipulating DateTime objects?
    AustinNinjaTrader Customer Service

    Comment


      #3
      thanks for the tip Ausitin... I had only read the SampleTimeFilter script. I will check this one out.

      Curious though if you have any thoughts if the structure of my strategy is correct. Basically I want to be able to look for general market conditions (simple if stmts that are true ) and then monitor future prices for other conditions. Like if the moving average breaks, and then 5 or 10 bars later a new daily low is made, go short... I am thinking that by giving the strategy time constraints on the validity of the "general market conditions", (variables deemed TRUE in the initial if statement) I can easily solve the problem of trying to figure out when to re-set the initial conditions to FALSE so that the strategy doesnt fire all the time when only the secondary conditions are met...

      any ideas or suggestions?

      regardless I appreciate the quick reply and I think I will be able to work something out

      Thanks

      Comment


        #4
        I just saw that there is a bars since entry method... that looks pretty much what I had in mind. Maybe I'll try that out. is there anything similar to that method that is easy to use?

        Comment


          #5
          eurostoxx trader, there is also a BarsSinceExit() method, but those two are the only methods that do something like measure the amount of time that has passed since an entry/exit.
          AustinNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X