Equity curve trading money management system in MQL5. How to implement it?

 

Good afternoon,

I am almost a newbie. I would like to implement an equity curve trading money management system in my EA in MQL5.

Equity curve trading system deals with two value, the equity using one contract (or lot) and the its moving average at 30 periods. When the equity cross his moving average from above to below the EA stop to work and resume to work when the equity cross his moving average at 30 periods from below to above.

Therefore I have mainly two problems:

1-I don't want to use the real value of my equity (of the account) but the calculated one from the backtesting simulation and then once obtained this value, store it in memory in an array and use it to calculate its moving average at 30 periods.

2- Put on chart the backtested equity and its moving average

Every suggestion,link, and especially example code is welcome.

Thanks
 

Hi Riccardo,

i 'll give you some guidelines in order to build what you are asking for, later we can discuss about details if you want:

  1. Avoid to have 2 systems (Real and BackTesting), integrations brings some dangerous errors;
  2. Use virtual private servers, so avoid using hystorical data. 
  3. You should be dynamic in correct and restart your many experts anytime
  4. Limit human interaction as much as you can

Here my propososal architecture:

  1. Build one Expert: it will create any time 1 virtual order, and 1 real order. Virtual order means it has some variable "SL" and "TP", if price reach this level consider to upgrade another variable, let's call it "virtual Balance".
  2. Check , with moving everage for instanc, your "virtual Balance"
  3. If Check is ok, the exper can keep to create both real and virtual orders.
  4. if Check fail, stop creating real orders, but keep on going with virtual ones, so you can keep to monitor the virtual Balance.
  5. Do not apply Money Managment strategies on virtual orders, (calculation of adaptive size), but of course you can do it on real ones. 
  6. When you go live with your Expert, run backtest and with fileWrite function, create a param.set file with info about last trades, so your expert will start immediatly with a "virtual memory" not empy. 

Of course there are some other issues to grasp with, but start with some easy firs.

<Deleted>