Lot size code calculation?

 

Hi, I am trying to include a money management function in an EA (actuallly it shouldn't be called MM, as it should only calculates how many lots can I buy so that when I hit my stop loss I only loss a certain percentage of my account).

I created the EA with a code generator, I`m not a programmer, so I dont know how to code it and where to include it.

Any help would be appreciated, thank you!

 

injecting the money management to an EA is good guys...

But yours strategy have been tested before?. how is the result??

 

I backtested the EAs (I built two based on different strategies, both attached here), but the tests showed huge max drawdowns, sometimes over 60%, even when the overall result is positive.

I think those drawdowns are not aceptable; I want to reduce this dd to at most 20%, so I should replace fixed lot size for lot sizing based on account free margin to risk no more than 1% (based on stoploss).

But this is what I cant code, both Eas are attached and of course can be modified to include any improvement necesary.

Files:
 

Do give us the update when you are done..

 
WilliamChadwick:
Do give us the update when you are done..

I am in need of some advice regarding the code, once I have it I´ll proceed to backtest the Eas again, please if someone with knowledege of mql4 has some advice or wants to modify the Eas please feel free to do it.

Files: