1. Execution Model
- v1 (Legacy)
- v2 (Current)
- Execution was line-by-line and evaluated expressions directly
- Developers had to manually assemble time-aligned series using:
buildTimeseries(...)mergeTimeseries(...)matchTimestamp(...)timeseries(...)constructor
- This was unintuitive and often led to performance bottlenecks
2. Keyword Arguments (kwargs)
- v1 (Legacy)
- v2 (Current)
Functions accepted only positional arguments, making scripts harder to read and maintain.
3. Compiler Improvements
- v1 (Legacy)
- v2 (Current)
- Most errors surfaced only at runtime
- Developers had to debug by trial and error
4. Data Subscriptions
- v1 (Legacy)
- v2 (Current)
All data sources handled via the generic
source(...) function.5. Technical Indicator Functions
- v1 (Legacy)
- v2 (Current)
- Functions like
rsi,emareturned a full timeseries - Developers often misunderstood how to work with them, leading to redundant or incorrect code
6. Field Accessors
- v1 (Legacy)
- v2 (Current)
Accessing fields from data was clunky and inconsistent.
7. Reverse Index Access
- v1 (Legacy)
- v2 (Current)
- Forward-style indexing only (oldest first)
- Hard to get the latest values directly
8. Function Definitions
- v1 (Legacy)
- v2 (Current)
No support for custom functions.
9. Loops
- v1 (Legacy)
- v2 (Current)
No support for looping constructs.
10. Plot Functions
- v1 (Legacy)
- v2 (Current)
Limited plotting functions (
plotLine, plotBar).11. Standard Library
- v1 (Legacy)
- v2 (Current)
Minimal helper set.
Summary
kScript v2 delivers major improvements over v1:Per-bar execution eliminates manual time alignment
Keyword arguments make functions clear and self-documenting
Compile-time checking prevents most runtime surprises
Dedicated subscription functions improve clarity
Technical indicators return scalars per bar instead of entire timeseries
Field accessors make OHLCV data ergonomic
Reverse indexing gives direct access to the latest data
Functions and loops enable modular and expressive code
Extended plot functions and library unlock richer visualization and analysis