ChartTemplateIndicators.Add
method · ChartTemplateIndicators · cAlgo.API Since 5.6
DesktopCLICloud
Adds a new indicator to a chart template.
Environment behaviour
Cloud — not supported. Never available in the cloud: it is only returned by members that do not work there (ChartTemplate.Indicators).
Overloads
| Signature |
|---|
Add(string name, object[] parameterValues) |
Add(IndicatorType type, object[] parameterValues) |
Add(string name, object[] parameterValues)
Adds a new indicator to a chart template.
ChartTemplateIndicator Add(string name, object[] parameterValues)
chartTemplateIndicators.Add(name: str, parameterValues: list[object]) -> ChartTemplateIndicator
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The name of an indicator. |
parameterValues | object[] | list[object] | The indicator parameter values or an anonymous object that contains indicator parameter values. |
Returns ChartTemplateIndicator — An ChartTemplateIndicator representing the added indicator instance.
Examples
var template = ChartTemplates.Get("My Template");
if (template != null)
{
var indicator = template.Indicators.Add("Simple Moving Average", Bars.ClosePrices, 50);
Print("Added indicator {0} to the template", indicator.Type.Name);
}
template = api.ChartTemplates.Get("My Template")
if template is not None:
indicator = template.Indicators.Add("Simple Moving Average", api.Bars.ClosePrices, 50)
api.Print(f"Added indicator {indicator.Type.Name} to the template")
Add(IndicatorType type, object[] parameterValues)
Adds a new indicator to a chart template.
ChartTemplateIndicator Add(IndicatorType type, object[] parameterValues)
chartTemplateIndicators.Add(type: IndicatorType, parameterValues: list[object]) -> ChartTemplateIndicator
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
type | IndicatorType | IndicatorType | The type of Indicator, you can get IndicatorType from AlgoRegistry. |
parameterValues | object[] | list[object] | The indicator parameter values or an anonymous object that contains indicator parameter values. |
Returns ChartTemplateIndicator — An ChartTemplateIndicator representing the added indicator instance.
Examples
var template = ChartTemplates.Get("My Template");
if (template != null && AlgoRegistry.Get("Relative Strength Index", AlgoKind.StandardIndicator) is IndicatorType rsiType)
{
var indicator = template.Indicators.Add(rsiType, new { Source = Bars.ClosePrices, Periods = 14 });
Print("Added indicator {0} to the template", indicator.Type.Name);
}
template = api.ChartTemplates.Get("My Template")
rsiType = api.AlgoRegistry.Get("Relative Strength Index", AlgoKind.StandardIndicator)
if template is not None and rsiType is not None:
indicator = template.Indicators.Add(rsiType, api.Bars.ClosePrices, 14)
api.Print(f"Added indicator {indicator.Type.Name} to the template")