Release notes
Everything that ships in the first release of SahiScript.
Initial release
SahiScript is the scripting language that powers Sahi charts. Every built-in indicator on a Sahi chart is itself a SahiScript program, so whatever they can do, your own scripts can do as well.
A familiar language
SahiScript is compatible with Pine v6 syntax, so scripts written for
other charting platforms generally run with little or no modification.
The //@version=6 header is accepted but not required.
- User-defined functions, user-defined types and methods, enums and tuples
-
if/switch,for,for…inandwhileloops -
Series and persistent state with
varandvarip
Built-in functions
-
Technical analysis — over 60
ta.*functions, covering moving averages (ema,sma,rma,wma,vwma,hma,alma), oscillators (rsi,macd,stoch,cci,mfi,tsi,wpr), bands and channels (bb,kc,supertrend,dmi), volume (obv,vwap,accdist,pvt), statistics (stdev,correlation,linreg,percentile) and structure (pivothigh,pivotlow,highest,lowest,crossover,barssince,valuewhen) -
Math and strings — the full
math.*andstr.*libraries - Collections — arrays, maps and matrices, including typed constructors, sorting, searching and matrix algebra
- Drawing — lines, labels, boxes, tables, linefills and polylines
Inputs
Scripts expose settings through input.int,
input.float, input.bool,
input.string, input.color,
input.source, input.symbol,
input.timeframe, input.session,
input.price, input.time,
input.text_area and input.enum.
input.expiry is unique to Sahi: it allows a script to
take a derivatives expiry as a setting, which has no equivalent on
other platforms.
Market data
-
request.securityandrequest.security_lower_tffor multi-timeframe and multi-symbol analysis -
request.instrumentandrequest.instrument_lower_tffor Sahi instruments -
Options data through
request.pcr,request.oi_change_pcrandrequest.volume_pcr
The editor
Scripts are written in the built-in code editor, which provides autocomplete, hover documentation, signature help, and live error and warning reporting as you type. A script can be applied to the chart without leaving the editor, and the editor itself can be docked beside or below the chart while you work.
Performance
Scripts execute within milliseconds, but scripts using
request.security can trigger network calls to fetch market
data for the requested symbol and timeframe, so results may take
longer to load.
Not supported yet
The first release covers indicators. The following are recognised by the language but are not available to write scripts against yet, and are planned for a future release.
-
Strategies —
strategy()scripts, order placement and backtest reporting are not supported yet. Scripts in this release are indicators: they calculate and draw, but they do not simulate trades. -
Libraries — scripts cannot yet be published with
library()or reused from another script withimport. Each script stands on its own for now. -
Alerts —
alert()andalertcondition()are accepted so that scripts written elsewhere parse cleanly, but they do not yet trigger notifications.
The complete language reference is still being written. In the meantime, the editor's autocomplete and hover documentation are the most thorough reference available, and the FAQ answers the most common questions.