Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time between trades

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

    Time between trades

    Is there a setting or a script I can add to set s time delay between trades? A few times a day the strategy will try and sell an existing contract and buy a new one in the same candle so I get a margin error and it stops the strategy.

    #2
    In OnPositionUpdate, if the position has just changed to flat, note the time by saving DateTime.Now in a variable.

    Later, when you are thinking of entering, you could calculate how long it has been since then like this:

    int SecondsSinceFlat = (int)Math.Floor((DateTime.Now - FlatTime).TotalSeconds);
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hi, you can also use BarsSinceExitExecution() to keep everything in OnBarUpdate, it would also work in historical mode (DateTime.Now references the real time PC clock):

      Comment


        #4
        Originally posted by NinjaTrader_ChrisL View Post
        Hi, you can also use BarsSinceExitExecution() to keep everything in OnBarUpdate, it would also work in historical mode (DateTime.Now references the real time PC clock):

        https://ninjatrader.com/support/help...texecution.htm
        Yes - that is a better idea. Chryslertech Do it that way.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          TY for your assistance

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          47 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          23 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          33 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          51 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          42 views
          0 likes
          Last Post CarlTrading  
          Working...
          X