Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.GetClose(0) or Close[0]

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

    Bars.GetClose(0) or Close[0]

    A little confused by this new way to get the same info.

    I'd like to know why this ? which one is more accurate, reliable and fast ?

    Under what conditions should I use or the other?

    Thanks

    #2
    Hello pstrusi,

    Close would take a bars ago value whereas Bars.GetClose takes an absolute barIndex.

    For example the following code in an indicator would print the first close on a chart, and would not change,

    Print(Bars.GetClose(0));

    While the following would print every close starting to from the left moving to the right.
    Print(Close[0]);

    If you were to pass the CurrentBar into GetClose, they would be the same. Please see the following explanation,


    Please let us know if you need further assistance.
    Last edited by NinjaTrader_AlanP; 09-10-2017, 04:31 PM.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AlanP View Post
      Hello pstrusi,

      Close would take a bars ago value whereas Bars.GetClose takes an absolute barIndex.

      For example the following code in an indicator would print the first close on a chart, and would not change,

      Print(Bars.GetClose(0));

      While the following would print every close starting to from the left moving to the right.
      Print(Close[0]);

      If you were to pass the CurrentBar into GetClose, they would be the same. Please see the following explanation,


      Please let us know if you need further assistance.
      Thanks Allan, a very clear and complete answer.

      Regards!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      169 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      326 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      251 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      353 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      180 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X