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 NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      48 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X