Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Backtesting problem with GetBars

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

    Strategy Backtesting problem with GetBars

    Hello everybody,
    I noticed a very strange behavior of the getbars function during the backtest, (in reality it works very well)​
    this is my function

    protected double ValoreMassimoRange()
    {
    double MassimoRange = 0;
    try
    {

    if (Time[0].TimeOfDay >= Calcolo_Range_Fino.TimeOfDay)
    {
    WriteToFile("Start date " + Calcolo_Range_Da.TimeOfDay.ToString(), @"C:\temp" + Instrument.FullName + ".log");
    WriteToFile("End date " + Calcolo_Range_Fino.TimeOfDay.ToString(), @"C:\temp" + Instrument.FullName + ".log");
    int BarraInizio = Bars.GetBar(Calcolo_Range_Da);
    WriteToFile("Index Start " + BarraInizio.ToString(), @"C:\temp" + Instrument.FullName + ".log");
    int BarraFine = Bars.GetBar(Calcolo_Range_Fino);
    WriteToFile("Index End " + BarraFine.ToString(), @"C:\temp" + Instrument.FullName + ".log");
    int barrafine = CurrentBar - BarraFine;
    int barrainizio = CurrentBar - BarraInizio;
    int barre = BarraFine - BarraInizio + 1;
    MassimoRange = MAX(High, barre)[barrafine];
    }

    }
    catch (Exception e)
    {
    return MassimoRange;
    }
    return MassimoRange;
    }​

    The problem is that StartBar and EndBar i got always the same index

    This is a part of log result of WriteToFile:

    Start date 15:30:00
    End date 15:45:00
    Index Start 1308 (int BarraInizio = Bars.GetBar(Calcolo_Range_Da)
    Index End 1308​ (int BarraFine = Bars.GetBar(Calcolo_Range_Fino)


    Could you help me to find a solution?

    Best regards

    #2
    Hello termi_80,

    Bars represents the primary series, this could relate to the series used. What series is the primary?

    Comment


      #3
      I solved the problem, thanks the same

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      53 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X