Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Which one is the correct code? (draw 1H pivot on 5mn chart)

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

    Which one is the correct code? (draw 1H pivot on 5mn chart)

    Hi,

    Suppose my current chart is a 5 mn chart and I want to draw the current hourly pivot point and the previous one? Which one is the correct code?

    Thanks!

    Code:
    AddDataSeries(Instrument.FullName, BarsPeriodType.Minute ,60);
    var pivot1 = (Highs[1][0] + Lows[1][0] + Closes[1][0]) / 3;
    var pivot2 = (Highs[1][1] + Lows[1][1] + Closes[1][1]) / 3;
    
    OR
    
    AddDataSeries(Instrument.FullName, BarsPeriodType.Minute ,60);
    var pivot1 = (Highs[1][1] + Lows[1][1] + Closes[1][1]) / 3;
    var pivot2 = (Highs[1][2] + Lows[1][2] + Closes[1][2]) / 3;

    #2
    Hello vindiou,

    Thanks for writing in.

    Your BarsInProgress reference is correct. As for the barsAgo reference, the syntax from your first example would be correct. 0 is the current bar, and 1 is the previous bar. For Calculate.OnEachTick, 0 is the developing bar, and 1 is the bar that had just closed.

    Keep in mind, AddDataSeries() must be added to State.Configure and referencing Instrument from State.Configure may not always be guaranteed. In such cases it would be recommended to use the AddDataSeries() overload that does not require an Instrument name so the primary Instrument is properly referenced.

    I've included links for AddDataSeries() and the Multi-Series NinjaScript public documentation. This is useful information to reference for Multi-Series NinjaScript syntax and the caveats behind using AddDataSeries().

    AddDataSeries() - https://ninjatrader.com/support/help...dataseries.htm

    Multi-Series NinjaScripts - https://ninjatrader.com/support/help...nstruments.htm

    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X