auto lot sizing issue
-
i want to use auto lot sizing like this :
balance 1000 - 1999 lot 0.01
balance 2000 - 2999 lot 0.02
balance 3000 - 3999 lot 0.03i am already used " % of balance => lot 100% "
and it gives me lot 0.01 on balance 1000 .. but when the balance exceed 1500 the lot becomes 0.02
and when balance becomes 2500 the lot turns to 0.03
but this is not what i want .. as i said .. i want the auto lot like that :balance 1000 - 1999 lot 0.01
balance 2000 - 2999 lot 0.02
balance 3000 - 3999 lot 0.03
and so on ....any help ???
-
Try putting this to your lot field:
MathFloor(AccountBalance()/1000)*0.01
-
@roar said in auto lot sizing issue:
MathFloor(AccountBalance()/1000)*0.01
should i put this equation into lot field under " % of balance => lot 100% " ??
-
@wolamen No, just "custom value"
-
@roar it is worked .. great .. thanks
-
@roar thanks for the last help .. now another issue
how could i do the same with condition of take profit ?
what i mean that :
if balance is 1000$ so the TP is 10$
but if the balance becomes 2000$ so the TP turns to 20$any help?
-
@wolamen
Your lot size already grows linearly with balance, so couldn't you just use a fixed pip TP, like 10 pips?
Anyway, there is no fast way to use $ stops, you must calculate it with your lot size and TP pips. You should be able to do the math yourself, I'll help only with the "coding" part
-
So there is something called lot step. For example, if the lot step is 0.01, you can open 0.01, 0.02, 0.03... lots. If the lot step is 0.1, you can open 0.1, 0.2, 0.3 and so on. Lot step is the difference between two possible lot sizes. If you try some middle value, for example 0.012345, it will give you an error. So the EA that is generated would always use possible values. If your balance is 2641 and the lot size is calculated as 0.02641, this value is then rounded to the nearest possible. I guess that I used MathRound(). But as roar wrote, you can always write your own function. Some functions that you can use are AccountBalance(), AccountEquity(), MathFloor(), MathCeil() and MarketInfo() if you want to get the lot step. Take a look at their description in the documentation for MQL4 in MetaEditor (Help -> MQL4 Reference)