Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving frpm NT7 to NT8 w/OnOrderUpdate and OnExecutionUpdate

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

    Moving frpm NT7 to NT8 w/OnOrderUpdate and OnExecutionUpdate

    Okay, I'm stuck.

    I moved a strategy over from NT7 to NT8, and read the code breaking changes related to both OnOrderUpdate and OnExecutionUpdate. I thought I had made the proper code changes, but the compiler is spitting back the following:

    Code:
    'NinjaTrader.NinjaScript.Strategies.PandaVer1.OnOrderUpdate(NinjaTrader.Cbi.Order)': no suitable method found to override
    'NinjaTrader.NinjaScript.Strategies.PandaVer1.OnExecutionUpdate(NinjaTrader.Cbi.Execution)': no suitable method found to override
    I originally thought I just had to change this line:
    Code:
    protected override void OnOrderUpdate(Order order)
    ... to this syntax:
    Code:
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
    -----

    When I tried that, the compiler came back with errors saying that every NT8 local indicator I had (the stock ones that came with an NT8 install) had duplicate indicator values.

    Well then, not sure where to go...

    -------------

    Here's the general structure of the code with a few examples. If anyone has any guidance, I'd love to hear it:

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class PandaVer1 : Strategy
    {

    private Order longOrder = null;
    private Order shortOrder = null;


    protected override void OnOrderUpdate(Order order)
    {
    // When we determine to stop our strategy all logic in the OnOrderUpdate() method will cease.
    if (haltProcessing == true)
    return;

    // Cancelling long limit orders
    if (longOrder != null && longOrder == order // If there's a long order active
    && longOrder.OrderType == OrderType.Limit // and it's a limit order
    && longOrder.OrderState == OrderState.PartFilled // and the order is partially filled
    && // and...
    (Close[0] < longOrder.LimitPrice - .15 // the price has gone below the limit order price
    || Close[0] > longOrder.LimitPrice + .15)) // or the price has gone above the limit order price:

    {
    shares_Amount = longOrder.Quantity; // Reset the shares amount to the current long order quantity
    CancelOrder(longOrder); // Cancel the remainder of the order
    Print("The limit long order was cancelled. The shares in play are " + shares_Amount + ".");
    }
    }

    protected override void OnExecutionUpdate(Execution execution)
    {
    /* Long Orders */
    if (longOrder == execution.Order && longOrder.OrderState == OrderState.Filled)
    { // do something amazing
    }
    }

    -----------------

    Thanks in advance!
    Last edited by Spiderbird; 06-30-2018, 03:59 PM.

    #2
    So the eventual answer was:

    - Keep OnOrderUpdate and OnExecutionUpdate outside the OnBarUpdate area.
    - Include the entire OnOrderUpdate line to avoid errors. This is what I eventually used:

    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity,
    int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)

    Comment


      #3
      Hello Spiderbird,

      Thank you for your note.

      Correct.

      OnExecutionUpdate,


      OnOrderUpdate,


      Please let us know if you need further assistance.
      Alan P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      77 views
      1 like
      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