Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IOOrder variable not NULL

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

    IOOrder variable not NULL

    Hello.

    For some reason my IOrder variable is not seen as NULL initially.

    I set it to NULL, but its not seen as NULL when it gets to OnBarUpdate() section.

    In the output window, its seen as containing the following text:

    longOrderA = Order='NT-00003/Sim101' Name='Long Part A' State=Cancelled Instrument='TF 06-11' Action=Buy Limit price=855.3 Stop price=0 Quantity=1 Strategy='rcsSimpleSuperGrail' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='160642e28e2a49b0b15e28fd9472fd63' Gtd='12/1/2099 12:00:00 AM'

    Not sure what I'm doing wrong. I have my code listed below.

    Variable:
    Private IOrder longOrderA = null;

    OnBarUpdate()
    if ( longOrderA == null && arrowDir == "up" ) // && "other code for those two indicator arrows" )
    {
    if ( Position.MarketPosition == MarketPosition.Short ) // handling Stop and Reverse condition
    {
    ExitShort();
    SetStopLoss(CalculationMode.Ticks, _initialStopLoss);
    }

    longOrderA = EnterLongLimit(_numOfContracts, GetCurrentBid(), "Long Part A");
    barNumberOfOrder = CurrentBar;
    }

    #2
    Hello rcsingleton,

    It will no longer be null once the condition is true and you assign it a value. Do you have logic in place that resets this object back to null when filled or cancelled?



    Code:
    protected override void OnOrderUpdate(IOrder order)
    {
        if (entryOrder != null && entryOrder == order)
        {
             Print(order.ToString());
            if (order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled)
                  entryOrder = null;
        }
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Yes, that fixed it. Thanks

      protected override void OnOrderUpdate(IOrder order)
      {
      // Resetting IOrder object(s) to NULL after order is filled
      if ( longOrderA != null && longOrderA == order )
      {
      Print(order.ToString());
      if ( order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled )
      longOrderA = null;
      }

      if ( shortOrderA != null && shortOrderA == order )
      {
      Print(order.ToString());
      if ( order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled )
      shortOrderA = null;
      }

      }
      Last edited by rcsingleton; 04-08-2011, 09:07 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      639 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      572 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X