Max daily loss

 

Hi, I have created an Expert to trade for me when i take the FTMO challenge, The only thing i have left to code is the max daily loss limit.

I need to set a maximum loss of 5% per day, So if i am risking 1% on every trade, after a loss of 4% in the current day the EA must stop trading.
I also need to include the risk in trades that are open as they have the potential to lose. So the code should add up the total profit/loss for the day and then add the total open risk in the account (open trades), If this is above 4% the EA should stop trading.


// MAX DAILY LOSS

//Add the total profit/loss of the current day
//Add the total risk of open trades
//If the value is below 4%: Trade = True
//If the value is above 4%: Trade = False
 
OnTeade()

Add the profits of closed positions. Reason_SL, Reason_TP.

Then calculate the max loss based on OpenPrice and SL value, add the two variables and there you get your total.

In OnTrade you can filter by time and date.

Should do the work for you.