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 inanazsocial, Today, 01:15 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by rocketman7, Today, 02:12 AM
          0 responses
          10 views
          0 likes
          Last Post rocketman7  
          Started by dustydbayer, Today, 01:59 AM
          0 responses
          1 view
          0 likes
          Last Post dustydbayer  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          23 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Working...
          X