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

Comment