Skip to content

Symbol.PipsForFixedRisk

method · Symbol · cAlgo.API.Internals

DesktopCLICloud

Calculates the number of pips 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 PipsForFixedRisk(double amount, double volume)
api.Symbol.PipsForFixedRisk(amount: float, volume: float) -> float

Parameters

Name C# type Python type Description
amount double float The amount to be risked.
volume double float The volume to be traded.

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.VolumeInUnitsMin;
        var amountRisked = 100;

        var stopLossInPips = Symbol.PipsForFixedRisk(amountRisked, tradeVolume);

        Print($"If you trade {tradeVolume} with a risk of losing {amountRisked} {Account.Asset.Name} you should use {stopLossInPips} Pips as your StopLoss");
    }
}
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.VolumeInUnitsMin
        amountRisked = 100
        stopLossInPips = api.Symbol.PipsForFixedRisk(amountRisked, tradeVolume)
        print(f"If you trade {tradeVolume} with a risk of losing {amountRisked} {api.Account.Asset.Name} you should use {stopLossInPips} Pips as your StopLoss")
{
  "AccessRights": "None"
}