Hello,
I am testing a new strategy on 8.0.16.2 64-bit. Instead of getting the strategy to call the indicator I already wrote, I thought it would be more efficient to port the simple code directly into the strategy. All it does is calculate a pivot. The confusing thing is, with the original indicator added to the chart and the strategy applied, even though they should be using the same code cut and pasted from the indicator to the strategy, and include the same additional data-series, the calculations are different. I am so far scratching my head as to why.
In the indicator and strategy, a 4 hour data series is added in state.configure (AddDataSeries(Data.BarsPeriodType.Minute, 240).
So, we have the primary data series on the chart and the additional one.
In both the indicator and strategy a simple calculation is done in the additional series, such as the following
// do the calcs for the pivot bar series if (BarsInProgress == 1) { if (CurrentBar < 2) return; // we only update the pivots once we have a full prior bar if (IsFirstTickOfBar) { currentClose = Close[0]; currentHigh = High[0]; currentLow = Low[0]; BarClose = Close[1]; BarHigh = High[1]; BarLow = Low[1]; // calculate pivot points pp = (BarHigh + BarLow + BarClose) / 3;
And the pp is plotted in the indicator, and on the strategy, I just output the value and some text at the value location.
The problem is, in the indicator and strategy end up plotting wildly different values and I cannot figure out why. Should they not be the same? It is perhaps that the strategy, unlike the indicator is not processing the historical data (i.e. not starting it's calculations from the start of the chart, per the indicator)?