Skip to content
All library documents

Configurable TradingView Backtest Engine with Crossovers and Risk Controls

Article Strategy library · Author: Zer3192

Summary

This Pine Script template separates strategy signals from the mechanics of backtesting. Users supply long and short entry and exit conditions; the example uses a 50-period and 200-period simple moving average crossover. Inputs can enable either direction, set the test dates, and provide take-profit and stop-loss percentages. A zero percentage disables the corresponding exit threshold.

The engine submits orders during the selected test period, sizes entries as a share of equity, and plots entry, stop, and target levels. It also uses order comments for configurable bot commands and tracks entry and exit states to limit repeated signals. The published setup tests BTC/USDT on Binance over a specified period, but provides no performance statistics. Results will depend on the user's conditions and settings; the template's mechanics and example alone do not demonstrate profitability or account for every live-execution detail.

Key ideas

  • The template lets users supply separate long and short entry and exit conditions.
  • The example strategy uses a fast and slow simple moving average crossover.
  • Inputs control the test window, trade directions, and percentage take-profit and stop-loss levels.
  • Orders are restricted to the selected test period, and position levels are plotted on the chart.
  • The document gives a BTC/USDT test setup but no strategy performance results.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.