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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X