Lotsize Calculation
Lets assume the following (simplified) Code:
This works well with MODE_LOTSTEP = 0.01.
With MODE_LOTSTEP 0.1 it does not work because 0.14 Lot is not allowed.
How can I calculate on Init to Print Out an Alert und prevent trading with this Lot Size?
thanks in advance
Why init() ? you should be checking when you have calculated your position size, or adjust it to fit within the requirements of MODE_MINLOT MODE_MAXLOT and MODE_LOTSTEP
I will check on Init if the LotMultiplier work with current LotStep. I think it will be okay to check once. Is there a way to calculate?
I will check on Init if the LotMultiplier work with current LotStep. I think it will be okay to check once. Is there a way to calculate?
Your first post in this thread is incorrect, the third order position size, 0.196 , does not work even with a LOTSTEP of 0.01 . . . the fourth position size would be 0.2744 and would also not work.
This is why it is a bad idea to do it that way, your code will be dependant on the way in which you use your LotMultiplier variable, if you change it then you have to change your code, you code is not reusable, it's inefficient and bad practice.
Your first post in this thread is incorrect, the third order position size, 0.196 , does not work even with a LOTSTEP of 0.01 . . . the fourth position size would be 0.2744 and would also not work.
I know that it will not work, therefore I looking for a possibility to calculate. If LotStep 0.01 and LotMultiplier = 1.4 everything works well. If LotStep 0.1 and LotMultiplier is 1.4, an Alert should tell the user to change theMultiplier. If this not possible, I must do it another way.
I know that it will not work, therefore I looking for a possibility to calculate. If LotStep 0.01 and LotMultiplier = 1.4 everything works well. If LotStep 0.1 and LotMultiplier is 1.4, an Alert should tell the user to change theMultiplier. If this not possible, I must do it another way.
" If LotStep 0.01 and LotMultiplier = 1.4 everything works well." NO, it doesn't . . .
It works because I use NormalizeDouble
myLot = NormalizeDouble(myLot * 1.4, Digits);
But it does not work on Lotstep 0.1 :-(
It works because I use NormalizeDouble
But it does not work on Lotstep 0.1 :-(
It seems to be working on 4 several Broker and 8 different Pairs:
| 26554124 | 2012.11.06 09:18 | sell | 0.01 | eurusdm |
| 26554824 | 2012.11.06 09:30 | sell | 0.01 | eurusdm |
| 26555008 | 2012.11.06 09:32 | sell | 0.01 | eurusdm |
| 26555277 | 2012.11.06 09:38 | sell | 0.01 | eurusdm |
| 26555421 | 2012.11.06 09:40 | sell | 0.02 | eurusdm |
| 26555463 | 2012.11.06 09:40 | sell | 0.03 | eurusdm |
| 26555596 | 2012.11.06 09:41 | sell | 0.05 | eurusdm |
| 26555633 | 2012.11.06 09:41 | sell | 0.07 | eurusdm |
| 26555688 | 2012.11.06 09:41 | sell | 0.10 | eurusdm |
| 26555870 | 2012.11.06 09:42 | sell | 0.14 | eurusdm |
| 26556140 | 2012.11.06 09:48 | sell | 0.20 | eurusdm |
| 26556883 | 2012.11.06 10:03 | sell | 0.28 | eurusdm |
| 26557319 | 2012.11.06 10:10 | sell | 0.40 | eurusdm |
| 26557420 | 2012.11.06 10:10 | sell | 0.56 | eurusdm |
| 26557672 | 2012.11.06 10:11 | sell | 0.79 | eurusdm |
| 26557716 | 2012.11.06 10:11 | sell | 1.11 | eurusdm |
| 26557997 | 2012.11.06 10:14 | sell | 1.55 | eurusdm |
The only thing I do in my Code is what I posted above... It works as I expected.
It works because I use NormalizeDouble
myLot = NormalizeDouble(myLot * 1.4, Digits);
But it does not work on Lotstep 0.1 :-(
double NormalizeLots(double lots, string pair=""){ if (pair == "") pair = Symbol(); double lotStep = MarketInfo(pair, MODE_LOTSTEP), minLot = MarketInfo(pair, MODE_MINLOT); lots = MathRound(lots/ls) * ls; if (lots < minLot) lots = 0; // or minLot return(lots); }
Lets assume the following (simplified) Code:
This works well with MODE_LOTSTEP = 0.01.
With MODE_LOTSTEP 0.1 it does not work because 0.14 Lot is not allowed.
How can I calculate on Init to Print Out an Alert und prevent trading with this Lot Size?
thanks in advance