Hi guys,
I’m currently in a bind with my EA. Everything was fine and dandy until i tried adding an auto lot sizing function or money mangement
The following are the codes I’ve added in and got me the error.
input bool isSizingOn = true; // Auto Lot Sizing
input int Risk = 1; // Risk level (%)
int OnInit(){
if(Digits == 5 || Digits == 3 || Digits == 1)P = 10;else P = 1; // To account for 5 digit brokers
if(Digits == 3 || Digits == 2) isYenPair = true; // Adjust for YenPair
if (isSizingOn == true)
{
Lots = Entry_Amount;
Lots = Risk * 0.01 * AccountBalance() / (MarketInfo(Symbol(),MODE_LOTSIZE) * Stop_Loss * P * Point); // Sizing Algo based on account size
if(isYenPair == true) Lots = Lots * 100; // Adjust for Yen Pairs
Lots = NormalizeDouble(Lots, 2); // Round to 2 decimal place
}
}
All variables are declared, no errors, not warnings.
Is my calculation wrong? Or am I doing it entirely wrong?