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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X