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 cre8able, 02-11-2023, 05:43 PM
      3 responses
      234 views
      0 likes
      Last Post rhubear
      by rhubear
       
      Started by frslvr, 04-11-2024, 07:26 AM
      8 responses
      111 views
      1 like
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      10 responses
      44 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by rocketman7, Today, 09:41 AM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by traderqz, Today, 09:44 AM
      2 responses
      10 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X