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

How to modify a pending limit order

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

    How to modify a pending limit order

    In a strategy, you can modify a pending ATM limit order with this command:

    AtmStrategyChangeEntryOrder()

    However, I cannot find help on how to modify the limit price on a non-ATM order that was placed with the EnterLongLimit() or EnterShortLimit() command.

    Bryan
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    cassb, please try using IOrders, which allow you to change the price whenever you want.
    Code:
    // in variables
    IOrder longEntryOrder;
    
    OnBarUpdate()
    {
        // place long limit order when conditions are met
        longEntryOrder = EnterLongLimit(...);
    
        // if still unfilled, change price
        longEntryOrder = EnterLongLimit(some new price);
    }
    This reference sample goes over some of the techniques necessary when using IOrders.
    AustinNinjaTrader Customer Service

    Comment


      #3
      So what you're saying is that when you submit a second limit order, it will just update the price and not try to create another limit order?
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        cassb, yes, as long as all of the other parameters are the same, the order will just get an updated price:
        Code:
        if (CurrentBar == 100)
            entryOrder = EnterLongLimit(0, true, 1, 2, "enter long");
        else if (CurrentBar == 105)
            entryOrder = EnterLongLimit(0, true, 1, 1.5, "enter long");
        Code:
        Order='NT-00000/Backtest' Name='enter long' State=PendingSubmit Instrument='ES 12-10' Action=Buy Limit price=2 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=Accepted Instrument='ES 12-10' Action=Buy Limit price=2 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=Working Instrument='ES 12-10' Action=Buy Limit price=2 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=PendingChange Instrument='ES 12-10' Action=Buy Limit price=1.5 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=Accepted Instrument='ES 12-10' Action=Buy Limit price=1.5 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=Working Instrument='ES 12-10' Action=Buy Limit price=1.5 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=PendingCancel Instrument='ES 12-10' Action=Buy Limit price=1.5 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        Order='NT-00000/Backtest' Name='enter long' State=Cancelled Instrument='ES 12-10' Action=Buy Limit price=1.5 Stop price=0 Quantity=1 Strategy='OneOrder' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f9aadfb2583645d6955e5114a2553b74' Gtd='12/1/2099 12:00:00 AM'
        AustinNinjaTrader Customer Service

        Comment


          #5
          OK, thanks Austin. That fact is not clear in the online help guide, then.

          Bryan
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Austin, I am playing with this idea of modifying pending orders, but it doesn't seem to be working how you described. Here is how the order is placed:

            EntryOrder = EnterLongStop(0, true, 1, 701.2, "LimitLong");

            Let's say you want to change the stop order to 700.5. All you do is enter this command and it will replace the previous limit stop order with a new one?

            EntryOrder = EnterLongStop(0, true, 1, 700.5, "LimitLong");

            It's not changing the order in the SuperDOM when do this though...

            Bryan
            cassb
            NinjaTrader Ecosystem Vendor - Logical Forex

            Comment


              #7
              Hi Brian,

              Yes, this is how it should work. One thing you'll want to check is that the conditions for the first order are not evaluating true.


              You can test a simple implementation of this without using IOrders if you want to get a handle on how it works. Use the following in a strategy with CalculateOnBarClose = false, and you should see the order updated as price changes.

              if (Historical)
              return;

              EnterLongStop(Close[
              0] + TickSize * 10);
              Ryan M.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by hdge4u, Today, 12:23 PM
              0 responses
              2 views
              0 likes
              Last Post hdge4u
              by hdge4u
               
              Started by thomson, Today, 12:00 PM
              0 responses
              4 views
              0 likes
              Last Post thomson
              by thomson
               
              Started by cmtjoancolmenero, Today, 11:56 AM
              0 responses
              3 views
              0 likes
              Last Post cmtjoancolmenero  
              Started by Uregon, 11-02-2023, 03:03 AM
              20 responses
              542 views
              0 likes
              Last Post MuMiX
              by MuMiX
               
              Started by raffu, Today, 11:41 AM
              0 responses
              2 views
              0 likes
              Last Post raffu
              by raffu
               
              Working...
              X