Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    192 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,234 views
    0 likes
    Last Post xiinteractive  
    Working...
    X