Symbol.VolumeForFixedRisk
method · Symbol · cAlgo.API.Internals
Calculates the volume to be risked (in X units of the account deposit currency) 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
| Signature |
|---|
VolumeForFixedRisk(double amount, double stopLossInPips) |
VolumeForFixedRisk(double amount, double stopLossInPips, RoundingMode roundingMode) |
VolumeForFixedRisk(double amount, double stopLossInPips)
Calculates the volume to be risked (in X units of the account deposit currency) 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 VolumeForFixedRisk(double amount, double stopLossInPips)
api.Symbol.VolumeForFixedRisk(amount: float, stopLossInPips: float) -> float
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
amount | double | float | The amount you want to risk in your account deposit currency. |
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.VolumeForFixedRisk(1000, 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.VolumeForFixedRisk(1000, 20)
api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, tradeVolume)
{
"AccessRights": "None"
}
VolumeForFixedRisk(double amount, double stopLossInPips, RoundingMode roundingMode)
Calculates the volume to be risked (in X units of the account deposit currency) 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 VolumeForFixedRisk(double amount, double stopLossInPips, RoundingMode roundingMode)
api.Symbol.VolumeForFixedRisk(amount: float, stopLossInPips: float, roundingMode: RoundingMode) -> float
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
amount | double | float | The amount you want to risk in your account deposit currency. |
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.VolumeForFixedRisk(1000, 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.VolumeForFixedRisk(1000, 20, RoundingMode.ToNearest)
api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, tradeVolume)
{
"AccessRights": "None"
}