Discussion of article "Processing of trade events in Expert Advisor using the OnTrade() function"
When compiling it gives an error implicit conversion from 'number' to 'string' TradeControl.mq5 349 99
in this line
_alerts += "On the pair "+PositionList[i].symbol+" the stoploss was changed from "+ PrevPositionList[i].sl +" to "+ PositionList[i].sl +"\n";
This is not an error but a warning that this line contains an implicit conversion of a number into a string. In such cases, the compiler warns about the conversion, and the programmer must decide whether this conversion is an error or not.
To remove this warning, you must make an explicit conversion:
_alerts += "On Steam."+PositionList[i].symbol+" changed stoploss from "+ (string)PrevPositionList[i].sl +" on "+ (string)PositionList[i].sl +"\n";
This is not an error, but a warning that this line contains an implicit conversion of a number into a string. In such cases, the compiler warns about the conversion, and the programmer must decide whether this conversion is an error or not.
To remove this warning, you should make an explicit conversion:
Somehow it does not work correctly, the position closed at take profit, but there is no information about it. here is the log
DS 0 TradeControl (EURUSD,M5) 22:36:06 Trade event received
EJ 0 TradeControl (EURUSD,M5) 22:36:06 Error # 4751
PN 0 TradeControl (EURUSD,M5) 22:36:06 876874 Order received for processing
DH 0 TradeControl (EURUSD,M5) 22:36:08 Trade event received
IS 0 TradeControl (EURUSD,M5) 22:36:08 Error #4751 Order 876874 not found!
HK 0 TradeControl (EURUSD,M5) 22:36:08 Error # 4751 state:4
RQ 0 TradeControl (EURUSD,M5) 22:36:08 0 Order executed, proceed to trade
OD 0 TradeControl (EURUSD,M5) 22:36:08 876874 order generated trade #947094
RS 0 TradeControl (EURUSD,M5) 22:36:08 Opened a buy position on EURUSD
DQ 0 TradeControl (EURUSD,M5) 22:36:08 Trade event received
DI 0 TradeControl (EURUSD,M5) 22:36:08 Received Trade event
KQ 0 TradeControl (EURUSD,M5) 22: 41:45 Received event Trade
KI 0 TradeControl (EURUSD,M5) 22:41:45 Trade event received
KQ 0 TradeControl (EURUSD,M5) 22:41:45 Trade event received
The article does not cover the closing of positions with take-profit and stop-loss. Only the events indicated at the beginning of the article are considered.
I see, it's a pity that they are not considered. I will wait for a similar article to appear or you will add your own in accordance with it. The analogue of the article for MT4 can be found here https://www.mql5.com/ru/articles/1399.
- Opening a position
- "Market Position
- Buy
- Sell
- Pending order
- Buy Limit
- Sell Limit
- Buy Stop
- Sell Stop
- "Market Position
- Order triggering
- Buy Limit
- Sell Limit
- Buy-stop
- Sell Stop
- Position closure
- "Market Position
- Buy
- Stop Loss
- Take Profit
- Manual (not Stop Loss or Take Profit)
- Sell
- Stop Loss
- Take Profit
- Manually
- Buy
- Pending order (delete)
- Buy Limit
- Expiration time
- Manually
- Sell Limit
- Expiry time
- Manually
- Buy-stop
- Expiry time
- Manual
- Sell stop
- Expiry time
- Manual
- Buy Limit
- "Market Position
- Position modification
- "Market Position
- Buy
- Stop Loss
- Take Profit
- Sell
- Stop Loss
- Take Profit
- Buy
- Pending order
- Buy Limit
- Opening Price
- Stop Loss
- Take Profit
- Expiry time
- Sell Limit
- Opening price
- Stop Loss
- Take Profit
- Expiry time
- Buy Stop
- Opening price
- Stop Loss
- Take Profit
- Expiry time
- Sell Stop
- Opening price
- Stop Loss
- Take Profit
- Expiry time
- Buy Limit
- "Market Position

- 2006.05.29
- Andrey Khatimlianskii
- www.mql5.com
No processing of HistorySelect()==false! Quite a frequent case...
The article does not cover the closing of positions with take-profit and stop-loss. Only the events indicated at the beginning of the article are considered.
New article Processing of trade events in Expert Advisor using the OnTrade() function is published:
Author: KlimMalgin
MQL5 supplies event processing mode,
Why do not supply event's praramers?
Wish like OnChartEvent(....), supply event id and parameters!!!!!!!!!!!!!
Wish like OnChartEvent(....), supply event id and parameters!!!!!!!!!!!!!
The OnChartEvent is used in the article Creating Active Control Panels in MQL5 for Trading.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Processing of trade events in Expert Advisor using the OnTrade() function is published:
MQL5 gave a mass of innovations, including work with events of various types (timer events, trade events, custom events, etc.). Ability to handle events allows you to create completely new type of programs for automatic and semi-automatic trading. In this article we will consider trade events and write some code for the OnTrade() function, that will process the Trade event.
Author: KlimMalgin