Skip to content

PriceAlerts.Add

method · PriceAlerts · cAlgo.API Since 5.2

DesktopCLICloud

Adds a new price alert.

Environment behaviour

Cloud — not supported. Throws ArgumentException 'Price alert is not supported in current environment.' (after normal argument validation).

Definition

PriceAlert Add(Symbol symbol, double price, PriceAlertQuoteType quoteType, PriceAlertCondition condition)
api.PriceAlerts.Add(symbol: Symbol, price: float, quoteType: PriceAlertQuoteType, condition: PriceAlertCondition) -> PriceAlert

Parameters

Name C# type Python type Description
symbol Symbol Symbol Symbol
price double float Price
quoteType PriceAlertQuoteType PriceAlertQuoteType Quote type
condition PriceAlertCondition PriceAlertCondition Condition

Returns PriceAlert — Added PriceAlert.

Examples

var targetPrice = Symbol.Bid - 30 * Symbol.PipSize;
var priceAlert = PriceAlerts.Add(Symbol, targetPrice, PriceAlertQuoteType.Bid, PriceAlertCondition.LowerOrEqual);
Print("Price alert {0} added at {1}", priceAlert.Id, priceAlert.Price);
targetPrice = api.Symbol.Bid - 30 * api.Symbol.PipSize
priceAlert = api.PriceAlerts.Add(api.Symbol, targetPrice, PriceAlertQuoteType.Bid, PriceAlertCondition.LowerOrEqual)
api.Print(f"Price alert {priceAlert.Id} added at {priceAlert.Price}")