Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetRealtimeOrder() concept

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

    GetRealtimeOrder() concept

    Hi,

    Who can explain me the current 'GetRealtimeOrder()' concept with OnOrderUpdate() callback? As far as I know - the OnOrderUpdate will be called as soon as an order's state is changed. Let's assume that I have a BuyStopOrder that was opened in Historical filling. Each new candle I want to modify the order (change the order's stop price). Let's assume that the Realtime is started. On a new realtime candle I'm trying to modify the historical BuyStopOrder - will I get the 'unable to change historical order error' if the attemp of the 'GetRealtimeOrder' only in OnOrderUpdate callback?

    As far as I remember - based on the previous rules the 'GetRealtimeOrder' was used in the 'OnStateChange()' callback.

    #2
    Hello webus,

    GetRealtimeOrder() is specifically useful if you have assigned an order object to a variable in historical data, and then the strategy transitions to real-time. This makes sure your variable has the up-to-date order object.

    It's necessary to do this at least once, as the strategy transitions to real-time in OnStateChange() to get the variables pointed to the right object. After the transition it is no longer necessary to use this for new orders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello webus,

      GetRealtimeOrder() is specifically useful if you have assigned an order object to a variable in historical data, and then the strategy transitions to real-time. This makes sure your variable has the up-to-date order object.

      This is basically only done once, as the strategy transitions to real-time in OnStateChange() to get the variables pointed to the right object. After the transition it is no longer necessary to use this for new orders.
      Thanks a lot!
      Hovewer, my question was not about what the GetRealtimeOrder is. I understand that the GetRealtimeOrder should be used only once (based on the new guide) and what for. My question was about a specific example. I do not think that I should rewrite it again.. It is too hard to get an answer on an exact question here. Should I rewrite my example?

      The key thing - a historical order should be converted in a realtime order only in the OnOrderUpdate callback, right? However, the OnOrderUpdate will be called ONLY if a Strategy order's is changed, right? So, the Realtime comes, a new candle arrives and the Strategy modifies the Historical order using 'ChangeOrder' function. Will the platform convert the historical order into realtime order only at this moment (as soon as 'ChangeOrder' is used)? I believe that I will see the 'unable to change historical order error'.

      Or another example - the Realtime comes and the historical order is being filled. So, OnOrderUpdate comes and this line is executed:
      PHP Code:
      if (myOrder != null && myOrder.IsBacktestOrder && State == State.Realtime)        
          myOrder = GetRealtimeOrder(myOrder); 
      
      HOWEVER, the current state is FILLED. How the platform will make it a realtime order at the moment when the state is FILLED?

      Comment


        #4
        Hello webus,

        As far as I know - the OnOrderUpdate will be called as soon as an order's state is changed.
        Yes, OnOrderUpdate is called when the OrderState of an order has changed.

        On a new realtime candle I'm trying to modify the historical BuyStopOrder - will I get the 'unable to change historical order error' if the attemp of the 'GetRealtimeOrder' only in OnOrderUpdate callback?
        Yes, if the order variable is being used elsewhere and GetRealtimeOrder hasn't retrieved the realtime order in OnStateChange(), that variable may have a historical object as the order may not be the order updating OnOrderUpdate().

        a historical order should be converted in a realtime order only in the OnOrderUpdate callback, right?
        The order object supplied from the parameters of OnOrderUpdate() would be updated. However, no, this would not update variables holding stale orders that should be updated in OnStateChange().

        Will the platform convert the historical order into realtime order only at this moment.
        The order that was placed in historical in a working state would be transitioned to real-time when OnStateChange() runs with State.Transition / State.Realtime. The order itself (not the variable holding the order) is already converted to a new real-time order object and still in a working state as it has not yet filled. When OnOrderUpdates when it fills, the order is already realtime. The variable holding the stale order would not be changed to the real-time order however, unless GetRealtimeOrder() is called on it. (You don't have to do that in OnStateChange(), but that is the best place so that you are only calling this once on the order at the time the order becomes realtime). The OnOrderUpdate() method would only be providing an order object, that would be updated in real-time. It does not, however, repoint variables to the new real-time object.

        HOWEVER, the current state is FILLED. How the platform will make it a realtime order at the moment when the state is FILLED?
        If the order filled in real-time that would be the order object from the parameters of OnOrderUpdate. But the myOrder variable would already have been converted to the up-to-date object when assigned the new order object in OnStateChange. The code you have here doesn't really make sense.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_ChelseaB​,


          .. and GetRealtimeOrder hasn't retrieved the realtime order in OnStateChange()...
          The order that was placed in historical in a working state would be transitioned to real-time when OnStateChange() runs with State.Transition / State.Realtime.
          Sorry, not sure about this. Do you mean that the platform convers the historical order automatically as soon as the State is 'Realtime' and the purpose of GetRealtimeOrder() is just to get the 'link' to to current realtime order?
          In other words, the 'GetRealtimeOrder()' does not start the 'converting process', am I correct?

          Comment


            #6
            Hello webus,

            Yes, that is my understanding. Another way of saying that is fetch the real-time order as I only have the historical order. Orders are made real-time when the script reaches real-time.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi NinjaTrader_ChelseaB​,​

              Yes, that is my understanding. Another way of saying that is fetch the real-time order as I only have the historical order. Orders are made real-time when the script reaches real-time.
              Got it. However, I cannot confirm this (based on my experience).. For instance, on the 'My Continuum' connection I've tested this:
              - I use Unmanaged Approach.
              - My Strategy opens a Long position and a reverse SellLimit order on the Long's StopLoss order's price.
              - Long position is opened in Historical state and the reverse SellLimit is placed in the Historical state also.
              - StopLoss for the historical Long position is triggered in Realtime state - and the historical (virtual) position is closed. At the same time the historical (virtual) SellLimit is triggered (because the limit price is the same as StopLoss price). I expected that the SellLimit will be triggered as virtual order (because this reverse order only makes sense if the initial position is real. Also because I did not use the 'GetRealtimeOrder()' when the 'State == State.Realtime' is changed (I did not use 'GetRealtimeOrder()' at all)). However, the first thing I saw was an attempt to make the virtual Sell Limit order a real order - and I got the error "cannot change the price above the market price" at the moment the order was triggered. So, so the limit order remained a historical order until it was triggered.
              Again, I did not use the object of the order and did not try to change it or something like this.

              But this contradicts this statement:
              Do you mean that the platform convers the historical order automatically as soon as the State is 'Realtime'?
              Yes, that is my understanding.
              This is why I'm asking the details regarding the 'GetRealtimeOrder()'. Am I missing something?

              Comment


                #8
                Hello webus,

                Where you have mentioned:
                StopLoss for the historical Long position is triggered in Realtime state - and the historical (virtual) position is closed. At the same time the historical (virtual) SellLimit is triggered (because the limit price is the same as StopLoss price)
                You are saying both the stop and limit filled? If so, I would recommend using the unmanaged approach so that you can use OCO on the orders (one-cancels-others).


                The error 'cannot change the price above the market price' is likely occurring by attempting to use or modify an order saved to a variable during State.Historical and not the real-time order fetched with GetRealtimeOrder().

                To demonstrate, below is a link to a video of an order submitted in historical, that is able to fill without error in real-time.


                Only when that historical order is attempted to be manipulated in real-time would there be an error without GetRealtimeOrder() used to fetch the real-time order.


                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi NinjaTrader_ChelseaB​,​

                  You are saying both the stop and limit filled?
                  Sorry, I mean not limit, but stop order. I mean that the Strategy uses:
                  [Long position + StopLoss order + TakeProfit order] AND a [reverse SellStop order] on the same price as Long's position StopLoss order. So, totally 1 position and 3 orders. TakeProfit and StopLoss are OCO orders. The reverse SellStop order is just an independent order that is triggered at the same price as StopLoss order. That's all.


                  If so, I would recommend using the unmanaged approach
                  As I wrote - I'm using the unmanaged approach. Please take a look at the '- I use Unmanaged Approach.' point in the previous post.


                  ​The error 'cannot change the price above the market price' is likely occurring by attempting to use or modify an order saved to a variable during State.Historical and not the real-time order fetched with GetRealtimeOrder().
                  Again. I do not use the variable and do not modify or use it somehow. The error appears as soon as the Long's StopLoss is filled and SellStop order is triggered. The error appears because the platform is trying to make a realtime order from the historical order at the same time as the historical Stop order is triggered.

                  Let's take a look at the specific case.
                  Here is the log from a specific case with Short position + StopLoss + TakeProfit and reverse BuyStop Order. You can see the line 'NinjaScript strategy 'Strat/194735414' submitting order' -> but the Strategy did not open any orders at this time. This BuyStop order was:
                  'orderId='NT-00309-116' account='1067067' name='Long_Rev' orderState=Working instrument='ES 09-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4476.25 quantity=6 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'' order.
                  The plarform tried to make in a realtime order as soon as the BuyStop order is triggered:

                  HTML Code:
                  2023-06-30 07:40:48:782|1|4|Enabling NinjaScript strategy 'Strat/194735414' : On starting a real-time strategy - StartBehavior=WaitUntilFlat Position=ES 09-23 3S EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=True MaxRestarts=4 in 5 minutes
                  ​
                  ....................
                  
                  2023-06-30 07:45:00:700|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4476.75, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime, OrderState: Filled, Order: orderId='NT-00303-116' account='1067067' name='SL_1' orderState=Filled instrument='ES 09-23' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=4476.25 quantity=1 tif=Gtc oco='7a574079d0904e77ba35fcc74fe1ec27' filled=1 averageFillPrice=4476.75 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'
                  ​
                  2023-06-30 07:45:00:709|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4476.75, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderTrace:927) State:Realtime, timestamp: 6/30/2023 7:45:00 AM, message:Strategy 'JosephHStrategy1v1v1/194735414': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00304-116' account='1067067' name='TP_1' orderState=Working instrument='ES 09-23' orderAction=BuyToCover orderType='Limit' limitPrice=4467.25 stopPrice=0 quantity=1 tif=Gtc oco='7a574079d0904e77ba35fcc74fe1ec27' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'
                  
                  2023-06-30 07:45:00:710|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4476.75, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime, OrderState: CancelPending, Order: orderId='NT-00304-116' account='1067067' name='TP_1' orderState=CancelPending instrument='ES 09-23' orderAction=BuyToCover orderType='Limit' limitPrice=4467.25 stopPrice=0 quantity=1 tif=Gtc oco='7a574079d0904e77ba35fcc74fe1ec27' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'
                  
                  2023-06-30 07:45:00:711|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4476.75, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime, OrderState: CancelSubmitted, Order: orderId='NT-00304-116' account='1067067' name='TP_1' orderState=CancelSubmitted instrument='ES 09-23' orderAction=BuyToCover orderType='Limit' limitPrice=4467.25 stopPrice=0 quantity=1 tif=Gtc oco='7a574079d0904e77ba35fcc74fe1ec27' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'
                  
                  2023-06-30 07:45:00:711|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4476.75, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime, OrderState: Cancelled, Order: orderId='NT-00304-116' account='1067067' name='TP_1' orderState=Cancelled instrument='ES 09-23' orderAction=BuyToCover orderType='Limit' limitPrice=4467.25 stopPrice=0 quantity=1 tif=Gtc oco='7a574079d0904e77ba35fcc74fe1ec27' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'
                  
                  ​2023-06-30 07:45:00:720|1|4|NinjaScript strategy 'Strat/194735414' submitting order
                  
                  2023-06-30 07:45:00:773|1|32|Order='ebabf2c9418946cca9eb7348ebb1e504/1067067' Name='Long_Rev' New state='Submitted' Instrument='ES 09-23' Action='Buy' Limit price=0 Stop price=4476.25 Quantity=6 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                  
                  2023-06-30 07:45:00:773|1|16|name='Strat' id=194735414 Logger: ES 09-23 (L:4477, A:4477, B:4476.75) (0) 6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime, OrderState: Submitted, Order: orderId='ebabf2c9418946cca9eb7348ebb1e504' account='1067067' name='Long_Rev' orderState=Submitted instrument='ES 09-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4476.25 quantity=6 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=4283 time='2023-06-30 07:45:00' gtd='2099-12-01' statementDate='2023-06-30'
                  
                  2023-06-30 07:45:00:837|1|32|Order='ebabf2c9418946cca9eb7348ebb1e504/1067067' Name='Long_Rev' New state='Rejected' Instrument='ES 09-23' Action='Buy' Limit price=0 Stop price=4476.25 Quantity=6 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Buy order stop price must be above last trade price ExchangeRejectCode = 2061'
                  
                  2023-06-30 07:45:00:839|0|32|1067067, Buy order stop price must be above last trade price ExchangeRejectCode = 2061 affected Order: Buy 6 StopMarket @ 4476.25
                  
                  2023-06-30 07:45:00:837|0|4|Strategy 'Strat/194735414' submitted an order that generated the following error 'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
                  ​

                  To sum up:
                  As you can see (I hope) - something is wrong. There is a contradiction. According to your statement - this historical BuyStop order 'NT-00309-116' should have become real before it was filled. However, this did not happen. The platform only started making it real the moment it started be filled. Do you see what I mean?

                  Comment


                    #10
                    Hello webus,

                    As a tip, to provide a text file that can be easily read (and prevent long posts without output) right-click the NinjaScript Output window -> select Save As. This will save a text file with the output information you can attach to your post (click Upload Attachments below).

                    It appears you are overriding OnOrderTrace, is this correct? (If so, temporarily can you comment this out so we can see the original TraceOrders information?)


                    I am not seeing any evidence that an order was transitioned to realtime. The first output I am seeing is that the state is already realtime
                    6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime

                    I'm not seeing any orders submitted in historical.

                    What evidence is in this output that you feel shows an order has changed from historical to realtime at the time an order is submitted?


                    Further, in the output you have provided, there is a rejected order due to an invalid price. I am not seeing any error message about an order needing to be transitioned. Can you provide the output where this message is occurring?

                    The error message will state:
                    Strategy ... has been disabled because it attempted to modify a historical order that has transitioned to a live order. Please see the help guide for more information on transitioning order references from historical to live.
                    Regarding the invalid order price error:
                    2023-06-30 07:45:00:839|0|32|1067067, Buy order stop price must be above last trade price ExchangeRejectCode = 2061 affected Order: Buy 6 StopMarket @ 4476.25
                    You will need valid order price. A buy stop order must have the stop price above the current ask (GetCurrentAsk(). A sell stop order must have the stop price below the current bid.
                    Hi I have a sellshort StopLimit order that i change if unfilled. I tick below the last bar's low. I keep getting the stop price can't be changed above the market but the price value it quotes ( the one I want) is below the market. Currently I am on the simulated feed. I appreciate in real market situations this could happen


                    This order was rejected because the stop price was equal to or below the current ask price.

                    I have to make the assumption A:4477 is the output from GetCurrentAsk().

                    A stop price of 4476.25 is not greater than 4477.

                    This is not related to using GetRealtimeOrder(). This is an invalid stop price.



                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi NinjaTrader_ChelseaB​,​​

                      As a tip, to provide a text file that can be easily read (and prevent long posts without output) right-click the NinjaScript Output window -> select Save As. This will save a text file with the output information you can attach to your post (click Upload Attachments below).
                      It appears you are overriding OnOrderTrace, is this correct? (If so, temporarily can you comment this out so we can see the original TraceOrders information?)​
                      Sorry, I see where everything is going. I will have to waste my time again and again doing one test after another and providing a log file one after another until I get bored. Not this time. I highlighted the parts of the log with the error. OrOrderTrace() and OnBarUpdate().
                      As far as I see - OrOrderTrace and OnBarUpdate prints all the posible data, isn't it?


                      I am not seeing any evidence that an order was transitioned to realtime. The first output I am seeing is that the state is already realtime
                      6/30/2023 7:45:00 AM (OnOrderUpdate:560) State:Realtime

                      I'm not seeing any orders submitted in historical.​
                      Do you see the line '​2023-06-30 07:45:00:720|1|4|NinjaScript strategy 'Strat/194735414' submitting order'? This is when the platfrom tried to make the current 'NT-00309-116' BuyStop order into a realtime order. It was at the same time as soon as a virtual StopLoss ('NT-00303-116') order is triggered. Do you see the order's IDs?
                      You can say that 'NinjaScript strategy 'Strat/194735414' submitting order' means that the Strategy placed a pending BuyStop order, but - not. The order was already placed at the same time as the StopLoss ('NT-00303-116') order. As I see it - this is how the platform tried to make the virtual BuyStop order ('NT-00309-116') a realtime order.
                      Once again - the Strategy does not use 'GetRealtimeOrder()' function at all.


                      What evidence is in this output that you feel shows an order has changed from historical to realtime at the time an order is submitted?
                      Sorry, but you do not hear me. Again - the BuyStop order was placed at State = State.Historical at the same time as StopLoss order (that was triggered at the State = State.Realtime). The virtual BuyStop order's details are (please take a look at the stopPrice and order's time):
                      'orderId='NT-00309-116' account='1067067' name='Long_Rev' orderState=Working instrument='ES 09-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4476.25 quantity=6 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-30 07:39:00' gtd='2099-12-01' statementDate='2023-06-30'' order.
                      Let me explain it in other way. The issue is in the line: 'NinjaScript strategy 'Strat/194735414' submitting order' -> the Strategy did not send any orders. I guess this is how the platform tried to conver a virtual 'NT-00309-116' into a realtime order at the moment when the 'NT-00309-116' was being triggered. This is the key point. Is it clear what I mean?



                      Further, in the output you have provided, there is a rejected order due to an invalid price. I am not seeing any error message about an order needing to be transitioned. Can you provide the output where this message is occurring?​
                      For this case I did not tell about 'any error message about an order needing to be transitioned​'. My problem is with the random 'NinjaScript strategy 'Strat/194735414' submitting order' event as soon as the virtual 'NT-00309-116' is being filled.


                      Regarding the invalid order price error:
                      You will need valid order price. A buy stop order must have the stop price above the current ask (GetCurrentAsk(). A sell stop order must have the stop price below the current bid.
                      https://forum.ninjatrader.com/forum/...ed#post1199001
                      This order was rejected because the stop price was equal to or below the current ask price.
                      Thanks for the clarification, but I understand what the error means. Please focus on this: the Strategy did not place any orders at this time. The message ​'Strat/194735414' submitting order' is related to the virtual 'NT-00309-116' order that was placed at the same time as StopLoss order was placed - long before this message appeared. The key thing: the Strategy did not place any orders at this time!



                      I have to make the assumption A:4477 is the output from GetCurrentAsk().
                      A stop price of 4476.25 is not greater than 4477.
                      This is not related to using GetRealtimeOrder(). This is an invalid stop price.​
                      Yes, 'A' means 'GetCurrentAsk()'.
                      Yes, this is not related to GetRealtimeOrder() fucntion, because my Strategy does not use it at all (!)
                      Yes, this is related to 'invalid stop price' - BUT the Strategy did not place any orders at this time. There was a historcial order on this price, but the platfrom decided to make it a realtime order and resent it as a realtime order at the moment when the historical was being filled.



                      Comment


                        #12
                        Hello webus,

                        Unfortunately, I am not seeing the issue.

                        I re-reviewed the text in post # 9 and the State: Historical is not in that text. I am not seeing any evidence this order was submitted in historical.

                        Do you see the line '​2023-06-30 07:45:00:720|1|4|NinjaScript strategy 'Strat/194735414' submitting order'? This is when the platfrom tried to make the current 'NT-00309-116' BuyStop order into a realtime order.
                        Possibly. However, this would show in the log. In the output from the output window from Print(order.ToString()); in OnOrderUpdate() you will see the new real-time update, as shown in the video I have provided you. May I confirm you have reviewed this video?

                        Do you see the order's IDs?
                        I do not. I see only one order in that text, order 'ebabf2c9418946cca9eb7348ebb1e504'. What is the other order ID?

                        Sorry, but you do not hear me. Again - the BuyStop order was placed at State = State.Historical
                        Please copy and paste the single line of text showing the order update from OnOrderUpdate() where the State is Historical from post # 9.

                        The issue is in the line: 'NinjaScript strategy 'Strat/194735414' submitting order' -> the Strategy did not send any orders.
                        This is incorrect. An order was submitted and it was rejected due to an invalid price.

                        Strategy submits order message:
                        ​2023-06-30 07:45:00:720|1|4|NinjaScript strategy 'Strat/194735414' submitting order

                        Order is in Submitted state, meaning it was submitted:
                        2023-06-30 07:45:00:773|1|32|Order='ebabf2c9418946cca9eb7348e bb1e504/1067067' Name='Long_Rev' New state='Submitted' Instrument='ES 09-23' Action='Buy' Limit price=0 Stop price=4476.25 Quantity=6 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''

                        Order is rejected:
                        2023-06-30 07:45:00:837|1|32|Order='ebabf2c9418946cca9eb7348e bb1e504/1067067' Name='Long_Rev' New state='Rejected' Instrument='ES 09-23' Action='Buy' Limit price=0 Stop price=4476.25 Quantity=6 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Buy order stop price must be above last trade price ExchangeRejectCode = 2061'


                        For this case I did not tell about 'any error message about an order needing to be transitioned​'.​
                        Your inquiry is about GetRealtimeOrder() which is only used to fetch a real-time order.

                        From your initial post:
                        Who can explain me the current 'GetRealtimeOrder()' concept with OnOrderUpdate() callback?
                        You are asking how GetRealtimeOrder() works. I have attempted to explain it's use in a video.

                        This method does not make any modifications to any orders and does not transition orders. The orders are transitioned automatically. Because they are transitioned to real-time orders automatically, it is necessary in the code to point any variables holding the old historical order to the new real-time orders.

                        This method is only to prevent the error message: "Strategy ... has been disabled because it attempted to modify a historical order that has transitioned to a live order."

                        There is no other use for this method. It does affect how orders are submitted or filled. Not related at all.

                        Please focus on this: the Strategy did not place any orders at this time.
                        An order was submitted by the strategy. It could have been an order transitioning to real-time and not from a method call at that moment, however there is no evidence of this in the output that I can see.

                        Yes, this is not related to GetRealtimeOrder() fucntion, because my Strategy does not use it at all (!)​
                        The inquiry of this thread from post # 1, is about how GetRealtimeOrder() is used. Have I inadequately explained what this method is for?

                        Yes, this is related to 'invalid stop price' - BUT the Strategy did not place any orders at this time. There was a historcial order on this price, but the platfrom decided to make it a realtime order and resent it as a realtime order at the moment when the historical was being filled.
                        While there is no evidence of this claim, that could be the case and would be an issue that is not related to GetRealtimeOrder().​

                        If this is an order that was transitioned to real-time and was working with a price in historical that was not a valid price in real-time, that would cause this order to be rejected. The historical orders are calculated using historical data. 1-tick intra-bar granularity can help with this as it will calculate more accurate prices. However, it may be necessary to use a further distance from the current price so that it does not get rejected in real-time.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by NullPointStrategies, Yesterday, 05:17 AM
                        0 responses
                        56 views
                        0 likes
                        Last Post NullPointStrategies  
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        132 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        73 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        45 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        49 views
                        0 likes
                        Last Post TheRealMorford  
                        Working...
                        X