How to backtest a Pine Script strategy for free, step by step
Paste a Pine Script v5 strategy into Deepwick, set realistic costs and read the results. A step-by-step guide with a strategy you can copy, free during launch.
You can backtest a Pine Script strategy for free in Deepwick, a browser-based charting platform that reads Pine Script v5 code. During launch every feature is free and no card is needed. This guide takes you from an empty account to a backtest you can trust, with a strategy you can copy.
What you need
- A Deepwick account. Sign up with your email, Google or Apple.
- A desktop or laptop browser: the script editor needs a desktop-sized screen.
- A strategy written in Pine Script v5, or the example below.
Step 1: open a chart
After you sign in, and after a short onboarding the first time, you land on a chart. Pick a market with the symbol search, for example BTCUSDT for crypto or EURUSD for forex, then choose the timeframe. The strategy runs on the bars loaded on this chart: 1,000 when it opens, and more as you scroll back.
Step 2: paste your strategy
Click </> Scripts in the chart's toolbar to open the script panel, then paste your code into the editor. A strategy must call strategy(). A script that calls indicator() draws on the chart but has nothing to backtest.
If you don't have one, copy this. It buys when a 20-period EMA crosses above a 50-period EMA, closes on the opposite cross, and keeps a stop two ATRs below the entry price:
//@version=5
strategy("EMA cross with ATR stop", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.1, slippage=2)
fastLength = input.int(20, "Fast EMA", minval=1)
slowLength = input.int(50, "Slow EMA", minval=2)
atrMultiple = input.float(2.0, "ATR stop multiple", minval=0.5, step=0.5)
fast = ta.ema(close, fastLength)
slow = ta.ema(close, slowLength)
stopDistance = ta.atr(14) * atrMultiple
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long", comment="EMA cross down")
if strategy.position_size > 0
strategy.exit("Stop", "Long", stop=strategy.position_avg_price - stopDistance)
plot(fast, "Fast EMA", color=color.teal)
plot(slow, "Slow EMA", color=color.orange)
You can also start from a built-in strategy. The Open… menu in the script panel has RSI Mean Reversion, MACD Crossover, Bollinger Bounce, EMA Trend Following and Donchian Breakout.
Step 3: set realistic costs
Commission and slippage both default to zero, in Deepwick and on TradingView, and a backtest without costs flatters almost every strategy. Set them in strategy():
commission_typeandcommission_value: a percentage of the trade's value (strategy.commission.percent), a fixed amount per order (strategy.commission.cash_per_order) or per contract (strategy.commission.cash_per_contract).slippage: ticks against you on every market and stop fill.initial_capital,default_qty_typeanddefault_qty_value: how much the strategy trades. Deepwick's default capital is 100,000, so set it explicitly if you want to compare results with another platform.
Step 4: run it
Press Run, or Ctrl/Cmd + Enter. If the script has an error, the panel shows the line and the column. The strategy's inputs appear next to the editor, so you can change the EMA lengths or the ATR multiple and run it again without touching the code.
Step 5: read the Strategy Tester
Open the Strategy Tester tab. Above the results Deepwick prints the rules it used: orders fill at the next bar's open, stops and targets along the bar, and gaps at the open. Then come net profit, number of trades, win rate, profit factor, maximum drawdown, Sharpe and Sortino ratios, buy-and-hold return, commission paid and the long and short sides, followed by the equity curve and the list of trades. Click a trade to jump to it on the chart.
Step 6: check it with the Inspector
Open the Inspector tab and hover the bars around a trade. It lists the value of every variable in the script on that bar: the two EMAs, the ATR and the stop distance. If a trade looks wrong, this is where you find out why, without adding plots or log lines.
Step 7: save it, alert on it, share it
Save backtest stores the result in your account. If your script declares alertcondition(), Create alert sends it to email, Telegram, Discord or a webhook. Publish… shares the script with the community.
Before you trust the result
A backtest is one sample of the past. Before you risk money on it:
- Count the trades. A result built on a dozen trades says very little.
- Set part of the history aside. Tune the inputs on the rest, then test once on the part you kept.
- Nudge each input. If the result collapses when a length moves from 20 to 22, you have fitted noise.
- Know the data: Deepwick's crypto bars come from Binance, and its CFD history starts in September 2026.
There is more on this in The overfitting problem in TradingView backtests.
When a script from TradingView doesn't run
request.security()does not stop the script, but it returnsna, so anything built on another timeframe stays empty.label.new()andtable.new()are not available yet; lines and boxes are.- Arguments Deepwick does not use, such as
process_orders_on_close, are ignored: orders always fill at the next bar's open.
The full list of what is supported is in the Deepwick Script reference. And if you are deciding between platforms, here is our honest comparison with TradingView.
— Enrique