Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Expire order, but how?

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

    Expire order, but how?

    Hi,

    Having some problems with my automated strategy. When I click on Enable Strategy, the strategy tries to place an order of the current 4-hour bar. But prices have already moved a lot since then, so I'm getting a "Unable to submit order, price too far ....." error.

    How should I approach this?

    I'm running the strategy on a 1-min interval. I have added two timeframes in the Initialize() section (240min and 1day).

    I submit the orders via the following code:

    Code:
    entryOrder = EnterLongLimit(iMainPeriodNr, false, iPositionSize, Closes[iMainPeriodNr][0]-(TickSize*3), "EnterLong");
    iMainPeriodNr is a variable that has been set to 1 (being the 240-min periodtype). I set the LiveUntilCancelled to false. So I was thinking the order has exactly 1-min time to be executed, otherwise be expired.

    But apparently I'm thinking wrong, because I'm getting errors. The strategy still tries to execute the order.

    I have set Sync Account To Postition to False, and I have set Wait Until Flat to enabled. So it should not try to execute historical orders right?

    #2
    Hello siroki,

    Thanks for your post.

    If the order is too far away, you will need to choose a different price that is closer to the market price.

    You may want to check with your broker on how far away from the market price you can place an order. Then check that the price you will be using for the order is less than that distance before the order is placed.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for your answer. Do you suggest I put a GetCurrentBid() / GetCurrentAsk() around the buy/sell order and see if that is exceeding a threshold compared to the price I want to buy/sell?

      Comment


        #4
        Hi siroki,

        GetCurrentBid and GetCurrentAsk will return the bid and ask prices which can be used in place of the last price.

        In historical, these will return the close price of the bar.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Great Chelsea,

          I just put a bracket of 10 pips around the bid/offer price and skip the trade if it falls outside. Works like a charm.

          Thx!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          48 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          66 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X