Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 112
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
Can I see the code?
extern string SYMBOLS ="EURUSD,GBPUSD,EURGBP,EURJPY,USDJPY";
string symbolsArray[1];
...
void init(){
StringToArray(SYMBOLS, symbolsArray);
...
}
int start(){
Comment(symbolsArray[0]+"|"+symbolsArray[1]+"|"+symbolsArray[2]+"|"+symbolsArray[3]+"|"+symbolsArray[4]);
//при запуске советника комментарий выводит правильную информацию, но через время один из элементов массива становится равным совсем другому значению
...
return(0);
}
void StringToArray (string stringOfSymbols, string &arrayOfSymbols[]){
...//функция заносит в массив названия торговых инструментов, здесь ошибок нету (проверено)
}
extern string SYMBOLS ="EURUSD,GBPUSD,EURGBP,EURJPY,USDJPY";
string symbolsArray[1];
...
void init(){
StringToArray(SYMBOLS, symbolsArray);
...
}
int start(){
Comment(symbolsArray[0]+"|"+symbolsArray[1]+"|"+symbolsArray[2]+"|"+symbolsArray[3]+"|"+symbolsArray[4]);
//при запуске советника комментарий выводит правильную информацию, но через время один из элементов массива становится равным совсем другому значению
...
return(0);
}
void StringToArray (string stringOfSymbols, string &arrayOfSymbols[]){
...//функция заносит в массив названия торговых инструментов, здесь ошибок нету (проверено)
}
The first thing I would do is add #property strict, correct any errors/warnings (if any) and replace init() and start() with OnInit() and OnTick().
Got 5 errors and 83 warnings ))))
Thank you!
5 errors and 83 warnings came out ))))
Try to write in a "new" language and there will be fewer hard-to-find mistakes.
start() // Специальная функция start()
{
while(!IsStopped()) // До тех пор, пока пользователь..
{ // ..не прекратит исполнение программы
RefreshRates(); // Обновление данных
//......................Здесь указывается основной код программы
Sleep(5); // Небольшая пауза
}
return; // Управление возвращается терминалу
}
//--------------------------------------------------------------------
I came across such a construction in the MQL4 tutorial:
start() // Специальная функция start()
{
while(!IsStopped()) // До тех пор, пока пользователь..
{ // ..не прекратит исполнение программы
RefreshRates(); // Обновление данных
//......................Здесь указывается основной код программы
Sleep(5); // Небольшая пауза
}
return; // Управление возвращается терминалу
}
//--------------------------------------------------------------------
Is it in the script or in the expert?
in the examiner.
Um... then it depends on what's going on in the main code. If sending an order is bad!
Yes, the order is being sent. It is not clear to me if the quotes should be updated forcibly in case the EA is launched in the window of one symbol but sends an order for another symbol. If, for example, the quotes for EURUSD are not updated, and at the same time, the new quotes for GBPUSD are received. And if my Expert Advisor is run on EURUSD, and I don't performRefreshRates(), then the Expert Advisor will not send an order on GBPUSD, until the quotes on EURUSD are updated?
There are several ways to get current prices:
1. For any symbol: if you want to get guaranteed current prices, call SymbolInfoDouble() with the correct identifiers before using them.
2. For the current symbol, you can also get the current prices through the predefined variables Bid and Ask. These can get out of date, so if the OnTick() function is running for a long time, you should refresh them using RefreshRates().