Calling a function after stoploss triggered

 

In mql5, i made an ea that places multiple pending orders.

Now when the stoploss of one of those gets triggered, i want to run a function that gets the input parameters (open price, stoploss and takeprofit) from that trade.

I don't know how to start that funktion exactly when a stoploss gets triggered and also i dont know how to get those informations of that trade that was just closed.


Can you help me with that?

Thank you very much!

Tobias

 
  1. Research OnTrade.
  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

 

@William Roeder i have stated the problem. The problem is that i don't know how to start a function exactly when a stoploss gets triggered.

And i can't really find information on how to do that with OnTrade.

 
KT313:

@William Roeder i have stated the problem. The problem is that i don't know how to start a function exactly when a stoploss gets triggered.

And i can't really find information on how to do that with OnTrade.

You can start by putting an Id code (comment field/magic id) in the pending orders. To know when they get filled, use the OnTrade with a for loop to run all deals with that Id code.
 
KT313:

In mql5, i made an ea that places multiple pending orders.

Now when the stoploss of one of those gets triggered, i want to run a function that gets the input parameters (open price, stoploss and takeprofit) from that trade.

I don't know how to start that funktion exactly when a stoploss gets triggered and also i dont know how to get those informations of that trade that was just closed.


Can you help me with that?

Thank you very much!

Tobias

https://www.mql5.com/en/forum/296230/page12#comment_18316634
How to start with MQL5 - How to track the triggering of Stop Loss or Take Profit in a MML5 Expert Advisor
How to start with MQL5 - How to track the triggering of Stop Loss or Take Profit in a MML5 Expert Advisor
  • 2020.09.17
  • www.mql5.com
Example: tracking the triggering of stop loss or take profit. Attention: to get indicator data in an mql5 expert advisor, you must adhere to the following rules: the indicator handle is created in oninit then (as a rule, in ontick), the indicator data is received using copybuffer. Example: find the most losing position and the most profitable position