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 NullPointStrategies, Today, 05:17 AM
          0 responses
          24 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          120 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X