Why compile error "IndicatorCounted()" ?

 

I just switched to MT5.

#property indicator_chart_window
#property indicator_buffers  0
#property indicator_plots    0

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int counted_bars = IndicatorCounted();
   Print("Counted Bars: ", counted_bars);
   return(rates_total);
  }

'IndicatorCounted' - undeclared identifier    TestMT5.mq5    22    23

')' - expression expected    TestMT5.mq5    22    40

What commands are required in MT5?

 
sorasit:

just switched to MT5.

'IndicatorCounted' - undeclared identifier    TestMT5.mq5    22    23

')' - expression expected    TestMT5.mq5    22    40

What commands are required in MT5?

In MT5, IndicatorCounted() is not used — it's from MT4.

Instead, use the prev_calculated parameter to know how many bars were previously processed.

Simple version:

mql5
int counted_bars = prev_calculated;

No need for IndicatorCounted() in MT5.

I hope i could help you! Best Regards

 
Arda Kaya #:

In MT5, IndicatorCounted() is not used — it's from MT4.

Instead, use the prev_calculated parameter to know how many bars were previously processed.

Simple version:

mql5
int counted_bars = prev_calculated;

No need for IndicatorCounted() in MT5.

I hope i could help you! Best Regards

Thank you for your kindness.