Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 orderdouble limitPricedouble stopPriceint quantityint filleddouble averageFillPriceOrderState orderStateDateTime timeErrorCode errorstring 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:



            Paul H.NinjaTrader Customer Service

            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.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by selu72, Today, 02:01 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Zachary  
                Started by WHICKED, Today, 02:02 PM
                2 responses
                8 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Started by f.saeidi, Today, 12:14 PM
                8 responses
                21 views
                0 likes
                Last Post f.saeidi  
                Started by Mikey_, 03-23-2024, 05:59 PM
                3 responses
                50 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by Russ Moreland, Today, 12:54 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X