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

Dynamic Trailing Stop

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

    #16
    This is not on a gap down where this is happening.

    Example during a backtest.....

    1/ prior bar hits high of 13955 & closes at 13942.
    2/ TrailStop updated on bar close (i.e. set to true) & is set to 1 (lowest value I believe that is possible).
    3/ current bar OHLC = 13942, 13947, 13921, 13928.
    4/ trade exits on current bar at 13954.

    so it would appear that stoploss is set to 13955 at the close of the prior bar & then since the price at the next bar open is 13 less than stoploss set point it assumes a 'gap' & therefore exits in midair.

    but why would one in real time get a fill at higher price than the current market price --- I cannot understand this.

    thx DG

    Comment


      #17
      A fill price of 13954 means that the stop price going into the current bar was at at a price higher than the low of the current bar and thus you are filled at your stop price + commission values.

      I realize you say that your stop was changed to a price of 1 but if that was the case, your stop would not have triggered. You can verify this by enabling TraceOrders = true in the Initialize() method and reviewing the Output window.

      The simulator or exchange can fill you at a price higher than the market. Usually does not happen but it can.
      RayNinjaTrader Customer Service

      Comment


        #18
        Ray - thx for your guidance on this.

        The way I see it is that the simulator is always filling me at the stop price (= 1 tick lower than high of prior bar) every time the current bar high is lower than prior bar high & if the trailstop value been set to <= 0.

        I don't think you will agree.......
        but I can send the strategy for you to back test if you wish.

        thx
        David

        Comment


          #19
          Please use the TraceOrders option and check the price of your "sell" stop order at the fill in question. If the price is a value of <= 0, let me know.
          RayNinjaTrader Customer Service

          Comment


            #20
            With TraceOrders, Value = 1 (I presume this is the minimum value, since the trailstop calculation actually takes the value < 0).

            So my prior comment still stands.............The way I see it is that the simulator is always filling me at the stop price (= 1 tick lower than high of prior bar) every time the current bar high is lower than prior bar high & if the trailstop value been set to <= 0 (.........sets itself to value=1).

            Comment


              #21
              Is this a "BUY" or "SELL" stop order?
              RayNinjaTrader Customer Service

              Comment


                #22
                since this is a long strategy, it is a sell stop order to exit. DG

                Comment


                  #23
                  Hi dgregor5,

                  Lets try to get to the root of this problem. Would you mind sending me a simple as possible strategy that displays the issues you are experiencing along with a replay file that highlights the problem? Thank you.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    Josh - sent a strategy via email to support for you to backtest. thx. David

                    Comment


                      #25
                      testing out a similar dynamic trailing stop strategy with simulated real time data feed observed the following:
                      Conditions:
                      1/ CalculateOnBarClose=True.
                      2/ SetTrailStop set in OnBarUpdate section.
                      3/ trail stop value sent to output window at onbarclose.
                      4/ TraceOrders = true in initialise method.

                      Obervations with real time simulated feed:
                      1/ If end of bar trail stop calculation on prior bar leads to stop price > open price of current bar, then trade exits immediately at open price of current bar. this is exactly what I expect.

                      Observations in backtestmode:
                      1/ If end of bar trail stop calculation on prior bar leads to stop price > open price of current bar, then trade exits immediately at stop price ---- hence why certain trades exit in mid-air.

                      Isn't this an issue !!?!?!

                      Again am I being dumb ?!?!?!?

                      thx
                      DG

                      Comment


                        #26
                        No, you are not being dumb. I understand your concern and will see what I can do. Would you mind sending me the things you sent through support to josh [at] ninjatrader [dot] com? Thanks.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #27
                          Josh - have sent the files. thx. DG

                          Comment


                            #28
                            Hi dgregor5,

                            The issue will be fixed for NinjaTrader 6.5. In the meantime you can do this to fix the issue on your NinjaTrader 6.0.1000.5 install.
                            1. Save and overwrite @DefaultFillType.cs at \My Documents\NinjaTrader 6\bin\Custom\Types\
                            2. Open up the NinjaScript Editor on any NinjaScript and hit compile
                            3. The fill algorithm should now be updated and you can see the effect in your backtests
                            Again, thanks for finding and pointing this out.
                            Attached Files
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #29
                              Hey Josh - great turnaround. thx for your assistance. Now works as expected. David

                              Comment


                                #30
                                Josh:
                                I am now seeing similar mid-air exits when using a dynamic profit target (using SetProfitTarget from within OnBarUpdate). This time the mid-air exits are always below where the exit should be........ (n.b. this is a long strategy again)

                                Similar issue ???

                                thx
                                David

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by CortexZenUSA, Today, 12:53 AM
                                0 responses
                                1 view
                                0 likes
                                Last Post CortexZenUSA  
                                Started by CortexZenUSA, Today, 12:46 AM
                                0 responses
                                1 view
                                0 likes
                                Last Post CortexZenUSA  
                                Started by usazencortex, Today, 12:43 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post usazencortex  
                                Started by sidlercom80, 10-28-2023, 08:49 AM
                                168 responses
                                2,266 views
                                0 likes
                                Last Post sidlercom80  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                3 responses
                                13 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Working...
                                X