Download MetaTrader 5
To add comments, please log in or register
1000 paid orders are executed in Freelance service. Sign up!
Pierre Rougier
386
Pierre Rougier 2014.10.25 17:32 
hello, 

Are there a difference between Bars and rates_total? 

Are there a difference between IndicatorCounted () and prev_calculated?

 

//+------------------------------------------------------------------+
//|                                                   Difference.mq4 |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
//---- plot Line

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {

//----
   Print("*********************************************************");
   Print("****************  IndicatorCounted() ********************");
   Print("*********************************************************");
   Print("Symbol() :",Symbol(),"   Period() :",Period());
   Print("time[0] = ",TimeToString(time[0],TIME_DATE)," time[rates_total-1] = ",TimeToString(time[rates_total-1],TIME_DATE));
   Print("Bars :",Bars,"  rates_total :",rates_total);
   Print("IndicatorCounted():",IndicatorCounted(),"  prev_calculated:",prev_calculated);

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

 

Carl Schreiber
5960
Carl Schreiber 2014.10.25 18:02  
As far as I think IndicatorCounted() is only the old version (before b600+) and the the other one the new way.
Keith Watford
Moderator
7990
Keith Watford 2014.10.27 05:10  
gooly:
As far as I think IndicatorCounted() is only the old version (before b600+) and the the other one the new way.

But don't forget that IndicatorCounted is the actual counted -1 to allow for recounting the last bar. (except when it =0)

Whereas prev_counted is the true amount.

/
To add comments, please log in or register