Skip to content

Indicator

Summary

Base class for Indicators.

Remarks

Contains all necessary market information, provides access to built-in indicators and provides framework for convenient indicators' creation.

Signature

1
public abstract class Indicator : Algo

Namespace

cAlgo.API

Methods

Name Description
Calculate Calculate the value(s) of indicator for the given index.
ToString The name of the indicator derived class.

Properties

Name Description
IsRealTime { get; }
IsLastBar { get; } Returns true, if Calculate is invoked for the last bar
IndicatorArea { get; } Defines the area where the indicator is placed.
Account { get; } Contains information of the current account.

Examples

1
2
3
4
5
6
 //...
 public override void Calculate(int index)
 {
     //This is where we place our indicator's calculation logic.
 }
 //...
1
2
3
4
5
6
 //...
 protected override void Initialize()
 {
 //Place your Initialization logic here
 }
 //...
1
2
3
4
5
6
7
8
9
 private IndicatorDataSeries input;
 protected override void Initialize()
 {
     input = CreateDataSeries();
 }
 public override void Calculate(int index)
 {
     input[index] = (MarketSeries.Close[index] + MarketSeries.Open[index]) / 2;
 }
1
2
3
4
5
6
7
8
9
 //...
 public override void Calculate(int index)
 {
     if (IsRealTime)
     {
         //Place the code-logic that you want to be calculated on incoming live data
     }
 }
 //...

Last update: July 1, 2022

Comments