Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to limit limit orders

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

    how to limit limit orders

    Hi,
    I have a strategy that I've written that uses limit orders. However, I want to have the limit order cancelled after a certain amount of time passes without getting filled. Is there a way to do this?
    Thanks ... Ed

    #2
    Hello Edstaffin,

    You can do a comparison of when the order was submitted and then compare that to the current bar time.

    When you first submit the order you will want to store the Time[0] to a variable that you can then call later on
    Code:
    DateTime entryTime;
    if(entryCondition)
    {
        EnterLongLimit();
        entryTime = Time[0];
    }
    
    if(Time[0] >= entryTime.AddMinutes(5))
    {
    
    }
    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Ed,

      You can use the CancelOrder() method. That's the easy part. How to use it at a specific time is where your choices are.

      You can do this after a number of bars have passed (record CurrentBar when you place the limit order and check with each BarUpdate if CurrentBar - RecordedCurrentBar is enough time to cancel the limit order), you can look at the Time TimeSeries and execute at specific time of day (say and hour before the close of your market) or use it to cancel after 5 minutes have passed and you weren't filled. The TimeSeries is a bit trickier, but will give you more accurate time of day or time between putting the LimitOrder in the market and when you want to take it out.

      There is good information in the NT help. I suggest looking at the section on Advanced Order Handling to get familiar with what your options are and the kinds of issues you may encounter.

      Best regards
      daqu40
      NinjaTrader Ecosystem Vendor - QTradez

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 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
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X