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

Mistake in Help Guide?

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

    Mistake in Help Guide?

    I stumbled upon this earlier today.

    &

    both say
    HighestBar(Close, Bars.BarsSinceSession - 1 is "the number of bars ago for the highest close of the current session"
    &
    Lowest(SMA(20), Bars.BarsSinceSession - 1 is "the number of bars ago for the lowest SMA(20) value of the current session"

    It's been to my experience that it's actually Bars.BarsSinceSession + 1 that does the trick. The reason I came across this is because I wanted to draw a line for the previous days high without having to use multiple time frames. When I used Bars.BarsSinceSession - 1 it was under the previous day's high if the high was on either the first or second bar of the session.

    Please let me know if I'm the one who missed something and need to fix my code.

    Thanks

    #2
    Bars.BarsSinceSession returns you the number of bars since the session start. On the first bar of the session this property will be 0. On the next bar it will be 1. Now when you are say on bar 20 and you wanted to go check the previous 20 bars through a lookback period you would only need to do 19 because you are already on the 20th bar. Does that make sense? You pass in Bars.BarsSinceSession - 1 to get 19 and you evaluate it across the last 19 bars. If you did a lookback of Bars.BarsSinceSession that would be 20 bars back and that would actually bring you 1 bar into the previous session. Bars.BarsSinceSession + 1 would bring you 2 bars into the previous session.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by JonesJoker, 04-22-2024, 12:23 PM
    6 responses
    32 views
    0 likes
    Last Post JonesJoker  
    Started by GussJ, 03-04-2020, 03:11 PM
    12 responses
    3,239 views
    0 likes
    Last Post Leafcutter  
    Started by AveryFlynn, Today, 04:57 AM
    0 responses
    5 views
    0 likes
    Last Post AveryFlynn  
    Started by RubenCazorla, 08-30-2022, 06:36 AM
    3 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Started by f.saeidi, Yesterday, 12:14 PM
    9 responses
    25 views
    0 likes
    Last Post f.saeidi  
    Working...
    X