Download MetaTrader 5

What difference for use Bars and IndicatorCounted ?

To add comments, please log in or register
sorasit
359
sorasit  

How to choose or apply ?



Thank you

Alain Verleyen
Moderator
32026
Alain Verleyen  

Bars : "Number of bars in the current chart."

IndicatorCounted : "The amount of bars not changed after the indicator had been launched last."

whroeder1
15335
whroeder1  
sorasit46: How to choose or apply ?

Look at ANY indicator in the codebase
#define LOOKBACK ma_period // Largest used in loop
int counted = IndicatorCounted();
if(counted < LOOKBACK) counted = LOOKBACK;
for(int iPos = Bars - 1 - counted; iPos >= 0; iPos--){
   buffer[iPos] = iMA( ... ma_period ... iPos); // Lookback==ma_period
   buffer[iPos] = ...  iPos+1);                 // Lookback==1
You use BOTH
sorasit
359
sorasit  
Thank you
To add comments, please log in or register