I've a global variable defined like this:
Then I've a function in my EA defined as follows.
// fill array with bar information to use in functions
CopyRates(Symbol(), PERIOD_CURRENT, 0,10, ga_rates);
Now I would like to use the variable ga_rates in the section onTick().
// only execute if bar is new
if (lv_isNewBar == true)
Print("D", "001", ga_rates.open);
Print("D", "002", ga_rates.close);
Print("D", "003", ga_rates.high);
Print("D", "004", ga_rates.low);
I do expect, that I receive 4 different values, but I only get one. It's always the open-value.
Anybody an idea?
Thanks for any help in advance.
It's easy, you're calling getBarInfo() when new bar shows up so naturaly you only got the first price of that bar which is the open.
When the first bar arrives Open=Close=High=Low, then they will all change except the open, of course.
Try geting the previous bar rates, ga_rates.open; ga_rates.close,... You will get all 4 prices correctly, or, remove the new_bar function.
Hope it helps, regards
Thank you! Problem solved.