Hello forum,
I am trying to write this simple "code" to link lot size to Account Balance, for example, if balance is between 1500 - 2499 = lotzise 0.2, 2500 - 3499 = lotzise 0.3, etc
So far I got this (see below) - within Start ( ), with the straightforward logic of simply "rounding" the proportion, also with the option to "override" it. Still, it returns lotsize = 0.
I'm obviously missing something...
Many thanks in advance!
D.
This line has double = (comparing not assigning)
lotsize == NormalizeDouble ((AccountBalance()/10000),1); //Try lotsize = NormalizeDouble ((AccountBalance()/10000),1);
This line has double = (comparing not assigning)
Hello forum,
I am trying to write this simple "code" to link lot size to Account Balance, for example, if balance is between 1500 - 2499 = lotzise 0.2, 2500 - 3499 = lotzise 0.3, etc
So far I got this (see below) - within Start ( ), with the straightforward logic of simply "rounding" the proportion, also with the option to "override" it. Still, it returns lotsize = 0.
I'm obviously missing something...
Many thanks in advance!
D.
double lotsize; if (LotSizeOverrideON == false) { lotsize == NormalizeDouble ((AccountBalance()/10000),1); }
If your account balance is 1,500 your code will return 0.1
This will meet your requirements
double ab =AccountBalance(); double lotsize; if(ab >= 1500 && ab < 2500) lotsize = 0.2;
Hello forum,
I am trying to write this simple "code" to link lot size to Account Balance, for example, if balance is between 1500 - 2499 = lotzise 0.2, 2500 - 3499 = lotzise 0.3, etc
So far I got this (see below) - within Start ( ), with the straightforward logic of simply "rounding" the proportion, also with the option to "override" it. Still, it returns lotsize = 0.
I'm obviously missing something...
Many thanks in advance!
D.
lots=0.2+MathFloor((balance-1500)/1000)/10;Don't forgot to follow RaptorUK advice though.
Hey all!
Thanks a lot everyone, angevoyageur's version is spot on! MathFloor function is key, I thought NormalizeDouble "rounds" the numbers, it looks like it only deletes digits actually..
GumRai, I also did that but I was looking at something.. more "elegant" : ) Qjol: Correct, only that using Balance is a bit more prudent though...Also good to know now the difference between "assigning" and "comparing" ... [blush]
Cheers!
D.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello forum,
I am trying to write this simple "code" to link lot size to Account Balance, for example, if balance is between 1500 - 2499 = lotzise 0.2, 2500 - 3499 = lotzise 0.3, etc
So far I got this (see below) - within Start ( ), with the straightforward logic of simply "rounding" the proportion, also with the option to "override" it. Still, it returns lotsize = 0.
I'm obviously missing something...
Many thanks in advance!
D.