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

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 swestendorf, Today, 11:14 AM
      2 responses
      5 views
      0 likes
      Last Post NinjaTrader_Kimberly  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      4 responses
      13 views
      0 likes
      Last Post xiinteractive  
      Started by Mupulen, Today, 11:26 AM
      0 responses
      2 views
      0 likes
      Last Post Mupulen
      by Mupulen
       
      Started by Sparkyboy, Today, 10:57 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by TheMarlin801, 10-13-2020, 01:40 AM
      21 responses
      3,917 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X