Guide › The chart
Scripts and backtests
The Script button opens an editor for writing your own indicators and strategies in a Python-like language. Prices are whole series, so sma(close, 20) is a line you can plot, and crossover(a, b) is true on the bars where a crosses above b. The Reference button lists every function.
Add strategy(long_entry=..., long_exit=..., stop=..., target=..., fee=...) and the right-hand panel shows a backtest: number of trades, share of winners, average result per trade, profit factor, drawdown, and the result of simply holding. Orders are filled at the next bar's open and fees are charged, so the test cannot use information that was not yet known.
Read the result carefully. The examples include two lessons from our own tests: a rule that won 62% of its trades and a rule that won 87%, both of which lost money, because their losing trades were far larger than their winners. Look at the average result per trade and the drawdown, test other symbols and periods, and be suspicious of any rule tuned until it fits the past.