Topics
Replies

ctid3066979
27 Apr 2021, 14:30

RE: RE:

ranjicgnr said:

ctid3066979 said:

Not sure if my heading explain it enough but i will try go into detail. so basically would like feature that is available on mt4/5 position size calculator that we can have a fixed risk percentage and our lot size changes based on our entry and SL input. 

thanks

graham

 

Hai

You can use the below code for automating lot sizing on cAlgo. Also you can modify the way you wanted

 

                                     double longStopLoss = Math.Min(Bars.Last(1).Low, Bars.Last(2).Low) - (Symbol.PipValue * 0.5);
                                    double balance = Account.Balance;
                                    double riskAmount = balance * RiskPercent * 0.01;
                                    douuble longRiskPoints = Ask - longStopLoss;
                                    double volumeinLots = Math.Floor(((riskAmount / longRiskPoints) / Symbol.LotSize) * 100) / 100;
                                    double volumeInUnits = Symbol.QuantityToVolumeInUnits(volumeinLots);
                                    ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, volumeInUnits, label);

 

I have used for EuroUSD. I have put last two bars low as stoploss.

OK but do not have a clue what to do with that lol

 


@ctid3066979

ctid3066979
23 Apr 2021, 14:31

YES we need this 100%


@ctid3066979

ctid3066979
23 Apr 2021, 00:23

someone has replied but i cant seem to see it


@ctid3066979