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

 
Added ports to the firewall, rebooted the computer, reinstalled terminals, of course
 
Roman Sharanov:
I added ports to the firewall, rebooted the computer, reinstalled the terminals, of course

I've got a ForexFoyu broker working.

 
Seric29:

Everything works for me forexFoyou broker.

So it's just me, even from my phone it works

 
Igor Makanu:

First you check orders through OrderSelect() as it should be - control the symbol and the order master number, and then you close the order in OrderCloseX() and search through the orders again, but for some reason you do not control the symbol and the master number in OrderSelect()

I think we should add OrderCloseX() in order not to rewrite all the code:

Once again to my question from yesterday. You turned out to be 100% right. There is already a confirmation today, everything works correctly now. Thank you once again. I somehow missed it and didn't pay attention.

 
Roman Sharanov:

So it's just me, even from my phone it works.

I'll tell you the truth, it happens.

 

Good afternoon, I am a newbie, help convert this to code:

-cross bars backwards, find the closest cross of 2 MAs and a touch from a fast MA
- go to the last order in the history, if it was opened before the crossover, then we may open a new one

 
Artyom Trishkin:


   double Low3 = 0;
   int Index = 0;
   Low3 = GetPatt5barsDN(Index);
   Index = (int)GetPatt5barsDN(Index); 
   Print("Low3= ", Low3);
   Print("Index= ", Index);
If wrong, please write the correct code.
I'll figure it out and figure out what my mistakes were!
Please don't forget that I'm new to programming :-(
Thank you.
 
Sfinks35:
If wrong, please write the correct code.
I'll figure it out and figure out what my mistakes were!
Please don't forget that I'm new to programming :-(
Thank you.
What do you pass it into function for? What happens to it inside the function?
 
Artyom Trishkin:
Index what do you pass it into the function for? What happens to it inside the function?
Inside the function, index is needed to refer to the address parameter that is specified in the call. And changes to index will affect the value of Index outside the function.
 
Sfinks35:
Inside the function index is needed to refer to the parameter-address that is specified in the call. And changes to the index will affect the value of the index outside the function.

Index is a variable that you pass to a function by reference. It then changes its value in the function itself. Why do you rewrite it by calling a function and putting a double-value in the int-variable? There is no need to do this.

You should start with programming basics.

Документация по MQL5: Основы языка / Функции / Передача параметров
Документация по MQL5: Основы языка / Функции / Передача параметров
  • www.mql5.com
Существует два метода, с помощью которых машинный язык может передавать аргумент подпрограмме (функции). Первый способ – передача параметра по значению. Этот метод копирует значение аргумента в формальный параметр функции. Поэтому любые изменения этого параметра внутри функции не имеют никакого влияния на соответствующий аргумент вызова...