Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No suitable method found to override (OnOrderUpdate)

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

    No suitable method found to override (OnOrderUpdate)

    Hi NT Team,

    I have a strategy with 2 entries. When entry 1 closes, I want entry 2 to move to breakeven. I am getting the referenced error when compiling. Hoping you can point out something obvious I am doing wrong.

    Thank you!

    Code:
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;
    
    if (CurrentBars[0] < 1)
    return;
    
    // Check if L1 position is closed
    if (Position.MarketPosition != MarketPosition.Long && L1Closed == false && entryPriceL1 > 0)
    {
    L1Closed = true;
    // Move L2 to breakeven
    ExitLongStopMarket(1, entryPriceL1, "Move to BE", "L2");
    }
    
    // Set 1
    if (CrossBelow(Low, SamriMathRTIntradayV21.Minus18, 1))
    {
    EnterLong(1, @"L1");
    entryPriceL1 = Close[0];
    L1Closed = false;
    }
    
    // Set 2
    if (entryPriceL1 > 0 && Close[0] <= entryPriceL1 - 80 * TickSize)
    {
    EnterLong(1, @"L2");
    }
    }
    
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time)
    {
    if (orderState == OrderState.Filled && order.Name == "L1" && order.OrderAction == OrderAction.Sell)
    {
    // When L1 closes, move L2 to breakeven
    if (Position.MarketPosition == MarketPosition.Long && Position.Quantity == 1)
    {
    ExitLongStopMarket(1, entryPriceL1, "Move to BE", "L2");
    }
    }
    }

    #2
    Hello quicksandatl,

    The code you have for the OnOrderUpdate method is not correct, the method is missing some parameters. You need to use override methods with all of the parameters they require, you can see an example in the following page of the correct syntax.




    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    75 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X