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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      167 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      88 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      128 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      208 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X