Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1267

 
Good afternoon. Please help me with the code. In practice, it should open trades alternately, i.e. (opened buy - closed buy opened sell - closed sell opened buy).
Files:
snake_x1t.mq4  14 kb
 
ANDREY:

Thanks again for the tip, but ..... in the Reference Manual it says that this function only applies to dynamic arrays. And my code is NOT a dynamic array, but a regular one.

I will be very grateful if you tell me (or, better, show me) how to change the size of a regular array in the first dimension.
Thanks again for your help.

You can't, it's static, because the dimension doesn't change.

Dynamic array, it does not mean that its size must be changed every time. It's just an opportunity to change it if necessary.

 
ANDREY :

Got it, thanks. Is there any way to set the size of the array using a variable?

Try it like this:

 #define  W 1000

 double T_P [ W ] = { 0 };

 void OnTick ()

{

the code

}
 
When the size of the array is increased, do the values in the array remain at the same order of magnitude?
 
Alexey Viktorov:

You can't, it's static because the dimension doesn't change.

Dynamic array does not mean that its size must be changed every time. It just means that you can change it if necessary.

Thank you for your help.

 
Hi all, where is there a tutorial on MT4 programming? For dummies, i.e. from scratch. I found it on MT5 at https://www.mql5.com/ru/articles/100 , but as far as I understood it, because of some differences written for MT5, it simply will not work on MT4. I need it for MT4.
Пошаговое руководство по написанию MQL5-советников для начинающих
Пошаговое руководство по написанию MQL5-советников для начинающих
  • www.mql5.com
Эта статья предназначена для начинающих, для тех, кто хочет научиться написанию простых советников на новом языке MQL5. Сначала мы определимся с тем, что требуется от нашего советника, а затем приступим к написанию того, каким образом он будет это делать. 1. Торговая стратегия Он будет следить за некоторыми индикаторами и при определенном...
 
jaffer wilson:

Try it like this:

Is define a variable?

 

Evening.

Is there a simpler way to determine whether the bar high or low has come first?

Thank you!

 
Сергей Таболин:

Is define a variable?

it is a substitution. That's how it's written and understood. Only (didn't check) declaring an array with simultaneous assignment of the last element ... don't know if it's correct or not.

 
Ontonello:
Hi all, where is there a tutorial on MT4 programming? For dummies, that is completely from scratch. I found it for MT5 at https://www.mql5.com/ru/articles/100 , but as far as I understand it, due to some differences, written for MT5 simply will not work on MT4. I need it for MT4.

Sergei Kovalev's textbook on MQL programming. Look it up, it's easy to find. The only thing there are no additions after 2016, OOP, today's enumerations. But it's okay to start with. What you found is a good article, not a textbook at all.

Reason: