pinescript, in chart.point.new time, index, price does index is back from current of…
- User
pinescript, in chart.point.new time, index, price does index is back from current of from 0 to current which is newest
Assistant
In PineScript's
chart.point.new(), theindexparameter works backwards from the current bar.Here's how the indexing works:
- Current bar (newest): index = 0
- Previous bar: index = 1
- Bar before that: index = 2
- And so on...
So if you want to create a point on:
- The current bar:
chart.point.new(time, 0, price) - 5 bars ago:
chart.point.new(time, 5, price) - 10 bars ago:
chart.point.new(time, 10, price)
This is different from
bar_index(the built-in variable), which counts forward from 0 at the first bar of the dataset to the current bar.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.