Risk calculation not same on backtesting as live

Created at 12 Feb 2016, 12:05
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!
MA

mats.j.andersson

Joined 05.02.2016

Risk calculation not same on backtesting as live
12 Feb 2016, 12:05


Hi

I am using the following code to calculate volume based on risk-%

 double costPerPip = (double)((int)(Symbol.PipValue * 10000000)) / 100;
var volume = (Account.Balance * RiskPerDeal / 100) / (StopLossInPips * costPerPip);
var volumeInUnits = Symbol.QuantityToVolume(volume);
volumeInUnits = Symbol.NormalizeVolume(volumeInUnits, RoundingMode.Down);

I am a running a demo account with 5000€ and leverage 1:10

When backtesting it will always accept my trades even if the StopLossInPips is very low (2 or 3). But when running "live" any trade with a SL of say 3 will give a volume of about 1,8 which of course will not be accepted since my total account is only 50 000.

Is there a way to get the backtest to function more like the "real deal" and acknowledge my real balance? 
Or is my way of calculating volume not optimal? 

Regards

/mats


@mats.j.andersson
Replies

Spotware
17 Feb 2016, 12:09 ( Updated at: 21 Dec 2023, 09:20 )

Dear Trader,

We recommend you to run backtesting using tickdata mode to get more accurate results. 


@Spotware