Iterate
Created at 08 Sep 2019, 18:31
Iterate
08 Sep 2019, 18:31
Hello Panagiotis,
How to iterate throught IndicatorDateSeries collection of a custom indicator? Using ForEach leads to this error:
Error CS1579: foreach statement cannot operate on variables of type 'cAlgo.API.IndicatorDataSeries' because 'cAlgo.API.IndicatorDataSeries' does not contain a public definition for 'GetEnumerator'
private Fractals i_fractal; protected override void OnStart() { i_MA_slow = Indicators.MovingAverage(MarketSeries.Close, ma_slow_period, MovingAverageType.Simple); i_MA_fast = Indicators.MovingAverage(MarketSeries.Close, ma_fast_period, MovingAverageType.Simple); daily_series = MarketData.GetSeries(TimeFrame.Daily); i_MA_daily = Indicators.MovingAverage(daily_series.Close, 50, MovingAverageType.Simple); i_ADXR = Indicators.DirectionalMovementSystem(20); i_RSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, 20); i_fractal = Indicators.GetIndicator<Fractals>(fractal_period); Print("up:" + i_fractal.UpFractal); Print("down: " + i_fractal.DownFractal); foreach (double price in i_fractal.UpFractal) { } }
Printing the variables showing this:
08/09/2019 17:21:45.101 | down: IndicatorDataSeries (Count: 1992, LastValue: 1.10201)
08/09/2019 17:21:45.101 | up:IndicatorDataSeries (Count: 1970, LastValue: 1.10845)
Also this doean't work as well:
double[] up = i_fractal.UpFractal as double[];
Replies
sifneosfx
09 Sep 2019, 15:45
RE:
Thanks!
Panagiotis Charalampous said:
Hi sinfeosfx,
Just use a for loop
for (int i = 0; i < i_fractal.UpFractal.Count; i++) { var price = i_fractal.UpFractal[i]; }Best Regards,
Panagiotis
@sifneosfx
PanagiotisCharalampous
09 Sep 2019, 11:18
Hi sinfeosfx,
Just use a for loop
Best Regards,
Panagiotis
@PanagiotisCharalampous