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

new SL and PT generated

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

    new SL and PT generated

    Hello,

    I am running SampleOnOrderUpdate strategy linked here


    So it works perfectly fine, when the condition is met it executes an entryLong and respective SL and PT orders.
    If I disable the strategy SL and PT remain submitted and when I enable it again using Immediately submit behavior those SL and PT are ignored (not even cancelled) and new SL and PT orders are generated.

    Is it normal for this to happen? What should I expect when resuming the strategy?

    #2
    Hello 7robert,

    Thank you for your reply.

    The Stop Loss and Profit targets should get automatically cancelled in most situations when the strategy is disabled. If you're just running that SampleOnOrderUpdate strategy as is, that would be the expected behavior.

    Do you get any errors in the log tab of the Control Panel when this occurs?

    I would try using Immediately Submit, Sync Account instead - this should ensure the strategy and your account are on the same page.

    Here's a link to our help guide that goes over the various start behaviors:



    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      I'm using NT 8. Maybe could be different because of the version?. I test it with immediately submit, and the strategy creates new target and new stop loss. All stop loss orders were filled and only the last target order was cancelled, the rest of targets were left on a working state, also, the account position was in short (which it shouldn't happen). . I will try using immediately submit synchronize account as a start behavior.

      Comment


        #4
        Hello 7robert,

        Thank you for your reply.

        I've had this post moved over to the NinjaTrader 8 forum to avoid confusion.

        Likely the issue is that it didn't recognize the original stop and profit target as matching the previously generated orders, did not cancel them, which left you with too many stop orders. when they all filled, it didn't recognize the stop as being linked to the 2nd profit target, thus leaving it active and you in an unintended position.

        Important to note is the behavior for matching orders:
        • A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
        This would be important to keep in mind if you have the Strategy calculate and submit orders OnEachTick or OnPriceChange. Since historical data is processed OnBarClose unless Tick Replay is in use, the generated orders from historical data will not match the existing orders from the previous run. One suggestion here would be to use a single tick data series for your OnEachTick operations so the historically generated and live orders can match. See backtesting with intrabar granularity example below for an example on a strategy that uses a single tick data series.

        With this in mind, a strategy should be able to re-enter an existing position if NinjaTrader is configured to not cancel these orders on strategy disable. (Tools > Options > Strategies > NinjaScript)

        When testing these behaviors, I recommend using the Playback Connection or the Simulated Data Feed to mimic realtime data and to disable/re-enable your strategy in this environment. I have created a video demonstration showing the SampleOnOrderUpdate Strategy resume a position and included a link to this sample. You may run the same test as I have on your end and then you may run the same test using your strategy to verify the behavior with your strategy.

        One final note is that the SampleOnOrderUpdate strategy uses Order objects which require the references be updated when transitioning to Realtime (See State.Realtime in the example) This would not have to be minded for a strategy that does not use Order objects, however.

        I have also included a video from our NinjaTrader 7 tips section that explains these behaviors further.

        Resuming Positions with SampleOnOrderUpdate — https://www.screencast.com/t/FUCm2zymF8Cd

        SampleOnOrderUpdate — https://ninjatrader.com/support/help...and_onexec.htm

        Syncing Account Positions doc — https://ninjatrader.com/support/help..._positions.htm

        Understanding Syncing Account Positions (NT7) — https://www.youtube.com/watch?v=US9cKUwLMOA

        Backtesting with Intrabar granularity — https://ninjatrader.com/support/help...ipt_strate.htm

        Please let us know if you are seeing anything inconsistent with these tests or if you have any additional questions.
        Kate W.NinjaTrader Customer Service

        Comment


          #5

          Hello Kate, 7robert and I are in the same team, so I'm gonna join in the conversation

          You say
          Likely the issue is that it didn't recognize the original stop and profit target as matching the previously generated orders, did not cancel them, which left you with too many stop orders. when they all filled, it didn't recognize the stop as being linked to the 2nd profit target, thus leaving it active and you in an unintended position.
          This is exactly what we think is happening, which frankly I don't know if it is the correct behavior or not.

          Also you mention it is important to know how orders are matched when using OnEachTick or OnPriceChange as calculate parameter on the strategy, but is it also important if the value set for this parameter is OnBarClose? In our case, generated orders from historical data should match our realtime generated orders because we are using OnBarClose as calculate parameter.

          Our configuration of NT is set to not cancel orders on strategy disable, indeed.

          Thanks for the video demonstration we actually tried to replicate it with no success. We have also recorded a video to show you what we are experiencing with the strategy (this is the first time we do it, so if it wasn't clear enough please let us know).
          The link is https://www.screencast.com/t/WKLCVH5N

          We are following SampleOnOrderUpdate as an example for developing strategies that uses Order objects. This is the reason we are trying to learn from its behavior.

          Thanks in advance.

          Comment


            #6
            Hello lismartin,

            Thank you for your post.

            The video is very helpful, thank you for that. We're currently tracking an item related to strategies not recognizing previously placed orders after restart in some cases. I am going to do some testing to see if this is related to what our team is looking into. I'll let you know as soon as I have more information.

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello 7robert and lismartin,

              Thank you both for your patience.

              In our testing this does seem to connected to an issue we're going to address in the next revision of NinjaTrader. I'd like to invite you both to write in to Platformsupport [at] ninjatrader [dot] com with a link to this post as we'd like to have you test the continuous build and see if this will address the issue. Please put "2242780 ATTN Kate W." in the subject line.

              Thanks in advance; I look forward to resolving this for you.
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              606 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              4 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by aa731, Today, 02:54 AM
              0 responses
              5 views
              0 likes
              Last Post aa731
              by aa731
               
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              11 views
              0 likes
              Last Post Christopher_R  
              Working...
              X