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 sjsj2732, Yesterday, 04:31 AM
          0 responses
          38 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          287 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          289 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          134 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          95 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X