Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange behavior - different results using the same timeframe

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

    Strange behavior - different results using the same timeframe

    I have a simple demo strategy running on M1 timeframe (set in GUI).
    It has added one additional M1 dataseries with Add(PeriodType.Minute, 1);

    Now the problem - I get 2 different backtest results when running on the same
    M1 dataseries. (First M1 dataseries is set from GUI, the second is added manually.
    When running backtest, I am filtering the default one, or the second added. In both cases, the backtest result are different).


    - when I run it on default M1 series (set in GUI) - filtered with
    Code:
     if (BarsInProgress [B][COLOR=Red]== 1[/COLOR][/B]){ return; }
    - when I the same strategy filtered with
    Code:
     if (BarsInProgress [B][COLOR=Red]== 0[/COLOR][/B]){ return; }
    In both cases - strategy uses M1 timeframe.
    How it is possible, that the backtest results are in both cases different?


    To reproduce it, just try to run this trivial demo strategy on M1 timeframe:
    (File also in attachment)

    Code:
            protected override void Initialize()
            {
                Add(PeriodType.Minute, 1);
                
                SetProfitTarget("", CalculationMode.Ticks, 1);
                SetStopLoss("", CalculationMode.Ticks, 10, false);            
                CalculateOnBarClose = false;
            }
    
    
            protected override void OnBarUpdate()
            {            
                [SIZE=2][COLOR=Red][I]//HERE JUST REPLACE 0/1 for switchi[SIZE=2]ng between CHART [SIZE=2][SIZE=2]vs ADDED [/SIZE][/SIZE][/SIZE]data series. [SIZE=2]
    [/SIZE][/I][/COLOR][/SIZE][SIZE=2][COLOR=Red][I][SIZE=2]            //Both are M1, so the result should be the same.[/SIZE][/I][/COLOR][/SIZE]
                if (BarsInProgress != [B][COLOR=Red]0[/COLOR][/B]){ return; }
                
                //just some demo trade
                if (Close[0] > Close[1])
                {
                    EnterShortLimit(Close[0]);
                }
                
            }
    Attached Files
    Last edited by misova; 03-13-2013, 06:41 PM.

    #2
    Welcome to our forums - this would be expected, since the Set()'s are only evaluated according to the primary series - so this will cause a difference in trade groupings as you had seen if you'd worked the same series from BIP1 unfortunately.

    Comment


      #3
      Bertrand, thank you very much for your response.

      I try to undestand, but I am not sure, how this works:
      • Primary series is M1.
      • Secondary series is also M1.

      Are these dataseries any way different, or they are exactly the same?

      Is there any difference in calling onBarUpdate() method?


      In Strategy Analyzer - both dataseries should onUpdateBar() in the same moment (first primary, then secondary) and and their bars values should be also the same.
      Am I right? So what exactly here, caused the backtests difference?

      I try to understand, but the "trade grouping" is very abstract for me. I try to google about this, but found nothing.
      Could you please more elaborate about the trade groupings in which case can this factor create totally different backtest results?

      Thanks
      Last edited by misova; 03-14-2013, 02:20 PM.

      Comment


        #4
        misova, both series would be the same, but not their processing in the script you setup as the Set methods (for your stops and targets) are always only evaluated / processing by NT internally on the primary series and this would be your BarsInProgress 0, so updating first. This leads in your example to a different grouping of trades and our suggestion would be always submitting to the primary series if you're working with identical series. For more control and for allowing stops and targets as well to be submitted to non primary series, use the Exit methods that would allow for a BarsInProgress parameter to designate which one to submit against.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        20 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        18 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        9 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        40 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X