Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1113
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
Greetings. I've watched the competent video "From MQL4 to MQL5 - how to rewrite EAs for Metatrader 5".
Many thanks to the author. I have decided to try it myself. I decided to try it myself. The idea is as follows:
1. I set dtriger = 1 in the inputs - Buy opens.
2. I set dtriger = -1 - Sell opens.
3. I set dtriger = 0 - all open ones are closed.
I read in the MT5 manuals that it is not possible to hold opposite positions,
and I have them.
Question: How can I correctly prescribe the closing of an open position
The question is: How to correctly register the closure of an existing position at opening a reverse one?
Many thanks.
Greetings. I have watched the helpful clip "From MQL4 to MQL5 - how to rewrite EAs for Metatrader 5".
I would like to congratulate the author. I have decided to try it myself. I wrote it. My idea is the following:
1. I set dtriger = 1 - opens Buy.
2. I set dtriger = -1 - Sell opens.
3. I set dtriger = 0 - all open ones are closed.
I read in the MT5 manuals that it is not possible to hold opposite positions,
and I have them.
Question: how to correctly prescribe the closing of an existing position
The question is: How to correctly register the closure of an existing position at opening a reverse one?
Many thanks.
You must have been very inattentive when reading the fact sheet.
Reference:General principles - Trading operations.
Bottom line: MetaTrader 5 has bothNetting and Hedgingsystems .
I would formulate your task differently:
1. dtriger = 1 - Buy opens.
2. dtriger = -1 - Sell opens.
3. dtriger = 0 - all open ones are closed.
The Expert Advisor should do the following:
Two algorithms are needed for implementation (the magic number also contributes here) - it can be disabled.
и
The general idea is to loop around all positions fromPositionsTotal()-1 to 0. It's from PositionsTotal()-1 to 0, not from zero to PositionsTotal()-1. This is important.
Also a word of advice: when working in MetaTrader 5, an order is a REMOVED ORDER. Therefore it is highly recommended that you do not even remember the word "order" at this initial stage, so as not to create confusion in your mind.
There are also market orders Buy and Sell, as well as CloseBy orders.
Thank you very much, just like music.
Thank you very much, just like music.
Well, if you would be so kind, more then.
I've put in the entries and prescribed a pre-close, but again the orders are hanging there and there.
Well, if you would be so kind, more then.
I have inserted the entries and prescribed a pre-close, but again there are hanging orders here and there.
Thank you very much, just like the notes.
What is the signal to open? Because the code is not complete - only closing positions, but I also need to open positions...
Trade command.mq5
#property version "1.000"
So far it only performs three actions: