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

Question: IsFirstBarOfSessionByIndex()

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

    Question: IsFirstBarOfSessionByIndex()

    Hi,
    I tested, how method Bars.IsFirstBarOfSessionByIndex() works,
    but it seems it does not work, but returns true for each bar.

    I tested on M15 timeframe, with this simple code:
    Code:
     
    [FONT="Courier New"]protected override void OnBarUpdate()
    {
          /[SIZE="2"][COLOR="DimGray"]/ Check, if current bar is first bar of session[/COLOR][/SIZE]
          Value[0] = Bars.I[COLOR="Red"]sFirstBarOfSessionByIndex(0)[/COLOR] ? 1 : 0;
    }[/FONT]
    Result is, that all values are 1 = that means, it says each bar is first bar of session,
    which is wrong obviously.

    When I replace it with IsFirstBarOfSession, then it works fine.
    Code:
     
    [FONT="Courier New"]protected override void OnBarUpdate()
    {
          Value[0] = Bars.[COLOR="Green"]IsFirstBarOfSession [/COLOR]? 1 : 0;
    }[/FONT]
    Can you explain, why the IsFirstBarOfSessionByIndex(idx) method does not work
    and return value 'true' everytime ?
    Last edited by misova; 11-19-2016, 03:35 AM.

    #2
    Try this

    Code:
    protected override void OnBarUpdate()
    {
          // Check, if current bar is first bar of session
          Value[0] = Bars.IsFirstBarOfSessionByIndex(CurrentBar) ? 1 : 0;
    }


    http://ninjatrader.com/support/helpG...ionbyindex.htm

    Comment


      #3
      Thank you ren37,
      you are completely right.

      Documentation is quite insufficient / misleading.
      It suggests using indexes, but do not tell from which side

      Standard and clear vocabulary should be used across whole documentation,
      to clearly differentiate, between indexing from left side vs right side of the data-series.

      Now, it is mixed up. Everything is just some indexing, but requirements differ across various methods and properties. Maybe there is some system, but it is not clear for me from the docs...
      Last edited by misova; 11-20-2016, 09:00 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cre8able, Yesterday, 04:22 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by stafe, 04-15-2024, 08:34 PM
      5 responses
      28 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by StrongLikeBull, Yesterday, 04:05 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Mestor, 03-10-2023, 01:50 AM
      14 responses
      375 views
      0 likes
      Last Post z.franck  
      Started by molecool, 10-09-2017, 10:48 AM
      5 responses
      1,621 views
      0 likes
      Last Post trader-ap  
      Working...
      X