meikel:
you declare count 2 times
in global before init and in init.
though the "count" in init is a local variable only avaiable in init and cannot be accessed in start
Thank you... has helped explain a lot!
int count = iBars(NULL,TF);
//-----
count=iBars(NUll,TF);

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi... am a new learner of MQL4. I just wanted an alert on the number of bars in a chart. Please refer the code below. The problem is that after execution of the special function init, when start() starts, the global variable "count" shows a value of 0. What am I doing wrong here?
int TF=1;int count;
int init()
{
//----
int count = iBars(NULL,TF);
Alert("Bar count for symbol ",Symbol()," is ",count);
//----
return;
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (count != iBars(NULL,TF))
{
Alert("Bar count for symbol ",Symbol()," in Time frame ",TF, " is ",count);
count=iBars(NULL,TF);
}
//----
return;
}
//+------------------------------------------------------------------+