Possible error of the MT5 Strategy tester in risk management calculating the batch with the OrderProfitCheck function

 
My premiere here with this thread, I want to share my experience with automated risk management, after thinking about the issue many times, I found this OrderProfitCheck function that belongs to the MoneyFixedRisk risk management class, before writing that does this function, I put them in context that makes my strategy, My strategy looks for entries, when it finds an entry, calculates an appropriate SL, with these two data and setting 1% of the balance as the maximum loss of an operation, OrderProfitCheck helps me to project the more lineage I need to not risk more than 1% of my balance.


Loss=-m_account.OrderProfitCheck(m_symbol.Name(),ORDER_TYPE_SELL,1.0,m_symbol.Bid(),sl);
aLots = MathFloor(m_account.Balance()*MaximumRisk/Loss/100.0/stepvol)*stepvol;


Until that moment I thought that they had solved my risk management problems, I entered the strategy tester and it turned out that sometimes it works and many times it does not, after many tests and not finding the problem, decide to test on real and resulting data that It works like a charm, it had no major inconveniences except the issue of the spread that makes the loss vary a bit.



I would like to know if someone has already been through this and if there is a solution to use it in the simulator ?, greetings.
 
Works / doesn't work is meaningless. Be more specific.
 
Alain Verleyen:
Funciona / no funciona no tiene sentido. Sé más específico.

Hello, If it works, in real time demo I already tried it and it works very well, what happens is that in the simulator it apparently does things well but in a few operations it burns the balance. It makes no sense, for example, to close a losing operation where I risked 15 usd and deducted 350usd or more, in a few operations it burns the balance, I have made the manual calculation according to my SL and my risk per operation to calculate the lineage and It is the same as the advisor calculates, today I will do other tests and capture some images to better describe the situation, thanks.

 
japarradog:

Hello, If it works, in real time demo I already tried it and it works very well, what happens is that in the simulator it apparently does things well but in a few operations it burns the balance. It makes no sense, for example, to close a losing operation where I risked 15 usd and deducted 350usd or more, in a few operations it burns the balance, I have made the manual calculation according to my SL and my risk per operation to calculate the lineage and It is the same as the advisor calculates, today I will do other tests and capture some images to better describe the situation, thanks.

capture some images to better describe the situation, thanks.

Files:
 
japarradog:

capture some images to better describe the situation, thanks.

Your strategy tester setting is in pips. Disable it if want to have profit/loss in chosen currency.


 
Alain Verleyen:

Your strategy tester setting is in pips. Disable it if want to have profit/loss in chosen currency.


Perfect @Alain Verleyen, it works fine, thanks.