Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parabolic stop jumps to a weird value

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

    Parabolic stop jumps to a weird value

    Before I go long, I setup my Parabolic stop:

    Code:
    SetParabolicStop(LongSignalName, CalculationMode.Ticks, ticks, false, TrailStopAcceleration, TrailStopAccelerationMax, TrailStopAccelerationMax);
    EnterLong(LongSignalName);
    Sometimes it works as expected (blue crosses is the plot of the current stop value):
    Click image for larger version  Name:	Screenshot 2022-09-07 103840.png Views:	0 Size:	14.8 KB ID:	1214651

    But most of the time I get something like this:

    Click image for larger version  Name:	Screenshot 2022-09-07 103800.png Views:	0 Size:	21.2 KB ID:	1214652
    The stop value "jumps" downwards. And as you can see, it is not only the plot. The stop is not executed when it should.
    I triple checked, that I do not send another parabolic stop or something.

    Any ideas?

    Thx,
    Sven
    Last edited by SvenB; 09-07-2022, 03:09 AM.

    #2
    Hello SvenB,

    Thanks for your post.

    To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    Have you added debugging prints to the strategy that prints out each value used for the SetParabolicStop() order to see exactly what value the Parabolic Stop order is submitting to?

    Have you added debugging prints that print out the value of the plot?

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window). Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121

    Once you add debugging prints to the strategy, you could add the Parabolic SAR indicator on the chart using the same parameters as your SetParabolicStop() method or plot and compare the debugging prints and strategy/plot behavior to the indicator on a chart.

    If you have added debugging prints and need assistance with analyzing the output of the prints, please let me know and I will be happy to help.

    Let me know if I may further assist.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,
      yes I did some logging and a lot more debugging while using the Strategy Analyzer.

      That is what the log (snipped)looks like (s. attached file for full log):


      Code:
      31.08.2022 18:11:02 Strategy 'Double7/-1': Entered internal SetStopTarget() method: Type=ParabolicStop FromEntrySignal='Double7 Long' Mode=Ticks Value=25 IsSimulatedStop=False IsMarketIfTouched=False
      31.08.2022 18:11:02 Strategy 'Double7/-1': Entered internal SubmitOrderManaged() method at 31.08.2022 18:11:02: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3988,00 SignalName='Double7 Long' FromEntrySignal=''
      31.08.2022 18:13:47 Strategy 'Double7/-1': Amended parabolic stop order orderId='NT-00001-545' account='Backtest' name='Parabolic stop' orderState=Working instrument='ES 09-22' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=3981.75 quantity=1 tif=Gtc oco='NT-00000-545' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2022-08-31 18:11:02' gtd='2099-12-01' statementDate='2022-09-07' stopPriceChanged=3979,5
      31.08.2022 18:14:46 Strategy 'Double7/-1': Amended parabolic stop order orderId='NT-00001-545' account='Backtest' name='Parabolic stop' orderState=Working instrument='ES 09-22' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=3979.5 quantity=1 tif=Gtc oco='NT-00000-545' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2022-08-31 18:11:02' gtd='2099-12-01' statementDate='2022-09-07' stopPriceChanged=3979,5
      The stop price falls from 3981.75 in line 3 to 3979.5 in line 4.
      Attached Files

      Comment


        #4
        I made a fresh strategy which is pretty simple. If not in market, set parabolic stop and enter long.
        Same effect on the very first trade.

        Code:
        protected override void OnBarUpdate()
        {
           if (BarsInProgress != 0)
           return;
        
           if (CurrentBar < BarsRequiredToTrade) return;
        
           if (Position.MarketPosition != MarketPosition.Flat)
           {
              Pstop[0] = stopValue;
              return;
           }
          SetParabolicStop("SignalLong", CalculationMode.Ticks, 4, false, 0.03, 0.15, 0.01);  
          EnterLong("SignalLong");
        }
        
        
        protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
        {
           //Plotting
           if (order.Name == "Parabolic stop" && order.OrderState == OrderState.Accepted)
           {
              stopValue = order.StopPrice;
              //Print("Stop price: " + order.StopPrice);
            }
        }
        Log (snipped):
        Code:
        31.08.2022 05:35:10 Strategy 'SimpleParaStopTest/-1': Entered internal SetStopTarget() method: Type=ParabolicStop FromEntrySignal='SignalLong' Mode=Ticks Value=4 IsSimulatedStop=False IsMarketIfTouched=False
        31.08.2022 05:35:10 Strategy 'SimpleParaStopTest/-1': Entered internal SubmitOrderManaged() method at 31.08.2022 05:35:10: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SignalLong' FromEntrySignal=''
        31.08.2022 05:50:54 Strategy 'SimpleParaStopTest/-1': Entered internal SetStopTarget() method: Type=ParabolicStop FromEntrySignal='SignalLong' Mode=Ticks Value=4 IsSimulatedStop=False IsMarketIfTouched=False
        31.08.2022 05:50:54 Strategy 'SimpleParaStopTest/-1': Entered internal SubmitOrderManaged() method at 31.08.2022 05:50:54: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SignalLong' FromEntrySignal=''
        31.08.2022 06:42:02 Strategy 'SimpleParaStopTest/-1': Amended parabolic stop order orderId='NT-00003-1183' account='Backtest' name='Parabolic stop' orderState=Working instrument='ES 09-22' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=4008.25 quantity=1 tif=Gtc oco='NT-00002-1183' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2022-08-31 05:50:54' gtd='2099-12-01' statementDate='2022-09-07' stopPriceChanged=3980
        31.08.2022 07:06:33 Strategy 'SimpleParaStopTest/-1': Amended parabolic stop order orderId='NT-00003-1183' account='Backtest' name='Parabolic stop' orderState=Working instrument='ES 09-22' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=3980 quantity=1 tif=Gtc oco='NT-00002-1183' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2022-08-31 05:50:54' gtd='2099-12-01' statementDate='2022-09-07' stopPriceChanged=3980
        Again, stop price falls below the initial value line (5 -> 6).

        This happens not all the time:
        Click image for larger version  Name:	Screenshot 2022-09-07 230251.png Views:	0 Size:	157.8 KB ID:	1214745

        I'm really running out of ideas at the moment.

        Thx,
        Sven
        Last edited by SvenB; 09-07-2022, 03:44 PM. Reason: typo

        Comment


          #5
          Today I ran the exact same backtest with the very simple strategy. Couldn't not find any misbehaving stops.

          How global/local are these signal names used in e.g. EnterLong()? Can they interfere with signals running in another strategy?
          Last edited by SvenB; 09-08-2022, 08:54 AM. Reason: typo

          Comment


            #6
            Ok, here it is again. Same strategy, same data. I don't get it.

            Click image for larger version

