How to Limit Daily Profits in dollars or percent ??

 

I have difficulties in making EA.

how do you limit the daily profit in ea.
if the daily profit is reached then EA will close open and stop positions.
then continue trading the next day.

please help. how to write the MQL
thank you