SWAMI Average Indicator
Created at 09 Nov 2013, 00:46
SWAMI Average Indicator
09 Nov 2013, 00:46
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)] public class RelativeStrengthSWAMI : Indicator { [Parameter(DefaultValue = 14)] public int MaxLookback { get; set; } [Parameter(DefaultValue = 2)] public int MinLookback { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } private RelativeStrengthIndex RSIValue; public override void Calculate(int index) { int Period = MaxLookback - MinLookback + 1; double TotalSum = ReturnSum(index); Result[index] = TotalSum / Period; } public double ReturnSum(int argIndex) { double Sum = 0.0; for (int i = MinLookback; i <= MaxLookback; i++) { RSIValue = Indicators.RelativeStrengthIndex(MarketSeries.Close, i); Sum += RSIValue.Result[argIndex]; } return Sum; } } }
Could someone take a look at this code? It's not returning a value.
Basically I want to retrieve the relative strength values of multiple lookback periods and take the average. Right now I am not getting anything.
Any help would be great, thanks!
Replies
Hyperloop
11 Nov 2013, 22:14
Yes I understand you could do that. I don't think that would serve its purpose in this code.
@Hyperloop
daemon
11 Nov 2013, 10:12
I'm not 100% sure about this but I think you can only initialize indicators in the Initialize method.
@daemon