MQL4 how can I check if the order hit SL?

MQL4 how can I check if the order hit SL?

Manage alerts

Loading saved threads...

NeoOne · External communityPost link
External question — Stack Overflow Stack Exchange Author: NeoOne Original post: https://stackoverflow.com/questions/70536924 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am coding an algorithmic trading robot and how can I check if the order hit SL on MQL4?
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange Author: PaulB Original post: https://stackoverflow.com/a/70548519 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. The most robust method is to record then track the trade using its OrderTicket() . Track this until the trade is closed (using OrderCloseTime() to determine when closed). You can then retrieve the OrderClosePrice() and check it against the OrderStopLoss() .
Quote
Report
Mahesh Mahadar · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Mahesh Mahadar Original post: https://stackoverflow.com/a/73086063 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. For MQL5 If trade hit stoploss or target then it will close automatically You just need to check position of that symbol. if(!PositionSelect(_Symbol)) { // trade is closed, now you can take new entry of that symbol. }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Mahesh Mahadar Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/73086063 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. For MQL5 If trade hit stoploss or target then it will close automatically You just need to check position of that symbol. if(!PositionSelect(_Symbol)) { // trade is closed, now you can take new entry of that symbol. }

Cancel quote

Checking account access…