Questions from Beginners MQL5 MT5 MetaTrader 5 - page 363
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I don't think you're asking the question here. Create a separate thread, attach the code of the indicator there and hope someone will help. Without the code... it's unlikely that anyone will help you.
When writing the ToR, I came across a situation where I don't understand how to describe the algorithm correctly. Can you advise on the possibility of partial closing of a position in the EA's work?
When writing the ToR, I came across a situation where I don't understand how to describe the algorithm correctly. Can you tell me whether a partial closing of a position is possible in the work of an EA?
What is so complicated about it? If the position is not evenly split (eg 0.09) then close most of it (0.05) and move the stop to breakeven, then another closing distance and again half of the one left (0.02) and move the stop to the next closing step and keep going up until the whole position is closed or broke even. The step can be fixed or calculated from any range, depends on the trading system.
Do I get it right? The MQL4 programming language allows formalizing the closing of only half of the market order volume... like lot 10 and close 5 lots when price reaches a certain level.
Or is it possible to close 1/3?
Or, it would be easier to implement this idea in an EA by placing different orders. When the price reaches a required level, one order is closed and the other remains in place of the partial closing of the market order volume. What do you think?
To do this, you need to specify a lot smaller than the position's lot in the close order (this is if MT4, in MT5 you can open the opposite position with a smaller lot, and they will overlap in the end). The position with the remaining lot will remain in the market.
Do I get it right? The MQL4 programming language allows formalizing the closing of only half of the market order volume... like lot 10 and close 5 lots when price reaches a certain level.
Or is it possible to close 1/3?
Or, it would be easier to implement this idea in an EA by placing different orders. When the price reaches a required level, one order is closed and the other remains in place of the partial closing of the market order volume. What do you think?
We can do both. OrderClose allows you to close the volume that is indicated to it. https://docs.mql4.com/ru/trading/orderclose
Of course you can open several orders with different profit levels. In case of a connection failure it will be even more reliable, because TP levels are stored on the server and will be executed if the price intersects them.
You can do both. OrderClose allows to close the volume, which is indicated to it. https://docs.mql4.com/ru/trading/orderclose
Of course, you can also open several orders with different profit levels. In case of a connection failure this will be even more reliable, because TP levels are stored on the server and will be executed if the price crosses them.
Hello all, I'm facing a problem, I'd like to hear the opinion of professionals or more experienced MT5 users. I have written an indicator and CEventBase class, which allows the indicator to generate events. When running Expert Advisors that process these events sooner or later, when running in real time, I get errors: 4001, 4102, 4104. When they start to "pile up", they won't stop happening) I attach the code of Generate function, which actually is the source of all these troubles. Would be very glad to hear your opinion...)
Good day to all!
Hello all, I'm facing a problem, I'd like to hear the opinion of professionals or more experienced MT5 users. I have written an indicator and CEventBase class, which allows the indicator to generate events. When running Expert Advisors that process these events sooner or later, when running in real time, I get errors: 4001, 4102, 4104. When they start to "pile up", they don't stop doing it) I attach the code of Generate function, which actually is the source of all these troubles. I'll be very glad to hear your opinion on it ...)
Good day everyone!
Obviously, the method you presented is a transit method. The error is most likely not in it. It is not clear from the data you presented what is going on. There may be several variants:
- Incorrect chart identifier (which is what the 4101 error says).
- Too frequent queries;
- Incorrect other parameters (event IDs for example).
Judging by the level of code you wrote, we can say that the error can be anywhere and anyplace.