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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    72 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X