Risk of loss in percentage?

 

Hello everyone!

I am faily new at MQL5 programming, but i have tho been programming in other languages like Python and C# (i see alot of similarities in C#)


i am making alot of different EA's for the purpose of learning.

I have made a simple bot that runs off of the MACD indicator, and i would like to make it so when it opens a trade, it never risks to loose more than an X-percantage of the full account.

This means that its gonna get a little bit more complex for me, and thats where i hope some of you could assist me. It needs to calculate a risk, and from that risk decide wether to keep the trade open or close it.


The reason why i want this is that the bot has a really neat balance graph every time i backtest it (no matter the period), and the equity follows nicely. However the equity sometimes spikes very low, which is what i dont want happening. So if you have a better idea, please let me know :-)


Thank you alot in advance for your time.

Files:
MACD.PNG  11 kb