Questions from Beginners MQL4 MT4 MetaTrader 4 - page 125

 
novichok2018:

And no error message should be displayed? Probably wouldn't hurt to know why an order is not found and how to avoid it?

In my opinion, it is not necessary. Basically, OrderSelect will only end with an error if the list string index is incorrect. If the index is exactly right, no error will occur. Thus, the OrderSelect error is a programmer error, not a runtime error.

 
Ihor Herasko:

The only MQL4 textbook I know of is Sergei Kovalev's textbook.

I don't know, maybe I don't know how to use the textbook, but I didn't find anything in it about arrays or structures, especially how to use them and for what purpose.

Your code seems to understand everything, but I don't understand how to use it in position analysis.

At the same time I can't seem to solve my situation without arrays. I seem to have used all options - flags, position counters, opening buy and sell using separate functions, as well as closing them. None of them help. As soon as buy opens and sell closes, the terminal does not see conditions for closing until a new sell is opened. If there are no bays during this period, everything works fine. It will be quite frustrating if the arrays don't help.

Anyway, looking forward to any further recommendations from you. Thank you.

22.02 13.00 I think I understood the reason of my situation: to make positions close on my conditions depending on conditions of their opening, I assign each a different magik. But to do this, I first use OrderSelect() after opening a position. So, each position creates a new magic when OrderSelect() is applied and the previous one is destroyed. That is why conditions are searched for by the last magik and if several bars (sells) open by different conditions, they all get closed by the last position opened (it can be seen in the Strategy Tester). So, when a buy position is opened when a sell is opened, it changes its magic number and the terminal cannot find conditions for closing the sell. I found the confirmation of this by prints. Now it remains to find how to avoid such a situation. Who can help?

 
Can anyone help adapt an EA to put on the market. Can't figure out the checks (
 
novichok2018:

I don't know, maybe I don't know how to use the textbook, but I didn't find any word there about arrays or structures, let alone how to use them and what for.

Your code seems to understand everything, but I don't understand how to use it in position analysis.

At the same time I can't seem to solve my situation without arrays. I seem to have used all options - flags, position counters, opening buy and sell using separate functions, as well as closing them. None of them help. As soon as buy opens and sell closes, the terminal does not see conditions for closing until a new sell is opened. If there are no bays during this period, everything works fine. It will be quite frustrating if the arrays don't help.

Anyway, looking forward to any further recommendations from you. Thank you.

This tutorial is ancient, it was written for versions of MT4 < 600, i.e. for old MQL4, it had no structures. Arrays were.

 
Alexey Volchanskiy:

The tutorial is ancient, written for versions of MT4 < 600, i.e. for old MQL4, there were no structures in it. There were arrays.

The Help also contains arrays, but what is the use: it is not clear how to use created arrays to close/open positions.

 
novichok2018:

There are arrays in the help too, but what's the use: how to use the created arrays to close/open positions is not clear.

))))))))) makes me laugh. Why do you need arrays to open/close positions?

 
Alexey Volchanskiy:

))))))))) made me laugh. Why do you need arrays to open/close?

If there is a series of trades, and for each step there are different parameters - lot/sl/tp/distance, then it's easier to go through them all in an array

 
Taras Slobodyanik:

If there is a series of trades, and for each step there are different parameters lot/sl/tp/distance, then it's easier to go through it all in an array

The situation is described in post 1243. Maybe you may be able to help? Thank you.

 

novichok2018:

Who can help?

Logic) Write in words a plan of what the EA should do, in what sequence, under what conditions (flowchart). Writing code will be much easier.

 
Aleksey Lebedev:

Logic) Write a plan in words, what should the Expert Advisor do, in what sequence, for what conditions (flowchart). Writing code will be much easier.

Thank you all. I think I solved the problem myself: I just removed all the magics and applied flags to identify the positions, for each condition different. Simple and effective. And without arrays.

If any of the experts see the pitfalls in this solution, which have not yet manifested themselves - would be very grateful for clarification.