Name:	Screenshot 2022-09-07 230251.png
Views:	231
Size:	228.9 KB
ID:	1214809

            Comment


              #7
              I'm getting different results in backtesting depending on if I'm connected or not:

              Connected to Continium:

              Click image for larger version  Name:	Screenshot 2022-09-08 175215.png Views:	0 Size:	497.6 KB ID:	1214815
              Not connected:
              Click image for larger version  Name:	Screenshot 2022-09-08 175129_1png.png Views:	0 Size:	469.2 KB ID:	1214816

              Is that intended behavior?

              Thx,
              Sven
              Last edited by SvenB; 09-08-2022, 10:00 AM. Reason: typo, wording

              Comment


                #8
                Hello SvenB,

                Thanks for that information.

                Please send me a reduced copy of the strategy with the debugging prints included as well as the exact steps and settings used to reproduce the behavior so I may investigate this further.

                Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

                To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.

                To export your strategy, go to Control Center > Tools > Export > NinjaScript AddOn.

                I look forward to further assisting.
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  Hi Brandon,

                  no need to reduce it. As said, it's a dead simple strategy. I have moved the SetParabolicStop to the "Configure" section in the code to make sure there is no race condition between "Position.MarketPosition != MarketPosition.Flat" and my intended dynamic parabolic stop with calculated ticks offset.

                  In the end, with this strategy I send you, I have different results, depending on if I'm connected to live data or not. As shown in post #7.

                  I have used 2000 ticks on ES. But I guess, you can see all information in the Data Box, from the previous screenshots.

                  Please, let me know if you need further information.

                  Thanks for your effort,
                  Sven
                  Attached Files

                  Comment


                    #10
                    Hello SvenB,

                    Thanks for your note.

                    I would need to be able to reproduce this issue on my end to further investigate.

                    Please test running the strategy using the Playback connection and note the exact time that the behavior occurs and the settings used to reproduce the issue.

                    Playback: https://ninjatrader.com/support/help...connection.htm

                    Once you are able to reproduce the issue with Playback, send me the exact steps you take and settings that you use to reproduce this issue so that I can perform an apples-to-apples test on my end to reproduce the behavior

                    Also, include a screenshot of the settings used for Playback (was Market Replay data or Historica data used with Playback, what are the specific Data Series settings used, what time does the behavior occur, etc), and the Strategy settings you use when you enable it so that I can reproduce this on my end.
                    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
                    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.

                    I look forward to assisting further.
                    Last edited by NinjaTrader_BrandonH; 09-08-2022, 01:49 PM.
                    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                    Comment


                      #11
                      Here is a video about what's going on:


                      Comment


                        #12
                        [QUOTE=NinjaTrader_BrandonH;n1214832]
                        Hello SvenB,

                        I would need to be able to reproduce this issue on my end to further investigate.

                        Please test running the strategy using the Playback connection and note the exact time that the behavior occurs and the settings used to reproduce the issue.
                        /QUOTE]

                        You still need this? In mean time I uploaded a video. If so, I will do it. Just let me know.

                        Sven
                        Last edited by SvenB; 09-08-2022, 02:25 PM. Reason: formatting

                        Comment


                          #13
                          Hello SvenB,

                          Thanks for your note.

                          I have imported the strategy you shared and ran a backtest on it in the Strategy Analyzer using the exact settings you used in the video shared in post #11.

                          When testing the strategy, I was not able to reproduce the behavior you are reporting. I ran 3 backtests, 1 test using the same settings you shared in the video, and 2 tests using different Start/End dates. I was not able to reproduce the behavior for any of the 3 tests.


                          Please test running the strategy using the Playback connection and note the exact time that the behavior occurs and the settings used to reproduce the issue.

                          Playback: https://ninjatrader.com/support/help...connection.htm

                          Once you are able to reproduce the issue with Playback, send me the exact steps you take and settings that you use to reproduce this issue so that I can perform an apples-to-apples test on my end to reproduce the behavior

                          Also, include a screenshot of the settings used for Playback (was Market Replay data or Historica data used with Playback, what are the specific Data Series settings used, what time does the behavior occur, etc), and the Strategy settings you use when you enable it so that I can reproduce this on my end.
                          • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
                          • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
                          I look forward to assisting further.
                          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                          Comment


                            #14
                            Hi Brandon,

                            I wasn't able to reproduce the problem with playback connection. I tried market replay and historical data.

                            Weird part is, at the moment I'm not able to reproduce it like shown in the video. Currently everything works as expected.

                            Comment


                              #15
                              Hi Brandon,

                              after playing around with different date ranges I found the problem again. And it's not at the same date as in the video.
                              Then I made a backup of my scripts, uninstalled NT, deleted the Documents folder, re-installed NT and downloaded market/historical data again.

                              After playing around with some date ranges I still have the problem

                              So, to reproduce I think the only way is to play around with the date ranges a bit (I always use 2 or 3 days in 2000 ticks) until the problem occurs.
                              And it is important to be connected to NT Continium! Otherwise, the problem does not occur!

                              Click image for larger version

Name:	Screenshot 2022-09-09 162013.png
Views:	222
Size:	60.4 KB
ID:	1214888

                              Everything else is at default settings, because of the new installation.


                              Last edited by SvenB; 09-09-2022, 08:21 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              59 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              133 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              73 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              50 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X