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 ghoul, Today, 06:02 PM
    2 responses
    12 views
    0 likes
    Last Post ghoul
    by ghoul
     
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    44 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    180 views
    0 likes
    Last Post jeronymite  
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Working...
    X