Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetRealtimeOrder() and OrderState.Filled

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

    GetRealtimeOrder() and OrderState.Filled

    Hi,

    Correct me if I'm wrong but if an order object (entryLong for example) is OrderState.Filled in State.Historical, using
    Code:
    GetRealtimeOrder(entryLong)
    during the State == State.Realtime will return a "null" value for entryLong.


    I realized this very belatedly, and ended up coding a bunch of stuff that relies on
    Code:
    if (entryLong != null)
    to run a bunch of code, even after the order has filled.


    This worked wonderfully during backtest and on historical charts, but ran into obvious issues during live trading.

    Is there a way to force GetRealtimeOrder(entryLong) to not return a null value for OrderState.Filled? Or does anyone have some thoughts on how to workaround this?

    Last resort is to change all code that relies on "if (entryLong != null)", a prospect that I'm not relishing as its quite a bit!

    Thanks in advance.


    #2
    Hello nicbizz,

    You could use GetRealtimeOrder() and if it returns null not assign the order to the variable.

    if (GetRealtimeOrder(order) != null)
    entryLong = GetRealtimeOrder(order);

    Or

    entryLong = GetRealtimeOrder(order) != null ? GetRealtimeOrder(order) : entryLong;
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello nicbizz,

      You could use GetRealtimeOrder() and if it returns null not assign the order to the variable.

      if (GetRealtimeOrder(order) != null)
      entryLong = GetRealtimeOrder(order);

      Or

      entryLong = GetRealtimeOrder(order) != null ? GetRealtimeOrder(order) : entryLong;
      Oh wow, this worked brilliantly.

      THANK YOU SO MUCH! You have no idea how I relieved I am not having to redo a big swath of code.

      -Nick

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X