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

ExitLongStopMarket not executing on same bar as entry

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

    ExitLongStopMarket not executing on same bar as entry

    Hello,

    I have a stop set up to execute if Price(Ask) falls below the Low of the signal bar.
    However, if this happens during the same bar as the positions entry, the order does not execute.
    The order eventually executes at EOD or from what would be the following entries stop area.

    How would I ensure the order executes even if its during the same bar as the positions entry?

    Thanks,

    Dave

    #2
    Hello DavidParkins,

    Thank you for your reply.

    If you're running the strategy OnBarClose and checking the position before submitting the exit order, it would be expected that the Stop order would not be placed until the next bar, as the strategy does not yet know that the entry order has filled.

    I would suggest trying running the strategy OnEachTick instead, as this would allow the strategy to trigger the exit order as soon as the entry order is filled and the change in position detected. This may require some reworking of the strategy to keep the strategy from re-entering multiple times on the same bar if conditions for entry are still true.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      I currently have the strategy set for OnEachTick. Sorry, I forgot to add that.
      I wondered if it had to do with the way the system recalled the data. So i ran the strategy through the night to test if the discrepancy occurred real-time. And it had occurred during the night.

      Thank you,

      Dave

      Comment


        #4
        Hello DavidParkins,

        Thank you for your reply.

        Can you supply a code sample or screenshots of the Strategy Builder if the strategy was created in that showing your logic for entry and your logic for the exit order? Without understanding what you're actually doing it's difficult to ascertain what may be occurring.

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

        Comment


          #5
          Unfortunately, I'm at work. But I will answer as best as I can remember.
          set 1
          CONDITIONS
          "Conditions"
          ACTIONS
          Enterlong
          (User variable) Set StopMode = 0
          (User variable) Set MyMIN = MIN(Low, 1)[0]

          SET 2
          CONDITIONS
          position=marketposition(long)
          and. StopMode = 0

          ACTIONS
          ExitLongStopMarket(Position.AveragePosition - (position.averageposition-((MyMin)"","")))


          I also ran the set 2 ACTIONS as
          ExitLongStopMarket((MyMIN)"","")

          I can screen capture at home later is this doesnt work.

          Comment


            #6
            Hello David,

            Thank you for your reply.

            I've made a simple example strategy with the same setup, and I'm seeing the stop order getting placed when I'd expect and filling when I'd expect. I do note you've mentioned multiple entries. If the next entry is made while another entry is already filled and in a position, it would be possible for the entire position to be closed by a stop placed later. If you're reusing the same entry logic again that updates the stop price it would change the existing stop to the new price, not create a separate stop for that new entry alone. This would be true unless you give individual entries signal names and link them to their exit via that signal name.

            I'm attaching my example strategy below.

            Information regarding using Signal names to link orders can be found on this page of our help guide:



            Please let us know if we may be of further assistance to you.
            Attached Files
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              I am attaching images of the chart showing one of the occurences. The Entry bar falls and closes below the stop target and doesnt stop out until later when the price moves back above and then back down.

              Ive also attached the 3 Sets I was testing.

              I have also double checked and verified that my settings are OnEachTick and not OnBarClose.

              Thanks,
              Dave
              Attached Files

              Comment


                #8
                Hello DavidParkins,

                Thank you for your reply.

                So I may best attempt to replicate, on what date did the orders shown in the first screenshot occur? What time zone are you in?

                I note you have 2 sets of exits that appear to do almost the same thing, other than one submitting an MIT and the other submitting an exit long stop market order. Is this intentional?

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

                Comment


                  #9
                  One exit is a stop loss and the other is a take profit.

                  I ran this on friday the 21st. The occurrence took place on Wednesday I believe. I am central us time zone. Chicago.

                  Comment


                    #10
                    Hello DavidParkins,

                    Thank you for your reply.

                    I apologize for the delay in response, we had an issue yesterday where we weren't getting alerted to new forum posts.

                    To further clarify, was this run on historical data on a chart, or on Market Replay data using the Playback connection? Keep in mind that on Historical data, the only datapoints known are the OHLC of a bar. Due to this, on historical data the strategy can only run On Bar Close, so if the strategy is usually running OnEachTick, you're going to get very different results than you would in a test using Market Replay data (which plays back tick by tick as the live market would have) or in real time on a chart.

                    If you were using historical data on the chart, do you see the same when testing over the same time period using Market Replay data?

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

                    Comment


                      #11
                      Hello,

                      I haven't ran this on market replay. I have run it real time with a simulation account and gotten the same result.
                      When running it through the strategy analyzer, I use the drop down menu to see trades and filter the biggest losses to the top. Then review them from there.
                      I understand that historical data is less accurate, however, there are several trades that execute at midpoints in the bar. But never on the same bar as entry.

                      I am currently running it real time on a simulation account. I will update you with pictures if it happens real time again.

                      Thanks for your time.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by The_Sec, Yesterday, 03:37 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by vecnopus, Today, 06:15 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post vecnopus  
                      Started by Aviram Y, Today, 05:29 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post Aviram Y  
                      Started by quantismo, 04-17-2024, 05:13 PM
                      3 responses
                      27 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by ScottWalsh, 04-16-2024, 04:29 PM
                      7 responses
                      36 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Working...
                      X