Hi,
Since you know how to modify code - why not insert some Print(...) calls into code and 'see' what you think you calculating and/or make up simple script with code/calculations attempting to modify - not forgetting the Print(..)s of course ;)
Good Luck
I made a Comment (lots) to show the lots on screen, but it gives me "0 lots".
double risk=RiskPercent/100;
IF RiskPercent is type int THEN type int / type int --> type int
only then is type int cast to type double for storage in a type double
in other words/for example:
25percent/100 results in ZERO not 0.75
type int not hold fractional part of number.
please try this:
double risk=RiskPercent/100.0;
Now you have: type int / type double --> type double
ie, having 100.0 as type double constant promotes the expression to type double and before division takes place RiskPercent is promoted to type double... then the division is done between two doubles
double stop=SL*1;
why "*1" ?
is same as saying: SL
f (mm) lot=NormalizeDouble(MathFloor((AccountFreeMargin()*risk)/stop),0);
Why zero digits after decimal point ie, whole lots only?
The expression might give for instance 0.2, and Normalize... will deliver zero
edit: ok, mathfloor returns largest int <= to double expr
but again, what if mathfloor returns zero?
btw,
a Comment to show lots is ok but this does not show the workings of the arithmetical expressions used in the function.
eg:
Print("(AccountFreeMargin()*risk)=",AccountFreeMargin()*risk);Print("(AccountFreeMargin()*risk)/stop=",(AccountFreeMargin()*risk)/stop);
IF RiskPercent is type int THEN type int / type int --> type int
only then is type int cast to type double for storage in a type double
in other words/for example:
25percent/100 results in ZERO not 0.75
type int not hold fractional part of number.
please try this:
double risk=RiskPercent/100.0;
Now you have: type int / type double --> type double
ie, having 100.0 as type double constant promotes the expression to type double and before division takes place RiskPercent is promoted to type double... then the division is done between two doubles
why "*1" ?
is same as saying: SL
Why zero digits after decimal point ie, whole lots only?
The expression might give for instance 0.2, and Normalize... will deliver zero
edit: ok, mathfloor returns largest int <= to double expr
but again, what if mathfloor returns zero?
btw,
a Comment to show lots is ok but this does not show the workings of the arithmetical expressions used in the function.
eg:
Print("(AccountFreeMargin()*risk)=",AccountFreeMargin()*risk);Print("(AccountFreeMargin()*risk)/stop=",(AccountFreeMargin()*risk)/stop);
Thank You!
Changing 100 to 100.0 made the difference.
Why stop=SL*1, that was an old error, it used to say sl*0.1 but then I realized that 1 lot =10 dollars per pip so, changed it to say *1 instead of changing stop and SL. I'll clean it up.
Thanks again, it is working now.
glad you now happy with code...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Following EA is one I downloaded somewhere and I modified the Money Management part of it.
Before it took a percentage of the account balance, but now I modified it to calculate max drawdown based on the stoploss that yu set.
Now, I use a broker with fractional pips, so 200 pips is really 20 pips.
After the mod. the EA doesn't place the order. Can someone take the challenge and see where I messed up?
Thanks.
Below is code I modified.