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

 
Youri Lazurenko:

Basically I haven't posted all the code, but only a part of finding the take profit of the order with the highest lot. The whole point is as follows - when the price reverses, a pending order with a bigger lot is placed. If it works, a stop loss is set on the opposite order so that when the order with big lot is closed at Take Profit, the order with negative profit at stop loss is also closed. The full code of modification with stop loss setting looks like this

P.S. During testing, there are so many nuances that need to be "explained" to the Expert Advisor as to how it should behave in certain cases.

I mean that you should not make unnecessary changes if you already know that something does not suit you. Sometimes it is better to interrupt execution of a function by calling return.
P.S. This is just something to think about.

 

Hello. what is error 130 when opening orders. Please advise how to get around it.

2019.02.06 17:12:38.643 2019.01.31 01:36:43 pulse GBPCHF,H1: Error opening SELL order : 130


 
Youri Lazurenko:

Basically I haven't posted all the code, but only a part of finding the take profit of the order with the highest lot. The whole point is as follows - when the price reverses, a pending order with a bigger lot is placed. If it works, a stop loss is set on the opposite order so that when the order with big lot is closed at Take Profit, the order with negative profit at stop loss is also closed. The full code of modifications with stop loss setting looks like this

P.S. In the process of testing, there are so many nuances that need to be "explained" to the Expert Advisor how to act in this or that case.

It will be much more effective to close a loss-making order programmatically when the take profit order closes. In my practice, there have been cases when a loss order was closed earlier and the price changed and moved away from the take profit order which overlapped it.

The opposite can be done, at the moment of closing a losing order using a stop, we can programmatically close a profitable one.

 
Георгий Ковальчук:

Hello. what is error 130 when opening orders. Please advise how to get around it.

2019.02.06 17:12:38.643 2019.01.31 01:36:43 pulse GBPCHF,H1: Error opening SELL order : 130


There is documentation on the website. There is also it in the editor's help. There is a search on the website which gives the first result.
Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений
Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений
  • www.mql5.com
Константы, перечисления и структуры / Коды ошибок и предупреждений - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:
There is documentation on the website. There is also one in the editor's help. There is a search on the website, which gives the first result.

This search returns error codes for a five and the question is for a four.

130

ERR_INVALID_STOPS

Incorrect stops

 
Youri Lazurenko:

If it is triggered, a stop loss is placed on the opposite order, so that when the order with a larger lot is closed at take profit, the order with a negative stop loss is also closed.

If I understand correctly, this is a risky manoeuvre: for opposite orders there are different triggering prices (Bid/Ask). There is a risk that one will close, and the other will remain in the market. Although the difference is only on the spread, it happens that the price touches on the reversal.

 
Alexey Viktorov:

It will be much more effective to close a loss-making order programmatically when the overlapping order will be closed at take value. In my practice, there have been cases when a loss-making order was closed, but it ALWAYS closed earlier and the price reversed and moved away from the take profit order, which overlapped it.

It is also possible to close a profit order at the moment of closing a loss-making one using a stop, as well as to close a profit order using a programmatic approach.

I will reply to you andIgor Zakharov at the same time.

I believe it is more risky to close programmatically - at the moment when you can close by breakeven, there may be no internet, connection, or light. With TP and SL set in advance, the above reasons are not significant.

"Ifyou set TP and SL at the same price, yes. If we set a SL taking into account the spread - TP+spread for buying, TP-spread for selling (due to the difference in closingBid/Ask), all orders will close at once (no problems with that yet).

 
Igor Zakharov:

This search returns error codes for a five and the question is for a four.

130

ERR_INVALID_STOPS

Incorrect stops

The editor has the same help. I wrote it. You didn't see it?
 
Artyom Trishkin:
And the editor has the same help. I wrote. You didn't see it?

I clicked on the link you gave, hoping to see a "first result" answer :) Of course, it wasn't there - the four had gone underground.

And yes, my bad - I didn't see about the editor's help :(

 
Igor Zakharov:

I clicked on the link you gave, hoping to see a "first result" answer :) Of course, it wasn't there - the four had gone underground.

And yes, my bad - I didn't see about the editor's reference :(

Type mql4.com in the address bar. What do you get?
Reason: