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

Doubt - Verification Error (Filled)

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

    Doubt - Verification Error (Filled)

    Could someone help me with this problem, if I perform this verification, an error occurs.

    ================================================== ============================
    // One time only, as we transition from historical
    // Convert any old historical order object references to the live order submitted to the real-time account

    if (OrderCompra != null && OrderCompra.IsBacktestOrder && State == State.Realtime)
    OrderCompra = GetRealtimeOrder(OrderCompra);

    if (order.Name == "C1" && orderState != OrderState.Filled)
    OrderCompra = order;

    if (order.Name == "C2" && orderState != OrderState.Filled)
    OrderCompra = order;

    if (order.Name == "C3" && orderState != OrderState.Filled)
    OrderCompra = order;

    if (OrderCompra != null && OrderCompra == order)
    {
    if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
    OrderCompra = null;

    if (order.OrderState == OrderState.Filled)
    OrderCompra = null;
    }
    ================================================== ============================
    NinjaScript-Output
    (Error on calling 'OnBarUpdate' method on bar 94: Object reference not set to an instance of an object.)

    ================================================== ============================​

    #2
    Hello WenisCR,

    Your code is trying to set 3 different orders to the same variable, that will eventually lead to a null error like you displayed.

    If you have "C1" C2" and C3" orders you need 3 separate order variables. OrderCompra would only represent a single order such as C1.

    The logic you have shown would need to be replicated 3 times if you have 3 orders.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,
      Thanks for the info, I'll try.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,983 views
      3 likes
      Last Post jhudas88  
      Working...
      X