PineTS Runtime Engine
The runtime environment executes the transpiled code. It simulates the Pine Script execution model where the script runs once for every bar in the dataset.
Key Components
- PineTS Class: The entry point. Manages the data provider, pagination, and execution loop.
- Context Class: The “Global State” passed to the script. Holds all variables, series data, and namespace instances.
- Series Class: The fundamental data structure wrapping arrays.
Execution Model
PineTS follows a “Push-Based” execution model:
- Load Data: Fetch OHLCV data from a Provider.
- Initialize Context: Create the
$object. - Run Loop:
- For each historical bar:
- Update
context.idx. - Push new OHLCV data into
context.dataarrays. - Execute the user script.
- Grow all user variables (push current value to history).
- Update
- Collect results/plots.
- For each historical bar:
This ensures that close[1] always refers to the data from the previous iteration.