How to retitle lot size based on equity in MQL?

Hi guys,

I have been trying to implement a code which will be able to adjust my lotsize based on the percentage of equity. I am not getting any errors but i am getting warnings which is preventing my EA from running in the strategy tester.


double Lots=0;
double Equity=AccountEquity();
double RiskedAmount=Equity*RiskPercent*0.01; 
 Lots=(RiskedAmount/ Xpips1 )/10;

Where Xpips would be an extern int.

I can’t see where i am going wrong. can someone please show me how to compute this.

Thanks in advance

Hi,

I assume your trading an instrument that has 5 digits?

Here is my code for auto adjust lotsize which works fine. My “StopLoss” is also an integer.

Hope this helps!

double LotSize=0;
double Equity=AccountEquity();
double RiskedAmount=Equity*RiskPercent*0.01;
LotSize=(RiskedAmount/(StopLoss))/10;