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 create order price

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

    Updating create order price

    Hello,

    I'm using createOrder function to add a stop price and I would like to know how I can update the price of this order.

    Can someone help me ?

    Thx !
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Hello johnok,

    Thank you for your post.

    In order to change the price of a stop order you've submitted via Account.CreateOrder() you would need to have saved it in an order variable like in the example seen on the CreateOrder page of the help guide:

    Code:
    Order stopOrder;
    stopOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.StopMarket, OrderEntry.Automated, TimeInForce.Day, 1, 0, 1400, "myOCO", "stopOrder", Core.Globals.MaxDate, null);
    
    myAccount.Submit(new[] { stopOrder });


    You could then refer to that stopOrder, update its StopPriceChanged property to the price you'd want to change it to, then use Account.Change to change to a new price:

    Code:
    Order stopOrder;
    stopOrder.StopPriceChanged = stopOrder.StopPrice - 4 * stopOrder.Instrument.MasterInstrument.TickSize;
    
    private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
    {
      // Change the stop order if an execution results in a long position
      if(e.MarketPosition == MarketPosition.Long)
          myAccount.Change(new[] { stopOrder });
    }



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      How do you change StopLimitOrder's limit price? Is there a property called StopPriceLimitChanged?

      I want to modify a StopLimitOrder's limit price when it's in Working status.
      Last edited by yubo27; 12-02-2023, 08:39 PM.

      Comment


        #4
        Yes.

        It's called LimitPriceChanged.

        Follow the links that Kate provided above.

        That is, in the Change() page, near the top,
        click on the embedded link for the Order object.

        Comment


          #5
          Hello yubo27,

          Thanks for your notes.

          bltdavid has provided some great information on this topic.

          Please see NinjaTrader_Kate's sample code on post # 2 demonstrating how to change the price of a stop order and see the help guide links shared in post # 2.
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          160 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          9 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X