inserting commission in risk calculation
inserting commission in risk calculation
04 Aug 2021, 09:17
Hi
i use this code for calculating the volume per risk:
/// <summary>
/// Returns the amount of volume based on your provided risk percentage and stop loss
/// </summary>
/// <param name="symbol">The symbol</param>
/// <param name="riskPercentage">Risk percentage amount</param>
/// <param name="accountBalance">The account balance</param>
/// <param name="stopLossInPips">Stop loss amount in Pips</param>
/// <returns>double</returns>
public static double GetVolume(this Symbol symbol, double riskPercentage, double accountBalance, double stopLossInPips)
{
return symbol.NormalizeVolumeInUnits(riskPercentage / (Math.Abs(stopLossInPips) * symbol.PipValue / accountBalance * 100));
}
how is it possible to consider symbol commission inside this?
after opening position we can get the commission with position.Commissions but before entering the position how could we get it to insert this formula?
the second point is above code do not consider spread, how could we consider spread in this volume calculation?
Replies
firemyst
22 Sep 2021, 04:38
RE:
PanagiotisCharalampous said:
Hi yaghouti,
At the moment commission information is not available in cTrader Automate API. Spread is not really relevant to this calculation since it is embedded in the actual price.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
What about this? Although you can only obtain it _after_ a position is opened:
@firemyst
PanagiotisCharalampous
04 Aug 2021, 10:12
Hi yaghouti,
At the moment commission information is not available in cTrader Automate API. Spread is not really relevant to this calculation since it is embedded in the actual price.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous