I am new to NinjaScript and am developing an indicator that displays the 1440 minute 5-day SMA on all charts of an asset. In my code, I add a data series in State.Configure with BarsPeriodType = Minute and the period = 1440 minute bars. The problem is that the SMA-5 price displays differently when I display the indicator on the 1440 minute chart vs the 60min chart. Given that I am specifying in the code to use the 1440 minute series, I would expect the calculation to be the same on the 1440 min chart and the 60 min chart.
Could someone provide insight into why this discrepancy exists and if possible, suggest a solution? Here is the code for where I add the series and calculate the 5-SMA:
else if (State == State.Configure)
{
// Add a 1440 min series
if (BarsArray.Length == 1)
AddDataSeries(Data.BarsPeriodType.Minute, 1440);
}
else if (State == State.DataLoaded)
{
// Initialize SMA series
smaValue = SMA(BarsArray[1], 5);
}
Edit:
Here is the indicator on the 1440 min chart:
Here is the indicator on the 60 min chart:
Thank you in advance!
Comment