Skip to content

Symbol.AmountRisked

method · Symbol · cAlgo.API.Internals

DesktopCLICloud

Calculates the amount to be risked based on the specified stop loss and trading volume. 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.

Definition

double AmountRisked(double volume, double stopLossInPips)
api.Symbol.AmountRisked(volume: float, stopLossInPips: float) -> float

Parameters

Name C# type Python type Description
volume double float The volume to be traded
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 stopLossInPips = 50;
        var tradeVolume = Symbol.VolumeInUnitsMin;
        var amountRisked = Symbol.AmountRisked(tradeVolume, stopLossInPips);

        Print($"If you trade {tradeVolume} with a StopLoss of {stopLossInPips} pips you will risk losing {amountRisked} {Account.Asset.Name}");
    }
}
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):
        stopLossInPips = 50
        tradeVolume = api.Symbol.VolumeInUnitsMin
        amountRisked = api.Symbol.AmountRisked(tradeVolume, stopLossInPips)
        print(f"If you trade {tradeVolume} with a StopLoss of {stopLossInPips} pips you will risk losing {amountRisked} {api.Account.Asset.Name}")
{
  "AccessRights": "None"
}