Announcement

Collapse
No announcement yet.

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.

      Comment


        #4
        Thanks Jesse.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        573 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        575 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X