ok. solved for closing position and change stoploss.
For checking if order closed by stoploss I would do this:
res1= OrderSelect(TicketNR);
if (res1==false) // the order has been closed
{
res1=HistoryDealSelect(TicketNR);
price=HistoryDealGetDouble(TicketNR,DEAL_PROFIT);
if (price<0) && ??? HistoryDealGetDouble(TicketNR,DEAL_PRICE) ???? But TicketNR of the opened order TciketNR of deal?
Thanks
Alain Verleyen:
To close a BUY position you have to send a SELL order with the same volume as your position.
To check if it's close by stoploss you can check the history of deals.
To change a stoploss you have to send an order TRADE_ACTION_SLTP.
Please read the documentation, the forum and articles. If you need help on coding please post your attempt.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
To close a BUY position you have to send a SELL order with the same volume as your position.
To check if it's close by stoploss you can check the history of deals.
To change a stoploss you have to send an order TRADE_ACTION_SLTP.
Please read the documentation, the forum and articles. If you need help on coding please post your attempt.