univetsity:
I'd like to confirm my trade lot, and use code as follow:
accountfreemargin()=10,000 MaximunRisk=0.02 but I found it couldn't run normally, it always use 0.01 trading.My MM is 5 digits price,so 1 Point stands 1USD,and b usually < 0.001.I think my method is correct,but the result go wrong.Any help would be great,TKS!I think you should declare:
double b; int c; b=iATR(NULL,0,233,0); c=AccountLeverage(); // number of losses orders without a break
Because iATR give you a double value less than zero if I'm not wrong.
acushnir:
I think you should declare:
Because iATR give you a double value less than zero if I'm not wrong.
great,you are correct!
I found use b and c the position will always 0.01,haven't find the cause,so wirte a new version as follow:
I found use b and c the position will always 0.01,haven't find the cause,so wirte a new version as follow: double LotsOptimized() { double b,lot;//=Lots; int orders=HistoryTotal(); int losses=0,wins=0; int c,e,f,d; b=iATR(NULL,0,60,0); c=AccountLeverage(); d=AccountFreeMargin();//I wanna use it describe account's principal,but couldn't how to if(orders>=1) {e=AccountFreeMargin(); } Print(MarketInfo(Symbol(), MODE_LOTSIZE)); Print(MarketInfo(Symbol(), MODE_LOTSTEP)); Print(MarketInfo(Symbol(), MODE_MAXLOT)); Print("this accountleverage is",c); if(d!=0) lot=NormalizeDouble((e*MaximumRisk/2000)*(1+3*(e/d-1)),2);//if profitiable,increase position,otherwise,the vice if(lot<0.01) lot=0.01; return(lot); }but the first order's position still be 0.01, these follow will be normal,don't know why. And I know the d==e in my code,so e/d always=1, but I wanna use d stands principal,but how do?TKS!
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
I'd like to confirm my trade lot, and use code as follow:
accountfreemargin()=10,000 MaximunRisk=0.02 but I found it couldn't run normally, it always use 0.01 trading.My MM is 5 digits price,so 1 Point stands 1USD,and b usually < 0.001.I think my method is correct,but the result go wrong.Any help would be great,TKS!