Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Updating order price

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

    Updating order price

    Hope you're doing great!

    The order is entered correctly, but when EMA changes, the order price is not getting updated in this live open order. How should I code it, so the price is updated in open orders in live trading as EMA changes? Thank you!


    orderPrice = Instrument.MasterInstrument.Round2TickSize(EMA(100 )[0]);
    if (orderPrice < EMA(100)[0]) orderPrice = orderPrice + 0.25;
    entryOrderA = EnterLongStop(1, orderPrice, "MyEntry-a");
    Last edited by sanjeev74; 04-11-2017, 09:43 AM.

    #2
    Hello sanjeev74,

    Thanks for writing in.

    When you submit an order, it will return as Submitted, Accepted, Working, and then Filled. When orders are submitted to your broker and are in a Working State, you can update them by submitting another order with the same order ID.

    For example, if your entry condition was controlled by Position.MarketPosition == MarketPosition.Flat or Position.MarketPosition != MarketPosition.Long, then that order would not be submitted again to update the price of the live order.

    I suggest to create a condition in OnBarUpdate() that will update the order's price. You could set a bool in OnExecution() that tells you when the order has been Accepted. This bool can then be used to control your order method to update the order's price.

    I see that you are already using IOrders to manage your positions, but for the thread's reference, the sample strategy on using OnExecution() and OnOrderUpdate() provides the necessary functionality to create orders that you can update with your own logic.

    Strategy: Using OnOrderUpdate() and OnExecution() methods to submit protective orders - http://ninjatrader.com/support/forum...ead.php?t=7499

    Please let me know if you have any questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by hdge4u, 04-29-2024, 12:23 PM
    5 responses
    28 views
    0 likes
    Last Post MisterTee  
    Started by llanqui, 01-25-2024, 06:15 PM
    9 responses
    64 views
    0 likes
    Last Post MisterTee  
    Started by tradingnasdaqprueba, 05-07-2024, 03:42 AM
    16 responses
    65 views
    0 likes
    Last Post tradingnasdaqprueba  
    Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
    55 responses
    5,461 views
    0 likes
    Last Post BartMan
    by BartMan
     
    Started by DawnTreader, 05-08-2024, 05:58 PM
    16 responses
    52 views
    0 likes
    Last Post DawnTreader  
    Working...
    X