Quick Translation#

Pine ScriptQuantScript
Implicit per-bar executiondf.forEach((frame) => { ... })
close, volume (implicit globals)frame.close, frame.volume (explicit)
var x = 0 (persists across bars)let x = 0; declared outside the loop
na (missing value)null (standard JS)
Runs only in TradingView UIquantscript run strategy.qs --mode backtest

Side-by-Side Comparisons#

Basic Structure

Pine Script

//@version=5
indicator("My Indicator")
plot(close)

QuantScript

indicator("My Indicator");
df.forEach((frame) => {
    chart.plot(frame.close, "Close");
});

Variables

Pine Script

myVar = 10
const PI = 3.14159

QuantScript

let myVar = 10;
const PI = 3.14159;

Simple Moving Average

Pine Script

smaValue = ta.sma(close, 20)
plot(smaValue, "SMA", color.blue)

QuantScript

df.forEach((frame) => {
    let smaValue = ta.sma(frame.close, 20);
    chart.plot(smaValue, "SMA", "#0000FF");
});

RSI Indicator

Pine Script

rsiValue = ta.rsi(close, 14)
hline(70, "Overbought")
hline(30, "Oversold")
plot(rsiValue, "RSI")

QuantScript

df.forEach((frame) => {
    let rsi = ta.rsi(frame.close, 14);
    chart.hline(70, "Overbought");
    chart.hline(30, "Oversold");
    chart.plot(rsi, "RSI");
});

Conditional Logic

Pine Script

if close > open
    label.new(bar_index, high, "Bullish")

QuantScript

df.forEach((frame) => {
    if (frame.close > frame.open) {
        console.log("Bullish bar");
    }
});

Strategy Entry & Exit

Pine Script

strategy("My Strategy")
if ta.crossover(ta.sma(close, 10), ta.sma(close, 20))
    strategy.entry("Long", strategy.long)
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 20))
    strategy.close("Long")

QuantScript

strategy("My Strategy");

df.forEach((frame) => {
    let fast = ta.sma(frame.close, 10);
    let slow = ta.sma(frame.close, 20);

    if (ta.crossover(fast, slow))
        strategy.entry("Long", "long");
    if (ta.crossunder(fast, slow))
        strategy.close("Long");
});

MACD Indicator

Pine Script

[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
plot(macdLine, "MACD", color.blue)
plot(signalLine, "Signal", color.red)
plot(hist, "Histogram", color.green)

QuantScript

df.forEach((frame) => {
    let [macd, signal, hist] = ta.macd(frame.close, 12, 26, 9);
    chart.plot(macd, "MACD", "#0000FF");
    chart.plot(signal, "Signal", "#FF0000");
    chart.plot(hist, "Histogram", "#00FF00");
});

Bollinger Bands

Pine Script

[lower, middle, upper] = ta.bb(close, 20, 2)
plot(lower, "Lower Band")
plot(middle, "Middle Band")
plot(upper, "Upper Band")

QuantScript

df.forEach((frame) => {
    let [lower, middle, upper] = ta.bbands(frame.close, 20, 2);
    chart.plot(lower, "Lower Band");
    chart.plot(middle, "Middle Band");
    chart.plot(upper, "Upper Band");
});

Key Translation Notes

  1. Frame iteration: Pine Script automatically iterates bar-by-bar. QuantScript requires explicit df.forEach((frame) => { ... }).
  2. Variable access: In Pine Script, you use close directly. In QuantScript, use frame.close inside the loop.
  3. Historical references: Pine uses close[1]. QuantScript uses the same syntax: close[1].
  4. Colors: Pine uses color.blue. QuantScript uses hex colors: "#0000FF".
  5. Function namespaces: Both use ta. for technical analysis functions, but syntax may differ slightly.
  6. Semicolons: Optional in QuantScript but recommended for clarity.

Feature Coverage#

QuantScript is actively implementing Pine Script V6 features. Here's the current coverage by category:

CategoryCoverageStatus
ta.* Technical Indicators35 / ~100+ functions (~35%)In Progress
math.* Math Functions24 / ~40 functionsMostly Complete
str.* String Functions17 / ~25 functionsMostly Complete
array.* Array Functions28 / ~50 functionsIn Progress
strategy.* Trading8 / ~25 functionsIn Progress
chart.* Drawing System5 basic functionsIn Progress
Operators & Control FlowAll core operators, if/for/whileComplete
Type SystemDynamic typing (no annotations)Planned
Drawing Objects (line, label, table)Not yet implementedPlanned
Multi-symbol (request.security)Not yet implementedPlanned

Priority Implementation Roadmap