Skip to content

Symbol.VolumeForProportionalRisk

method · Symbol · cAlgo.API.Internals

DesktopCLICloud

Calculates the volume to be risked (in X% of either the account equity or balance) based on the specified stop loss. Note that the result of this calculation may be imprecise as the exact degree of risk always depends on market movement and is impossible to predict.

Overloads

VolumeForProportionalRisk(ProportionalAmountType type, double percentage, double stopLossInPips)

Calculates the volume to be risked (in X% of either the account equity or balance) based on the specified stop loss. Note that the result of this calculation may be imprecise as the exact degree of risk always depends on market movement and is impossible to predict.

double VolumeForProportionalRisk(ProportionalAmountType type, double percentage, double stopLossInPips)
api.Symbol.VolumeForProportionalRisk(type: ProportionalAmountType, percentage: float, stopLossInPips: float) -> float

Parameters

Name C# type Python type Description
type ProportionalAmountType ProportionalAmountType The type of the amount to be risked (either balance or equity).
percentage double float The percentage of equity or balance to be risked.
stopLossInPips double float The stop loss in pips.

Returns double — The calculated volume in units.

Examples

using cAlgo.API;

namespace cAlgo.Robots;

public partial class TestExample : Robot
{
    protected override void OnStart()
    {
        var tradeVolume = Symbol.VolumeForProportionalRisk(ProportionalAmountType.Equity, 1, 20);

        ExecuteMarketOrder(TradeType.Buy, SymbolName, tradeVolume);
    }
}
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        tradeVolume = api.Symbol.VolumeForProportionalRisk(ProportionalAmountType.Equity, 1, 20)
        api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, tradeVolume)
{
  "AccessRights": "None"
}

VolumeForProportionalRisk(ProportionalAmountType type, double percentage, double stopLossInPips, RoundingMode roundingMode)

Calculates the volume to be risked (in X% of either the account equity or balance) based on the specified stop loss. Note that the result of this calculation may be imprecise as the exact degree of risk always depends on market movement and is impossible to predict.

double VolumeForProportionalRisk(ProportionalAmountType type, double percentage, double stopLossInPips, RoundingMode roundingMode)
api.Symbol.VolumeForProportionalRisk(type: ProportionalAmountType, percentage: float, stopLossInPips: float, roundingMode: RoundingMode) -> float

Parameters

Name C# type Python type Description
type ProportionalAmountType ProportionalAmountType The type of the amount to be risked (either balance or equity).
percentage double float The percentage of equity or balance to be risked.
stopLossInPips double float The stop loss in pips.
roundingMode RoundingMode RoundingMode The rounding method.

Returns double — The calculated volume in units

Examples

using cAlgo.API;

namespace cAlgo.Robots;

public partial class TestExample : Robot
{
    protected override void OnStart()
    {
        var tradeVolume = Symbol.VolumeForProportionalRisk(ProportionalAmountType.Equity, 1, 20, RoundingMode.ToNearest);

        ExecuteMarketOrder(TradeType.Buy, SymbolName, tradeVolume);
    }
}
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        tradeVolume = api.Symbol.VolumeForProportionalRisk(ProportionalAmountType.Equity, 1, 20, RoundingMode.ToNearest)
        api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, tradeVolume)
{
  "AccessRights": "None"
}