Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest problems/error StopLoss

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

    Backtest problems/error StopLoss

    Hi,
    I encountered another problem. The StopLoss execute prices appear to depend on the mainchart time-period. Simulated or not makes no difference.
    If I handle exits manually, all results are the same (as it should).

    See Image

    See attached strategy for FDAX, optimize on dataseries (1 to 5 minutes, step1)
    Attached Files

    #2
    mart331, yes this would be expected for the Set() methods - if you need to tie Exits them to a specific bars index, please use the Exit() methods offering a dedicated overload for this approach then.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      mart331, yes this would be expected for the Set() methods - if you need to tie Exits them to a specific bars index, please use the Exit() methods offering a dedicated overload for this approach then.
      I dont understand.
      You say: the StopLoss method doesnot execute on the stoploss exitprice given???

      So if I program: SetStopLoss(20 ticks)
      it does NOT necesarily execute an exit if the loss is 20 ticks??

      Comment


        #4
        I guess I'm then not sure I follow your issue - a stop of 20 ticks is a stop of ticks, however with stop market orders you could see slippage, which is expected for this order type. For debugging your order behavior please work with the TraceOrders feature -



        Thanks

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          I guess I'm then not sure I follow your issue - a stop of 20 ticks is a stop of ticks, however with stop market orders you could see slippage, which is expected for this order type. For debugging your order behavior please work with the TraceOrders feature -



          Thanks
          Well, it does not! That is not caused by slippage!
          see samplecode. Only difference is mainchart timeframe.
          Not the timeframes traded on.

          In BACKTEST, this gives (very) different results with different mainchart timeframes
          if ( BarsInProgress== SecondsBarIndex )
          {
          if ( EnterFlag ==1)
          {
          EnterFlag =
          0 ;
          if (autoProfit==1)
          {
          SetProfitTarget( CalculationMode.Ticks,
          20 );
          SetStopLoss(
          "Long:n", CalculationMode.Ticks, 20 , true);
          }
          EnterLong(SecondsBarIndex ,
          1, "Long:n");
          }
          elseif (EnterFlag == -1)
          {
          EnterFlag =
          0;
          if (autoProfit==1)
          {
          SetProfitTarget( CalculationMode.Ticks,
          20 );
          SetStopLoss(
          "Short:n", CalculationMode.Ticks, 20 , true);
          }
          EnterShort(SecondsBarIndex ,
          1, "Short:n");
          }
          }
          Last edited by mart331; 11-19-2010, 08:09 AM.

          Comment


            #6
            Mart331, this was exactly my point - you should be executing to your primary series if you're working with the same symbols but different timeframes, otherwise it would be possible that orders are processed twice then.

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Mart331, this was exactly my point - you should be executing to your primary series if you're working with the same symbols but different timeframes, otherwise it would be possible that orders are processed twice then.
              Hi Bertrand,
              Unless I oversee something (I hope I do) this is not the case.

              I tried to enter on
              EnterLong(0,1,"xxx");
              but that is even worse.


              Please tell me how to get in backtest the same results for every mainchart-timeframe,
              because I can't. (that = stoploss right triggered)

              (I posted the sourcecode with first post)

              Why is this so imprtant I think,
              I want to get as much as possible reliable backtest results, but when I see that this (the timeframe) affects the stoploss execution price.... well, than backtest optimize is in my opinion UNreliable.
              Last edited by mart331; 11-19-2010, 09:16 AM.

              Comment


                #8
                When using Set()s in MultiSeries script where the added series are multiples of eachother of the same instrument, you should submit to the primary series only, as the Set() methods would be evaluated on the next primary BIP event then. Also: if you change your primary timeframe, it would for sure change the logic triggered trades, your execution prices received and thus your stop losses as well. Backtests are useful to check if you're edge is worth further exploring at all.

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  When using Set()s in MultiSeries script where the added series are multiples of eachother of the same instrument, you should submit to the primary series only, as the Set() methods would be evaluated on the next primary BIP event then. Also: if you change your primary timeframe, it would for sure change the logic triggered trades, your execution prices received and thus your stop losses as well. Backtests are useful to check if you're edge is worth further exploring at all.
                  Again, the problem is that the Stoploss is NOT triggered at 20 ticks.
                  MY code does nothing at all considering this.

                  Comment


                    #10
                    Please see the attached picture - this is your code on ES 1 min with a tightened stop of 4 ticks, as otherwise it would not trigger at all - to debug your order behavior please work with the TraceOrders feature and simplify as much as is needed to ensure the basics are working as you expect, then add more complex code step by step.

                    Attached Files

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    600 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    346 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    558 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    558 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X