Get started
Introduction
Funnest Script is an open-source (Apache-2.0) language for chart indicators and trading strategies.
A script is plain JavaScript that runs once over all of a chart's bars.
In the Funnest app
The script editor on the trading screen needs nothing installed.
Write a script there and:
- put it on the chart over the candles or in its own pane,
- get an alert when its condition fires,
- run it as paper auto-trading,
- backtest it and see the return, win rate and the deepest drop,
- share it, and try other people’s scripts.
Install
To run the same language in your own code, add the package.
npm i @funnest/scriptPackages
@funnest/scriptThe language: runtime, backtester, trading rules and docs. No dependencies, browser and Node
@funnest/script-cliFrom the terminal: type-check, run on real exchange prices, backtest
@funnest/script-mcpAn MCP server so AI tools like Claude and Cursor read the docs, write, run and fix scripts
skills/funnest-scriptA skill for AI coding agents: how to write, check and fix a script
Your first script
Line 1 says the version, then the script declares itself once and draws.
Every name below is in scope.
//@version=2
indicator({ name: 'My EMA', overlay: true })
const len = input.int('Length', 20, { min: 2 })
plot('EMA', ta.ema(close, len), { color: color.orange })A series is one number per bar.
Do arithmetic on series with
See Rules & mistakes.
Do arithmetic on series with
add, sub, gt… not with + or >.See Rules & mistakes.
Run it in your code
import { execute, backtest } from '@funnest/script'
// bars: { open, high, low, close, volume, time }, a Float64Array each
const result = execute(code, bars)
if (result.ok && result.strategy) {
// candles: [{ time, open, high, low, close }, …]
const test = backtest(candles, result.strategy)
console.log(test.totalReturn, test.winRate)
}