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

SetStopLoss blocking exits

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

    SetStopLoss blocking exits

    I have 2 related questions regarding SetStopLoss(), which I'm updating on every call to OnBarUpdate() and not setting in Initialize().

    1. On live trading SetStopLoss() blocks all ExitLong() and ExitShort() calls which return null. Why? The Exit calls work fine in backtest mode.

    2. I could understand (1) if this was related to the need to cancel the stop order before submitting the exit. So to this end I tried using OnOrderUpdate() to capture the order id generated by SetStopLoss() only to find that OnOrderUpdate() is never called when the stop loss order is created or amended, only when/if it gets filled. Isn't the point of OnOrderUpdate() to see all updates to live orders?

    So why is this happening and what should I use instead? I just want to set a software intrabar stop and exit/take profits using market orders on firsttickofbar.


    Thanks

    #2
    Hmm. Off the top of my head I don't recall SetStopLoss() blocking out Exit() methods. I think it just takes whichever closes the position first and cancels the extras. Have you used TraceOrders=true to confirm the behavior you are experiencing?

    In regards to OnOrderUpdate() the Set() methods do not return an IOrder object which is why it is not "trackable" in the OnOrderUpdate() in that manner. You can still track it by the order name by checking the order object that is called. The recommended fashion to handle this scenario would be to opt for using ExitLongStop() etc type orders to behave as your stops. It will provide you with the utmost granularity in stop/target control. You can see an example of how to do this in the Reference Sample section of the forum. Look for the sample entitled with OnOrderUpdate() and OnExecution().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Originally posted by Josh View Post
      Have you used TraceOrders=true to confirm the behavior you are experiencing?
      I enabled TraceOrders and the order is rejected with reason "There is no remaining quantity to exit". To doubly confirm I removed all SetStopLoss() calls and the order is not rejected. None the wiser, looks like a NT bug.


      Originally posted by Josh View Post
      In regards to OnOrderUpdate() the Set() methods do not return an IOrder object which is why it is not "trackable" in the OnOrderUpdate() in that manner. You can still track it by the order name by checking the order object that is called.
      Yes, thats what I'm doing, checking for the "order.Name" as I have no order id. This is why I'm using OnOrderUpdate. OnOrderUpdate is still never called for the "Stop loss" order until it is filled.


      Originally posted by Josh View Post
      The recommended fashion to handle this scenario would be to opt for using ExitLongStop() etc type orders to behave as your stops.
      Don't want to use ExitLongStop() etc as I want to use the software stop facility which only comes with SetStopLoss() that prevents orders from actually being placed on the market.


      If no body knows or its not possible I will probably revert to managing stops myself tick by tick as can't seem to trust SetStopLoss(). Thing is, it still works fine in backtest mode.

      Comment


        #4
        Hi Gumphrie,

        I have just confirmed the issue you were experiencing. It is related to the use of the simulated stop. Thanks for reporting. You will find that it has no issue if you use a real order for the time being.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          So there is currently no simulated stop solution at all apart from doing it yourself in code or ETA for a fix?

          Comment


            #6
            Right sim stops do not work as expected. Fix will be available with next update of NT6.5, likely early June. Thanks for reporting this bug.

            Will follow up on PM shortly.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DawnTreader, Yesterday, 05:58 PM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by OllieFeraher, Today, 11:14 AM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by GwFutures1988, 10-15-2023, 12:13 AM
            12 responses
            517 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by quicksandatl, Today, 11:11 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by aman jain, 10-01-2020, 09:25 PM
            3 responses
            293 views
            0 likes
            Last Post Legiboka  
            Working...
            X