Errors, bugs, questions - page 1437 1...143014311432143314341435143614371438143914401441144214431444...3193 New comment Ilyas 2015.11.24 15:15 #14361 MathIsValidNumber Документация по MQL5: Математические функции / MathIsValidNumber www.mql5.com Математические функции / MathIsValidNumber - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5 Ilyas 2015.11.24 15:16 #14362 The behaviour is different, due to a more aggressive optimiser for MQL5 code. Ilya Malev 2015.11.24 15:22 #14363 Ilyas: MathIsValidNumber Thank you, I didn't know Ilya Malev 2015.11.24 15:30 #14364 Ilyas: The behaviour is different because of more aggressive optimizer for MQL5 code. Also MT4 was smarter and gave a "integral constant overflow" warning, while MT5 was silent. Slava 2015.11.24 16:35 #14365 Ilya Malev: 1. Why in MT4 and MT5 does this code lead to different results (and more logical in MT4)?Read documentationWhat does EMPTY_VALUE mean in MQL4? Прочие константы - Документация на MQL4 docs.mql4.com Прочие константы - Документация на MQL4 Vladimir Karputov 2015.11.24 17:43 #14366 Сергей Таболин: Can you tell me why the following line (when first accessed) gives an "out of range" error: Declare - declared, but who will fill buffer buf_ldn[ldn]? Dina Paches 2015.11.24 17:59 #14367 Сергей Таболин: Look at the values of pr_open and pr_close the first time they are accessed. Vladimir Pastushak 2015.11.24 17:59 #14368 Сергей Таболин: that's the fill-in, isn't it?Or am I missing something?You declared an array but didn't specify an array size...Static exampleint buf_lup[1000], buf_ldn[20000]; Maxim Khrolenko 2015.11.24 18:02 #14369 Сергей Таболин: that's the fill-in, isn't it?Or am I missing something? No, it's not an array fill. Besides, if ldn = 0;, by putting 0 into [ ] you've declared 0 elements in the array, i.e. there's not even one element there. Read the article Arrays in MQL5: Fundamentals of MQL5 Programming. Any rookie question, so static array ? OnDeinit in indicators Vladimir Karputov 2015.11.24 18:05 #14370 Сергей Таболин: that's the fill-in, isn't it?Or am I missing something?You have to set the size of the array before you fill it. (ArrayRezise). A simple example://+------------------------------------------------------------------+ //| Test.mq5 | //| Copyright © 2015, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.00" #property script_show_inputs input bool show_error=true; // true - выполнить с ишибкой //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { int buf_ldn[]; // объявили динамический массив. Print("Размер массива buf_ldn[]=",ArraySize(buf_ldn)); // выведем на печать размер массива if(show_error) { //--- попытка присвоить значение элементу массива с индексом "0" вызовет ошибку: //--- Test (EURUSD,M15) array out of range in 'Test.mq5' (22,14) buf_ldn[0]=1; } else { //--- установим новый размер массива: ArrayResize(buf_ldn,1); //--- попытка присвоить значение элементу массива с индексом "0" НЕ вызовет ошибку: buf_ldn[0]=1; //--- выведем на печать размер массива и значение элемента с индексом "0" Print("Размер массива buf_ldn[]=",ArraySize(buf_ldn),", элемент с индексом ""0"" имеет значение:",buf_ldn[0]); } } //+------------------------------------------------------------------+ Files: Test.mq5 2 kb 1...143014311432143314341435143614371438143914401441144214431444...3193 New comment
MathIsValidNumber
The behaviour is different because of more aggressive optimizer for MQL5 code.
1. Why in MT4 and MT5 does this code lead to different results (and more logical in MT4)?
Read documentation
What does EMPTY_VALUE mean in MQL4?
Can you tell me why the following line (when first accessed) gives an "out of range" error:
that's the fill-in, isn't it?
Or am I missing something?
You declared an array but didn't specify an array size...
Static exampleint buf_lup[1000], buf_ldn[20000];
that's the fill-in, isn't it?
Or am I missing something?
that's the fill-in, isn't it?
Or am I missing something?
You have to set the size of the array before you fill it. (ArrayRezise). A simple example: