I'm adding a secondary dataseries to plot an SMA of 1440 minutes on a 5 minutes chart. I know that this is possible to do manually by loading a secondary chart in the background but I need to do it with an indicator for reasons that don't matter now.
The problem is that if I then create a chart that is 1440 minutes and load the normal SMA indicator in that chart de average on the 5 minute chart that corresponds to the 1440 minute dataserias is diferent than the one on the 1440 minute chart.
I'll simplify the code here as an example.
if (State == State.SetDefaults) { AddPlot(new Stroke(Brushes.Yellow, DashStyleHelper.Dot, anchoDefecto), PlotStyle.Line, "SMA200_1440"); } else if (State == State.Configure) { int daysLoaded = Bars.ToDate.Subtract(Bars.FromDate).Days; AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, daysLoaded, null, null); } protected override void OnBarUpdate() { if(CurrentBars[0] >= 0 && CurrentBars[1] >= 0){ SMA200_1440[0] = SMA(Closes[1], 200)[0]; } }
Then I load an SMA with period 200 on a 1440 minute chart.
I'd expect both SMA's to show the same but they don't, there is allways a small diference. Any ideas why this happens?
I should add that this happens in some markets more than others, as an example I'm using CL 9-19 (Crude Oil Futures)
Comment