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
Sorry, I didn't understand exactly what you meant. I thought that you meant to change the magic number directly before closing an already open position (that already has a magic number). In my opinion it's not possible to change a magic number of an open position.
Of course I set a magic number corresponding to the strategy before I open the position. This is essential to my EA:
Could this be a bug in MT5 / OnTradeTransaction?
Sorry, I didn't understand exactly what you meant. I thought that you meant to change the magic number directly before closing an already open position (that already has a magic number). In my opinion it's not possible to change a magic number of an open position.
Of course I set a magic number corresponding to the strategy before I open the position. This is essential to my EA:
Could this be a bug in MT5 / OnTradeTransaction?
Forum on trading, automated trading systems and testing trading strategies
OnTradeTransaction Event is triggered 4 times when closing one position
Vladimir Karputov, 2020.07.09 12:09
You have two strategies. Strategy # 0 has Magic '1556', and strategy # 1 has Magic '7548'.
If you want to close a position that was opened according to Strategy # 0 - you must assign the object m_trade Magic '1556'
m_trade.SetExpertMagicNumber(1556);
, if you want to close the position that was opened according to Strategy # 1 - you must assign the object m_trade Magic ' 7548 '
Did you do it? No, you didn’t do this.
Step 1: m_trade.SetExpertMagicNumber(Strategy #);
Step 2: m_trade.PositionClose(
I'm doing it the way you described:
I think it's a bug that the magic number when closing the position in OnTradeTransaction is set wrong by MT5.
Bug description: Instead of setting it to the magic number of the transaction that closes the position, it is set to the magic number of the last transaction that opened a position.
I'm doing it the way you described:
I think it's a bug that the magic number when closing the position in OnTradeTransaction is set wrong by MT5.
Bug description: Instead of setting it to the magic number of the transaction that closes the position, it is set to the magic number of the last transaction that opened a position.
OK, you are right. Thanks for waking me up.
There is no bug. It works perfect if I set the magic number directly before closing the position.
I ran with my head against the wall several hours then it's harder to listen and to think.