Skip to main content
All guides

PineScript Strategies

PineScript backtesting

Most backtests look great until fees, slippage and real fills show up. This guide takes you from your first Pine script to a strategy test you can trust before you size it.

What to know first

  1. 01

    Set commission and slippage before you look at a single result. A zero-fee backtest is not a backtest.

  2. 02

    Watch for lookahead. Any logic that acts on a bar before it closes will make the test look better than live trading can.

  3. 03

    Twenty trades prove nothing. Look for a sample large enough to cover trending, ranging and volatile conditions.

Academy lessons

From the PineScript Strategies module. Full lessons are in the Academy, which is included with Pro.

  1. 01

    Introduction to PineScript

    The Pine Editor, the compiler, and the structure every script shares.

  2. 02

    Strategy fundamentals

    The strategy() function, order functions, and every Strategy Tester setting that changes results.

  3. 03

    Backtesting and performance analysis

    Reading results, monthly tables, drawdown duration, and where the Strategy Tester misleads.

  4. 04

    Your first strategies

    RSI, breakout and pin bar strategies built end to end, with exits and risk rules.

Further reading

Free tools