please convert this method
please convert this method
11 Jul 2014, 07:43
hi
i have this method MQL4
double lotsoptimized(){ double lot; if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE)*MarketInfo(Symbol(),MODE_TICKVALUE)); else lot=NormalizeDouble((AccountBalance()/1000)*minlot*risk,lotdigits); //lot=AccountFreeMargin()/(100.0*(NormalizeDouble(MarketInfo(Symbol(),MODE_MARGINREQUIRED),4)+5.0)/risk)-0.05; return(lot); }
pt = Symbol.PointSize*10;
but in calgo lot just int
and i dont know how convert mql to calgo :)
please if you can convert this method
thank you
Replies
RootFX
11 Jul 2014, 09:55
( Updated at: 21 Dec 2023, 09:20 )
RE:
modarkat said:
Here you go
but it's work like this method 100% .?
double lotsoptimized(){ double lot; if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE)*MarketInfo(Symbol(),MODE_TICKVALUE)); else lot=NormalizeDouble((AccountBalance()/1000)*minlot*risk,lotdigits); //lot=AccountFreeMargin()/(100.0*(NormalizeDouble(MarketInfo(Symbol(),MODE_MARGINREQUIRED),4)+5.0)/risk)-0.05; return(lot); }
@RootFX
RootFX
14 Jul 2014, 22:11
ok how edit this method
protected int GetVolume { get { var risk = (int)(RiskPct * Account.Balance / 100); int volumeOnRisk = stoploss > 0 ? (int)(risk * Symbol.Ask / (Symbol.PipSize * stoploss)) : Volume; double maxVolume = Account.Equity * Leverage * 100 / 101; double vol = Math.Min(volumeOnRisk, maxVolume); return (int)Math.Truncate(Math.Round(vol) / 10000) * 10000; // round to 10K } }
you can set RiskPct like this 1% or 2 % ... etc
but i want calc in stoploss
@RootFX
modarkat
11 Jul 2014, 09:29
Here you go
/forum/cbot-support/2929
@modarkat