Get rid of Take Profit & Stop Loss fixed settings in an EA

 

I want to base my EA to use technical indicators to enter and exit trades. To EXIT I want to get rid of Take Profit and Stop Loss settings and rather use a percentage of the current profits or a percentage of the current equity available. (Yes I know I would be stopped out earlier, but then I want to make sure my ENTRY to trades is correct! - if a trade is wrong, it is wrong! Why risk waiting for the signal to reverse?)

Thus to enter trades if my technical indicators detects a BUY or SELL signal - to simplify, let's say if SlowMA is above FastMA I want to SELL and BUY when the situation is reversed. (I have code for this, so no help needed here! - two functions to calculate the maximum lots based on available equity and to ensure it is aligned with the trader lots allowed - maximum lots allowed)

I want to use a percentage of my deposit amount initially but if the account has some profit, a percentage of the profit - I have already found some code on the forum to calculate the amount of lots based upon a percentage: The specific example uses 15% of equity.

What I require is some kind of Account Guard to EXIT trades - thus if the EA made a wrong BUY or SELL trade, I need to EXIT the trade if a percentage of equity or profits is reached - let say 25% of profits if the profit is more than $100, if no profit yet, a percentage of equity?

Can somebody please point me to an example or provide an example to achieve this? Much appreciated!

I am not a MQL4 programmer, but a brilliant Google copy-and paster!