Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price discrepancy calculating SMA-5 on 1440 minute series

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Price discrepancy calculating SMA-5 on 1440 minute series

    Hello,

    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:

    Click image for larger version

Name:	image.png
Views:	79
Size:	4.4 KB
ID:	1282847


    Here is the indicator on the 60 min chart:

    Click image for larger version

Name:	image.png
Views:	73
Size:	7.1 KB
ID:	1282846



    Thank you in advance!
    Attached Files
    Last edited by tsliepen; 12-19-2023, 01:03 PM. Reason: Edited to include screenshots

    #2
    Hello tsliepen,

    The Calculation setting, TickReplay, the State, and when this is calling Draw.TextFixed() will be a factor here.

    I would recommend printing the BarsInProgress, date, State, and bar time, which will help clarify.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    595 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X