Code: Select all
double Lots;
Lots = NormalizeDouble(Risk * ((AccountBalance() * 50) / (MarketInfo(Symbol(),MODE_BID) * 10000)),2);So first I want to get the useable balance given my account's leverage of 50:1, so 10000 * 50 = 50000.
Then I want to divide this number by the current bid price of the currency chart I'm looking at * 10000 for 1 lot (Oanda). This should be the maximum lot size I can trade based on my account balance.
Next, I want to factor in my Risk % * Value in order to get the actual lot size I should trade based on my Risk %.
Lastly, I want to round the final value to just 2 decimal places.
So in this example it would be:
Code: Select all
NormalizeDouble(0.3 * ((10000 * 50) / (1.33150 * 10000)),2);
NormalizeDouble(0.3 * (50000 / 13315),2);
NormalizeDouble(0.3 * 3.75***),2);
END VALUE = 1.13;