ExpertTrader
Fun Poster
- Messages
- 889
- Joined
- Dec 25, 2009
- Messages
- 889
- Reaction score
- 1,128
- Points
- 91
u have to find mathematically, what is the multiplication factor and use that for your LotSize calculation
eg.
(again, there are many ways, my explanation suppose to make things easy, if it is not , I am sorry)
the key is to understand also the function of MathFloor() ==> which return integer from double and also NormalizeDouble
void LotSizeCalculation()
{
double NativeBalance = 10000;
//because you define your multfactor to be NOT Linear, so, we have to figure it out, quite a bit on the calculation
LotSize = NormalizeDouble( MathFloor( (0.1 x 2 x AccountBalance() ) / ( (NativeBalance +1) * 0.1) ) * 0.1 , 1); //u want only 1 digit decimal
if (LotSize < 0.1 && AccountBalance() > 0) LotSize = 0.1;
//checking
// if accountbalance = 9999, LotSize = 0.2 x 9999/1000.1 = 1.999 ==> after MathFloor = 1 , then x 0.1 jadi 0.1 then after NormalizeDouble, LotSize = 0.1
// if accountbalance = 10000, LotSize = 0.2 x 10000/1000.1 = 1.999 ==> after MathFloor = 1 , then jadi 0.1 then after NormalizeDouble, LotSize = 0.1
// if accountbalance = 10001, LotSize = 0.2 x 10001/1000.1 = 2 ==> after MathFloor = 2 , then jadi 0.2 then after NormalizeDouble, LotSize = 0.2
// if accountbalance = 15000, LotSize = 0.2 x 15000/1000.1 = 2.999 ==> after MathFloor = 2 , then jadi 0.2 then after NormalizeDouble, LotSize = 0.2
//** by right we want if accountbalance = 15001, LotSize = 0.2 x 15001/1000.1 = 3 ==> after MathFloor = 3 , then jadi 0.3 then after NormalizeDouble, LotSize = 0.3
// but the above still give if accountbalance = 15001, LotSize = 0.2 x 15001/1000.1 = 2.999 ==> so, the formula is still wrong - kena betul sikit lagi kat NativeBalance + 1 vs accountbalance formula
// seterusnya check sendiri - i have to go for a while
}
best eh..?
ok - kembali kejap -
rasanya the formula tu kira ok - 99% tepat (tidak 100% mengikut keperluan Penyoal) - so boleh pakai -
sebab
tengok ni
//checking
//if accountbalance = 15002, LotSize = 0.2 x 15002/1000.1 = 3.00009 ==> after MathFloor = 3 , then jadi 0.3 then after NormalizeDouble, LotSize = 0.3