Lots calculation; I keep getting 0 lots when debugging

 
Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);
Print(Lots);

When checking the log, I continue to get a calculation of 0 lots, so this error perpetuates:


2013.07.17 17:47:59 2012.01.11 22:19 Coin Toss EA EURUSD,M5: OrderSend error 4051

2013.07.17 17:47:59 2012.01.11 22:19 Coin Toss EA EURUSD,M5: invalid lots amount for OrderSend function


 
slothstylez :

When checking the log, I continue to get a calculation of 0 lots, so this error perpetuates


Perhaps you can explain the logic behind your calculation ? what are you trying to calculate ?
 
I'm trying to calculate lot size (ie: Lots) using risk management. The variable "Risk" is an int that represents the percentage of the account that you are willing to risk in a given trade. All other relevant data within the calculation are built in mql4 functions or constants that should produce an appropriate lot size given Risk value.
 
This is being tested on the Oanda platform.
 
slothstylez :

When checking the log, I continue to get a calculation of 0 lots, so this error perpetuates:

2013.07.17 17:47:59 2012.01.11 22:19 Coin Toss EA EURUSD,M5: OrderSend error 4051

2013.07.17 17:47:59 2012.01.11 22:19 Coin Toss EA EURUSD,M5: invalid lots amount for OrderSend function



Your code:

double Lots = 0;
int Risk = 1;
Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);
Print(Lots);

produces this in the log:

Lots Test #1

So, the code (as you have posted it) seems to give a non-zero value. Did you define the variable Lots as an int or double?

 
 
WHRoeder :
Normalize the size

So, basically instead of using MathFloor() I want to use NormalizeLots() ?
 
slothstylez :
I'm trying to calculate lot size (ie: Lots) using risk management. The variable "Risk" is an int that represents the percentage of the account that you are willing to risk in a given trade. All other relevant data within the calculation are built in mql4 functions or constants that should produce an appropriate lot size given Risk value.
How does it ? your risk is governed by your stop, where is your stop in your calculation ?
 
slothstylez : I'm trying to calculate lot size (ie: Lots) using risk management.

I missed that post.
Risk = account balance * percent = (OrderOpenPrice - SL) * OrderLots * DeltaPerLot.

 
WHRoeder :

I missed that post.
Risk = account balance * percent = (OrderOpenPrice - SL) * OrderLots * DeltaPerLot.

Good, I thought it was just me going nuts and being confused about what the OP was trying to do . . .
Reason: