ChartIndicators Summary The interface representing a chart indicator instances collection.Provides properties and events that allow for accessing various information about indicators attached to a chart.
Signature
public abstract interface ChartIndicators
Namespace cAlgo.API
Examples Example 1 (C#) Example 2 (PYTHON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 using cAlgo.API ;
namespace cAlgo.Robots ;
[Robot(AccessRights = AccessRights.None)]
public class TestExample : Robot
{
protected override void OnStart ()
{
foreach ( var chartIndicator in ChartIndicators )
{
Print ( $"Name: {chartIndicator.Name} | Type: {chartIndicator.Type} | InstanceId: {chartIndicator.InstanceId} | Bar Outputs #: {chartIndicator.BarOutputs.Count} | Line Outputs #: {chartIndicator.LineOutputs.Count}" );
}
ChartIndicators . IndicatorAdded += args => Print ( $"Chart indicator added, {args.Indicator.Name}" );
ChartIndicators . IndicatorRemoved += args => Print ( $"Chart indicator removed, {args.Indicator.Name}" );
ChartIndicators . IndicatorModified += args => Print ( $"Chart indicator modified, {args.Indicator.Name}" );
var sma = ChartIndicators . Add ( "Simple Moving Average" , Bars . OpenPrices , 100 );
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14 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 ):
for chartIndicator in api . ChartIndicators :
print ( f "Name: { chartIndicator . Name } | Type: { chartIndicator . Type } | InstanceId: { chartIndicator . InstanceId } | Bar Outputs #: { chartIndicator . BarOutputs . Count } | Line Outputs #: { chartIndicator . LineOutputs . Count } " )
api . ChartIndicators . IndicatorAdded += lambda args : print ( f "Chart indicator added, { args . Indicator . Name } " )
api . ChartIndicators . IndicatorRemoved += lambda args : print ( f "Chart indicator removed, { args . Indicator . Name } " )
api . ChartIndicators . IndicatorModified += lambda args : print ( f "Chart indicator modified, { args . Indicator . Name } " )
sma = api . ChartIndicators . Add ( "Simple Moving Average" , api . Bars . OpenPrices , 100 )
Methods Add (2) Add (1 of 2)
Summary
Adds a new indicator to a chart.
Signature
public abstract ChartIndicator Add ( string name , object [] parameterValues )
Parameters
Name Type Description name string The name of an indicator. parameterValues object[] The indicator parameter values or an anonymous object that contains indicator parameter values.
Return Value
ChartIndicator
Examples
Add (2 of 2)
Summary
Adds a new indicator to a chart.
Signature
public abstract ChartIndicator Add ( IndicatorType type , object [] parameterValues )
Parameters
Name Type Description type IndicatorType The type of Indicator, you can get IndicatorType from AlgoRegistry. parameterValues object[] The indicator parameter values or an anonymous object that contains indicator parameter values.
Return Value
ChartIndicator
Examples
See Also
Remove Summary
Removes an indicator from a chart.
Signature
public abstract bool Remove ( ChartIndicator indicator )
Parameters
Name Type Description indicator ChartIndicator The ChartIndicator to be removed from a chart.
Return Value
bool
Properties Item Signature
public abstract ChartIndicator Item { get ;}
Return Value
ChartIndicator
Standard Summary
Gets the list of chart standard indicators.
Signature
public abstract IReadonlyList < ChartIndicator > Standard { get ;}
Return Value
IReadonlyList
Custom Summary
Gets the list of chart custom indicators.
Signature
public abstract IReadonlyList < ChartIndicator > Custom { get ;}
Return Value
IReadonlyList
Count Summary
Gets the number of all indicators attached to a chart.
Signature
public abstract int Count { get ;}
Return Value
int
Events IndicatorAdded Summary
Occurs when a new indicator is added to a chart.
Signature
public abstract event Action < ChartIndicatorAddedEventArgs > IndicatorAdded ;
IndicatorRemoved Summary
Occurs when an indicator is removed from a chart.
Signature
public abstract event Action < ChartIndicatorRemovedEventArgs > IndicatorRemoved ;
IndicatorModified Summary
Occurs when an indicator attached to a chart is modified.
Signature
public abstract event Action < ChartIndicatorModifiedEventArgs > IndicatorModified ;