Podcast
Questions and Answers
How often does a Pine script execute on historical bars?
How often does a Pine script execute on historical bars?
What does the 'close' built-in variable return when a Pine script runs on a realtime bar?
What does the 'close' built-in variable return when a Pine script runs on a realtime bar?
How does the execution of strategies differ from indicators in Pine scripts?
How does the execution of strategies differ from indicators in Pine scripts?
What happens when a Pine script executes on historical bars?
What happens when a Pine script executes on historical bars?
Signup and view all the answers
What identifies the last bar in a Pine script execution cycle on the chart?
What identifies the last bar in a Pine script execution cycle on the chart?
Signup and view all the answers
Study Notes
Pine Script Execution
- Pine Script runs in a continuous loop, executing on each chart bar.
- The execution order is from left to right across the chart's bars.
- Historical bars are closed bars on the chart, where the script has already run.
- The realtime bar is the currently open bar in the chart.
- The script runs once per bar, including realtime bars, until the bar closes.
- If a price or volume change is detected, the script executes again for that realtime bar.
- After a realtime bar closes, it becomes an elapsed realtime bar.
- The script doesn't recalculate on historical bars when the price/volume changes; it only executes once per historical bar.
Script Execution on Bar Types
- When running on a historical bar, the
close
built-in variable shows the close price of that bar. - When running on the realtime bar,
close
represents the current price until the bar closes.
Strategy vs. Indicator Execution
- Strategies usually execute only once on the realtime bar's close.
- Strategies can be configured for execution on every price/volume change, if necessary.
- Indicators are executed differently than strategies.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Explore the intricacies of how Pine Script executes on charts, including its behavior on historical and realtime bars. This quiz covers the execution order, the differences in script execution for strategies versus indicators, and the implications of bar types on script performance.