fx_maddin:
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
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
RaptorUK:
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
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?
fx_maddin:
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?
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. 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.
RaptorUK:
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.
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.
fx_maddin:
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 . . .
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.
RaptorUK:
" If LotStep 0.01 and LotMultiplier = 1.4 everything works well." NO, it doesn't . . .
" 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 :-(
fx_maddin:
No, it doesn't. If myLot is 0.14 and you multiply by 1.4 you get 0.196, use NormalizeDouble on a 3, 4 or 5 digit pair and you will end up with 0.196, 0.1960 or 0.19600 none of which are full multiples of 0.01
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.
fx_maddin:
That will also not work correct. It assumes lotStep = 0.0001 A lot of brokers have minlot=0.1, lotStep=0.01. Normalize it correctly
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); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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