Multiple values for the same time period?
Multiple values for the same time period?
14 Dec 2012, 17:59
I have a print statement in an indicator, calculate event:
Print("{0,20:MM/dd/yyyy HH:mm}{1,25}{2,25}{3,25}{4,25}",opentime1,PlotCount,MA1_MA2_1,MA1Slope1,"Trend Up Buy");
How come when I run the robot, the log indicates 2 index values for the same time period. in this case 14:24 has 2007 and 2008. I have a count that simple counts up in the calculate event.
PlotCount++;
But this makes no sence...
Replies
lec0456
14 Dec 2012, 22:49
Here is the modified Sample SMA I am using
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true)] public class SampleSMA : Indicator { [Parameter] public DataSeries Source { get; set; } [Parameter(DefaultValue = 14)] public int Periods { get; set; } [Output("Main", Color = Colors.Turquoise)] public IndicatorDataSeries Result { get; set; } private int PlotCount; protected override void Initialize() { PlotCount=0; } public override void Calculate(int index) { double sum = 0.0; DateTime opentime1 = MarketSeries.OpenTime[index]; for (int i = index - Periods + 1; i <= index; i++) { sum += Source[i]; } Result[index] = sum / Periods; Print("{0,20:MM/dd/yyyy HH:mm}{1,20}{2,20}{3,20}{4,20:#.000000#}",opentime1,index, PlotCount, Result[index],"indicator"); PlotCount++; } } }
@lec0456
lec0456
14 Dec 2012, 23:02
( Updated at: 21 Dec 2023, 09:20 )
Here is a better example of the problem: by taking out the print statement in the robot and replacing it with just printing "onBar". You can see that at the same time interval the indicator is printing twice with different values, one before the onbar event and one after???
@lec0456
lec0456
14 Dec 2012, 22:48
Here is the robot which will print 2 indicator calculations for each on bar event
@lec0456