1. Choosing the dollars value to risk into the operation.
2. Calculating the pips' size number of stoploss (differentiation between entryprice and stoploss level)
3. Dividing the risk in dollars for the stoploss pips then obtaining how many dollars I could risk for, for every pip.
4. Commuting this value in Lots.
The following is a practical example on the couple audcad :
0. These are the settings on QuoteManager:
PriceScale: 1/100000 (xxx/JPY = 1/1000)
MinMovement: 1
BigPointValue: 1
1. I want to risk 50$ at each operation.
2. I want to calculate the stoploss range in pips.
entryprice = 0.96918
Stoploss = 0.95942
entryprice - Stoploss = 0.00976 * 10000 = 97.6 pips
3. 50/97.6 = 0.5 cents at pips.
4. 0.5 $ cents at pips represent 0.05 Lots meaning 0.5 *10000 correspond to 5000 contracts.
Here's the code:
Code: Select all
vars: Rng(0), Risk(0), EntryLvl(0), StopLossLvl(0), PipsSL(0), SizeTrade(0);
Risk = InitialCapital * 0.05; //I decide how much I want to risk for each trade.
Rng = EntryLvl - StopLossLvl; //I calculate the pips number of pips of stoploss.
PipsSL = Rng * (PriceScale/10); //I try to make this number out of a whole number with a decimal place.
CentsAtPip = Round(Risk/PipsSL, 1); //I divide the risk for the pips' number obtaining how many dollars I could risk for, at every pip.
Then rounding up this number at the first decimal place.
SizeTrade = (CentsAtPip * 10) * 1000; //At the end I want to calculate the trade size multiplying the value by 10000.
Example: CentsAtPips = 0.7, SizeTrade = 0.7 * 10000 = 7000 which means 0.07 Lots