Auto lot size setting based on risk percentage

Created at 22 Apr 2021, 12:34
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid3066979

Joined 22.04.2021

Auto lot size setting based on risk percentage
22 Apr 2021, 12:34


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


cTrader
@ctid3066979
Replies

ranjicgnr
22 Apr 2021, 23:36

RE:

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.


@ranjicgnr

ctid3066979
23 Apr 2021, 00:23

someone has replied but i cant seem to see it


@ctid3066979

louislamprell
23 Apr 2021, 13:06

Absolutely agreed

I would like to be able to place my orders using a risk percentage settings instead of having to use a calc first and then change the lot size. I scalp so being able to quickly place an order at 1% of my bank means when prices quickly change and i need to adjust my order, I dont need to constantly recalculate the lots to ensure i am only risking 1%. The trade panel is fantastic on ctrader, for me the only thing missing is a percentage based risk setting


@louislamprell

ranjicgnr
27 Apr 2021, 13:56 ( Updated at: 21 Dec 2023, 09:22 )

 

I am coding one for risk based qty. You can suggest features. I will try to incorporate


@ranjicgnr

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

Leonardo4
06 Mar 2024, 03:16

This is a very important function! Why hasn't it been done yet?

Это очень важная функция! Почему это до сих пор не сделано?


@Leonardo4