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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X