## Spinal Implant EA with money management module

By JohnLast 2899 days ago Comments (5)
 От Technical Analysis

This  is the Spinal Implant EA with Logistic kernel and with money management module. You can see how the lot site is bigger when we are on a very profitable streak.

What is different is that here I use money management module. However I am using decreasing lot size.

This is the basic money management module from the default Moving Average expert.

Money Management used in the expert is very simple, but effective: the control over each position volume is performed depending on the previous transactions results. This algorithm is implemented by the LotsOptimized() function. The basic lot size is calculated on basis of the maximum allowable risk:

lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);

The MaximumRisk parameter displays the basic risk percentage for each transaction. It usually possesses a value between 0.01 (1%) and 1 (100%). For example, if free margin (AccountFreeMargin) equals to \$20,500 and rules of capital management prescribe to use risk of 2%, the basic lot size will make 20500 * 0.02 / 1000 = 0.41. It is very important to control over the lot size accuracy and to normalize the result with the allowable values. Normally, fractional lots with step of 0.1 are allowed. A transaction having volume of 0.41 will not be performed. To normalize, the NormalizeDouble() function is used with accuracy up to 1 character after the point. This results in the basic lot of 0.4. The basic lot calculation on basis of free margin allows to increase in volumes of operation depending on trading successfulness, i.e., to trade with reinvesting. This is the basic mechanism with obligatory capital management for increasing of trading effeсtiveness.

DecreaseFactor is the extent to which the lot size will be reduced after unprofitable trading. Normal values are 2,3,4,5. If the preceding transactions were unprofitable, the subsequent volumes will decrease by a factor of DecreaseFactor in order to wait through the unprofitable period. This is the main factor in the capital management algorithm. The idea is very simple: if trading is successfully increasing, the expert works with the basic lot making maximum profit. After the very first unprofitable transaction, the expert will "reduce the speed" until a new positive transaction is made. The algorithm allows to disable "speed reducing", for doing it, one has to specify DecreaseFactor = 0. The amount of the last successive unprofitable transactions is calculated in the trade history. The basic lot will be recalculated on this basis:

if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);

Thus, the algorithm allows to effectively reduce the risk occurring as a result of a series of unprofitable transactions.The lot size is obligatorily checked for the minimum allowable lot size at the end of the function because the previously made calculations can result in lot = 0:

if(lot<0.1) lot=0.1;

• JohnLast 2899 days ago

I made a simple upgrade allowing to have as a paremeter the number of the unprofitable trades after which the lot size is reduced.

• isuborsky 2878 days ago

This don't work with 0,01 lots , only with 0,10 lots, how I can improve this? Also with other bots

• JohnLast 2878 days ago

Yes you are correct, the code has to be checked and modified.

• JohnLast 2878 days ago

When I compare the results with 0.1 lot or with 0.2 lots without money management and with money management set for risk between 0.1 and 0.2: the results with money management are better.

The test results are of course forward tests.

with 0.1 lot: 446 profit

with 0.2 lot: 886 profit

with money management: : 1096 profit