Announcement

Collapse
No announcement yet.

Barstate_newbar

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

  • Barstate_newbar

    if barstate is newbar, does close() now reference the last price of the newly forming bar. If you want to reference the most recently completed bar your must use close(-1)? If you wish to base your actions on completed bars is this correct??
    TIA, Bob

  • #2
    Bob:

    That's how I have done it. If getBarState() == BARSTATE_NEWBAR, that means a new bar is forming and if I want the close of the bar that just completed, I need to use close(-1).

    Chris

    Comment


    • #3
      You are correct, though in practice the difference in price (if any) between close(-1) on a NEWBAR and close(0) will be very, very small...so you could get away with doing it either way.

      Since I don't think there is any additional overhead for close(-1) however, you might as well do it the correct way.

      G
      Garth

      Comment

      Working...
      X