Loading Data ...
This demo loads and execute native pine script from this file
cross-signal.pine, then uses
PineTS to execute it and get the results.
The results are then used by QFChart to render the chart.
Loading Data ...
Pine Script is TradingView's proprietary scripting language designed for creating custom technical indicators and trading strategies. It provides a simple, intuitive syntax that allows traders to express complex mathematical calculations and conditional logic without needing extensive programming knowledge. Pine Script is widely used by millions of traders worldwide to build, test, and deploy custom trading tools.
PineTS is a groundbreaking JavaScript/TypeScript library that brings Pine Script execution to the web.
PineTS is a runtime transpiler that executes Pine Script code directly in the browser or Node.js environment.
This demo showcases PineTS's ability to:
This demo executes a Cross Signal indicator written in pure Pine Script. The indicator detects when a fast moving average crosses above or below a slow moving average, generating buy and sell signals. Key features:
The execution flow demonstrates the full PineTS + QFChart integration:
cross-signal.pine file via HTTPBehind the scenes, this demo showcases advanced capabilities:
ta.*, math.*, plot(), and other namespacesHere's a simplified version of what the Cross Signal indicator looks like:
//@version=5
indicator("Cross Signal", overlay=true)
// Input parameters
fastLength = input.int(9, "Fast MA Length")
slowLength = input.int(21, "Slow MA Length")
// Calculate moving averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Detect crossovers
bullCross = ta.crossover(fastMA, slowMA)
bearCross = ta.crossunder(fastMA, slowMA)
// Plot MAs
plot(fastMA, "Fast MA", color.blue)
plot(slowMA, "Slow MA", color.red)
// Plot signals
plotshape(bullCross, "Buy", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(bearCross, "Sell", shape.triangledown, location.abovebar, color.red, size=size.small)
To execute your own Pine Script files:
// Load Pine Script source
const response = await fetch('your-indicator.pine');
const pineScript = await response.text();
// Execute with PineTS
const pineTS = new PineTS(PineTS.Provider.Binance, 'BTCUSDT', '1d', 500);
const { result, plots, marketData } = await pineTS.run(pineScript);
// Visualize with QFChart
const chart = new QFChart.QFChart(container, { title: 'My Indicator' });
chart.setMarketData(marketData);
chart.addIndicator('My Indicator', plots, { isOverlay: true });