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

ChangeOrder method not found?

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

    ChangeOrder method not found?

    In my indicator I want to change the SL order.
    But the ChangeOrder method 'doesn't exist in the current context'.
    Why?
    How can I manage my SL order in my indicator?



    #2
    Already found it, but it doesn't work.
    I use:

    Code:
    Order sl = account.Orders.FirstOrDefault(o => o.OrderState==OrderState.Accepted && o.Name=="Stop1");
    Print("SL = " + sl );
    if (sl!=null) {
        double newsl = IsFirstTickOfBar ? Open[1] : Open[0];
        Print("SL = " + sl + " newprice: " + newsl);
    // sl.StopPrice = sl.LimitPrice = newsl;
        sl.GetOwnerStrategy().ChangeOrder(sl, sl.Quantity, newsl, newsl);
    }
    The SL order is found and the newprice is calculated, but the order doesn't change.
    Print says:
    SL = orderId='d70b9a67b9a14b979b3005ba4bb8ade5' account='Sim101' name='Stop1' orderState=Accepted instrument='ES 12-20' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3422.25 quantity=1 tif=Gtc oco='19b69d7920b34fb3bce537b3d5a8b225' filled=0 averageFillPrice=0 onBehalfOf='' id=33713 time='2020-10-22 12:07:20' gtd='2099-12-01' statementDate='2020-10-22'

    I started the order using an ATM strategy.

    Comment


      #3
      Hello wjadevries,

      To clarify ChangeOrder is for NinjaScript Strategies, you can find that in the strategy section of the help guide. For Indicators you would need to use the Addon section of the help guide anytime you want to access orders or account related details.

      To change an order using the addon approach you would need to use the Change method from the account. You won't be using the strategy or its methods at all in this situation and keep in mind making changes or other modifications to NinjaScript strategy based orders from outside the strategy will likely cause it ti disable.



      Please let me know if I may be of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thanks Jesse.

        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