MqlRates close price for many symbols
bool CTradingEngine31::SearchTradingSignals(void) { MqlRates rates[]; ArraySetAsSeries(rates,true); if(CopyRates(_Symbol, _Period, 0, 3, rates) != 3) { Print("CopyRates of ",_Symbol," failed, no history"); return(false); } if(rates[1].close >whatever) --do something-- }
You are copying rates from the current chart only, Where are your other symbols engaged?
I was expecting something like this
bool CTradingEngine31::SearchTradingSignals(void) { MqlRates rates[]; ArraySetAsSeries(rates,true); for (int i=0; i<ArraySize(Symbols_Array); i++) if(CopyRates(Symbols_Array[i], _Period, 0, 3, rates) != 3) { Print("CopyRates of ",Symbols_Array[i]," failed, no history"); return(false); } if(rates[1].close >whatever) --do something-- }
You are copying rates from the current chart only, Where are your other symbols engaged?
I was expecting something like this
You mean this?
int CTradingEngine31::OnInit(string _TradeSymbol ) { ResetLastError(); if(!m_symbol.Name(_TradeSymbol)) // sets symbol name return(INIT_FAILED); RefreshRates(); -------code------- }So _TradeSymbol should be Symbols_Array?
Hold on! I don't know your entire code, just check your entire copy rates method call to ensure you copy all the symbols in a loop
Raw code without data
Could be, I don't know, I just found empty ea template and trying to fill it with my own data.
This code works well but there I also didn't find anything about copying rates. So my question remains same.
Something similar maybe?
string Tradesymbol[]; MqlRates rates[]; ArraySetAsSeries(rates,true); for (int i=0; i<ArraySize(TradeSymbol); i++) if(CopyRates(TradeSymbol[i], _Period, 0, 3, rates) != 3) { Print("CopyRates of ",TradeSymbol[i]," failed, no history"); return(false); }
I'm using multi symbol ea with classes and need to get close of last bar but through the usual method with MqlRates I get last close only for the 1st pair in list.