Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting scewed results

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

    Backtesting scewed results

    I'm backtesting a forex strategy based on a 30-min interval. I have set a fixed number of ticks as a profit target and enter a position through a limit order.

    The problem is that when backtesting, NT will enter the order at my price but it will think the profit target is hit, even though in reality it is not.

    The reason is that for example a 30-min bar will be 25 ticks from high to low (let's say EURUSD 1.1550 - 1.1525). Let's say I enter the bar short at 1.1540 and have a 5 pip profit target at 1.1535. When backtesting the strategy thinks my profit target is hit because the entry and profit level falls within the bar high-low. But in reality I have seen that this might often not be the case because what if the price was 27 minutes below my entry price, then at minute 28 my entry was hit and the final 2 minutes of the bar it stayed above my short level and closed at 1.1550.

    In reality the profit level was never hit, even though the backtest thinks it has.

    This is understandable because I don't have tick data, but even based on the 1-min data that I do have it should have been simulated that the profit level was never touched AFTER i entered my entry.

    What can I do?

    UPDATE: I'm trying to access Josh's post but that doesn't seem to work.. http://www.ninjatrader-support.com/v...ead.php?t=6652
    Last edited by siroki; 05-02-2016, 02:03 PM.

    #2
    Hello siroki,

    Thank you for your post.

    You can use the Exit methods and submit to a smaller bar series for intra-bar granularity simulation. This would allow for a simulation of fills intra-bar.
    We have an example at the following link that uses 1 Tick data: http://ninjatrader.com/support/forum...ead.php?t=6652

    Comment


      #3
      Ok I get it, unfortunately it doesn't work.

      I added a secondary timeseries in the Initialize() part, I put the BarsInProgress == 0 inside the OnBarUpdate and finally I submitted the EnterLongLimit() to the first added bar (EnterLongLimit(1,.....))

      Now when I backtest I get no trades at all.

      I backtest this on the 60 minute interval.

      Code:
      protected override void Initialize()
              {
                  CalculateOnBarClose = true;
      			ExitOnClose = true;
      			
      			SetProfitTarget("EnterLongLimit", CalculationMode.Ticks, 5);
      
      			Add(PeriodType.Minute, 1);
      		}
      
              protected override void OnBarUpdate()
              {
      			if(BarsInProgress == 0) {
      
      				if(	   <Conditions.....>
      					) {
      						EnterLongLimit(1, false, 100, <some level>, "EnterLongLimit");
      Last edited by siroki; 05-02-2016, 02:15 PM.

      Comment


        #4
        Hello siroki,

        Thank you for your response.

        You would need to use an Exit method that is sent to the secondary series. SetProfitTarget, SetStopLoss, and SetTrailStop only work off of the primary series for the instrument historically.

        So you would remove the SetProfitTarget and use ExitLongLimit() for example.

        Comment


          #5
          Ah it seems I got it working now.

          I sent the entry methods to the primary bar and sent the exit methods to the granular bar (in my case the 1min).

          That seems to work.

          Thanks!
          Last edited by siroki; 05-02-2016, 02:38 PM.

          Comment


            #6
            Submit your entry to the primary series:
            Code:
            EnterLongLimit([B]0[/B], false, 100, <some level>, "EnterLongLimit");
            If you do not see exits after doing this and the Exit method is sent to the secondary series you would need to verify you have Minute data for this date in the Historical Data Manager (Tools > Historical Data Manager > Edit): http://ninjatrader.com/support/helpG...t7/editing.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by arvidvanstaey, Today, 02:19 PM
            4 responses
            11 views
            0 likes
            Last Post arvidvanstaey  
            Started by samish18, 04-17-2024, 08:57 AM
            16 responses
            60 views
            0 likes
            Last Post samish18  
            Started by jordanq2, Today, 03:10 PM
            2 responses
            9 views
            0 likes
            Last Post jordanq2  
            Started by traderqz, Today, 12:06 AM
            10 responses
            18 views
            0 likes
            Last Post traderqz  
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            47 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X