Rounding lot size to 10,000 increments.

 

Hello again everyone!


I am trying to put in a function so that my lot sizes are always at 10000 increments. In theory;


if (Lotsize < 10,000) Lotsize = 10,000; else

if (Lotsize > 10,000 && Lotsize < 20,000) Lotsize = 10,000; else

if (Lotsize > 20,000 && Lotsize < 30,000) Lotsize = 20,000; else


etc..


Is this the correct format for what I am trying to accomplish?

 

Ok. Tried a rough draft with this coding, and recieved ordersend error 131 (invalid lot size.) Here's what I have;


if (Lotsize < 10000) Lotsize = 10000; else
if (Lotsize > 10000 && Lotsize < 20000) Lotsize = 10000; else
if (Lotsize > 20000 && Lotsize < 30000) Lotsize = 20000; else
if (Lotsize > 30000 && Lotsize < 40000) Lotsize = 30000; else
if (Lotsize > 40000 && Lotsize < 50000) Lotsize = 40000; else
if (Lotsize > 50000 && Lotsize < 60000) Lotsize = 50000; else
if (Lotsize > 60000 && Lotsize < 70000) Lotsize = 60000; else
if (Lotsize > 70000 && Lotsize < 80000) Lotsize = 70000; else
if (Lotsize > 80000 && Lotsize < 90000) Lotsize = 80000; else
if (Lotsize > 90000 && Lotsize < 100000) Lotsize = 90000; else
if (Lotsize > 100000 && Lotsize < 110000) Lotsize = 100000;


double Lotsize = AccountBalance() /Aggresion;


I am assuming that with the divisor variable it is not recognizing the minimum lotsize as 10000. Where am I going wrong?

 

if(Lotsize < 20000) Lotsize = 10000; else Lotsize=MathFloor(Lotsize/10000)*10000;

 
I'm sorry, could you explain what that function does? I'm assuming that function rounds lotsizes to the nearest 10,000, yes?
 

Ok. Program edited as such;


if(Lotsize < 10000) Lotsize = 10000; else Lotsize=MathFloor(Lotsize/10000)*10000;

double Lotsize = (AccountBalance()/Aggression);


Still getting ordersend error 131. Any ideas?

 
Replace strings

double Lotsize = (AccountBalance()/Aggression);

if(Lotsize < 10000) Lotsize = 10000; else Lotsize=MathFloor(Lotsize/10000)*10000;

 
Gotcha. I believe this fixed the issue, and now am having a problem with margin requirements, I suppose. Thank you very much!
Reason: