Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pausing trade orders of any kind when in positions during rollover MBTrading

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

    Pausing trade orders of any kind when in positions during rollover MBTrading

    Hi:

    I have a strategies that leaves positions on during rollovers during the week daily (rollover between 4:50 pm est---5:10 pm est) and only closes and flattens all and disables strategies on Friday at 4:50 pm est.

    What can I do to add to the code to make it pause taking any orders whatsoever so it does not accidentally try to order and then disable the strategy during this period of time? Right now, sometimes it will try to make a order and then because of rollover it can not do it as the account is unavailable and then it disables the strategy. Then, I have to manually close the position and re-enable the the instrument that was disabled. This effectively messes up the position and it has to wait, then, for another valid reentry...would rather have it leave the position on seamlessly throughout the rollover period daily, and only have it exit all positions/flatten and disable all strategies on Friday at 4:50 pm est.

    If you could include sample code to put into the strategy I could use to test per above that would be great.

    Please let me know where it should be place in the code for the least intrusion (onBarupdate, Initialize, etc)...smile.

    Thanks...

    Greg

    #2
    Greg, for this you would setup a time filter in your entry rules to not attempt issuing an order during those rollover times - http://www.ninjatrader.com/support/f...ead.php?t=3226

    For the ExitOnClose, you can set this to false and then issue a market exit order for example on your desired time on Friday before the weekend only.

    if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 165000)
    {
    ExitLong();
    ExitShort();
    }

    Comment


      #3
      Hey Bertrand...

      With the Friday Exit...what command do I include for it to exit and also after everything is flattened to disable the strategies?

      Instead of the exit command is there a flatten all command that will flatten all and automatically disable with only one "flatten" command or something similar to be sure after the exit, no more re-entries will take place cause there is actually 8 more min of trade time after 4:50 pm est.

      For the time filters during the week, also, if I have them do a normal exit of all positions but keep the strategies enabled, how do I make sure it will not re-entry till 5:10 pm est?

      Lastly, if I tell it to exit all positions at 4:50 pm est but the time filter is also 4:50 pm est will it still exit cause if the time filter says don't trade between 4:50 pm est and 5:10 pm est not to trade...bottom line with the Mon-Thur rollovers I just want to be sure when I exit that new trades do not take place during the small gap between when I exit and the time filter says not to trade...

      Comment


        #4
        Greg, there are a few options - one would be including a call to Disable() once you're in flat state.



        There's no combined command available in supported NinjaScript, it would be custom combination you create here.

        The further entries would be avoided by the time filter rule discussed in the example, it could then not trigger outside of those assigned time hours, which you would set as desired to cover the rollover period.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        664 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        376 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X