Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can i catch rejected StopLoss-Order?

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

    How can i catch rejected StopLoss-Order?

    How can i catch a rejected StopLoss-Order because price of StopLoss is above market price?

    I have seen GetCurrentAsk, GetCurrentBid methodes.
    They are not helping for me on fast markets because of Calculate.OnBarClose.

    I'm looking for RealTimeErrorHandling-Solution while RealtimeErrorHandling.StopCancelCloseIgnoreRejects or IgnoreAllErrors is set.

    I try to catch related order by name on OnOrderUpdate but no order at all arrives with OrderState.Rejected!!!

    Order with name (SL_MyEntry) is attached as OCO.
    Error message occures for customer (see image) but no related event seen so far.
    (Working on simulated account...)


    NT 8.24.2

    Full code attached! Please help me out.
    Attached Files
    Last edited by PWidera; 05-25-2021, 07:05 AM.

    #2
    PHP Code:
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    try
    {
    Print("OrderName: " + order.Name + " OrderState: " + order.OrderState.ToString() + " Time: " + DateTime.Now.ToString("HH:mm:ss.fff"));
    
    if (order.Name == "MyEntry")
    {
    entryOrder = order;
    }
    
    if (order.Name == "SL_MyEntry")
    {
    stopOrder = order;
    
    if (stopOrder != null && stopOrder == order)
    {
    // Rejection handling
    if (order.OrderState == OrderState.Rejected)
    {
    Print("Order rejected!");
    ExitLong("StopBreak", "MyEntry");
    } 
    

    Comment


      #3
      On real money account, there also no OrderState.Rejected detectable!
      Instead valid position directly closed.
      Is this normal?

      In this case there is no need to implemend of RealtimeErrorHandling for rejected StopLosses!?

      Comment


        #4
        Why on simulation-account an error message occures and systematic (direct close) is not the same as on real money account?
        Was same strategy and same data-feed.

        Just one time related to (sim101)-Account and one time on (real)-Account.
        Last edited by PWidera; 05-25-2021, 08:51 AM.

        Comment


          #5
          If the system behavior on simulation-account ist not the same then on realmoney-Account and OrderState.Rejected can not be detected,
          then you can never track performance on simulation-account before shifting to live!?

          Looking forward for an support comment...
          Last edited by PWidera; 05-25-2021, 08:59 AM.

          Comment


            #6
            Hello PWidera,

            Thanks for your post.

            Please note that we cannot provide debugging services for your strategy.

            Here is a short video that demonstrates handling order rejections: https://Paul-ninjaTrader.tinytake.co...MF8xNjk4NDc3Mg

            You may want to change your calculate to OnEachTick or OnPriceChange and configure your strategy so that some parts only perform once per bar based on the bool IsFirstTickOfBar and be able to use ObEachtick Or OnPriceChange when you need it for your stop movement.

            References:



            Comment


              #7
              Hi Paul,

              i have seen your video and double check everything on my side!
              With all the same settings and related code for orders, i never can catch any rejected StopOrder.

              You can see that a stop-change (orange to blue line) is mutch above current market price!
              Printout of current OrderState shows a submitted and accepted order, while error message occurs.
              This makes no sense for me and i don't know what should be wrong.... :-(
              Attached Files

              Comment


                #8
                Hello PWidera,

                Thanks for your reply.

                I would suggest starting with a simple strategy to replicate what we've shown in the video.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                81 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                149 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                79 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                52 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                58 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X