OPEN-SOURCE SCRIPT

SMA Backtest Optimizer [Mr_Rakun]

750
The SMA Backtest Optimizer is a powerful Pine Script tool designed to systematically analyze and compare various Simple Moving Average (SMA) periods to identify the most profitable configuration for trading strategies. This indicator tests multiple SMA periods (from 10 to 100) using a crossover strategy where buys occur when price crosses above the SMA and sells when price crosses below it.

Key Features:
  • Tests 10 different SMA periods to determine optimal settings
  • Calculates profit/loss based on a defined starting capital
  • Tracks total profit and number of trades for each period
  • Visually highlights the best performing SMA on your chart
  • Displays comprehensive results in an easy-to-read table
  • Labels the chart with key performance metrics


This code serves as a core framework that traders can customize for their specific needs. You can easily modify the strategy parameters, test different technical indicators, adjust capital settings, or implement more complex entry/exit rules. The optimization methodology can be applied to virtually any trading approach you wish to evaluate.
Feel free to adapt this framework to test your own trading ideas and discover which parameters work best in different market conditions.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.