Skip to content

Calculate Method

Calculate

Summary

Calculate the value(s) of indicator for the given index.

Signature

1
public abstract void Calculate(int index)

Parameters

Name Type Description
index int The index of calculated value.

Return Value

void

Declaring Type

cAlgo.API.Indicator

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: March 23, 2023