OPEN-SOURCE SCRIPT
Telah dikemas kini Strategy Sensitivity Matrix

The Strategy Sensitivity Matrix is an institutional-grade backtesting tool designed to evaluate the robustness and parameter sensitivity of trend-following strategies. It enables users to compare the historical performance of a broad range of parameter combinations across multiple metrics to assess the overall stability of the selected strategy. The model displays the complete backtest landscape in a structured, color-coded matrix that allows investors to quickly identify robust parameter regions and evaluate historical performance stability across parameter combinations.
At its core, the matrix systematically evaluates a wide range of parameter combinations, where every individual cell represents the backtest result for one unique parameter configuration. Users can switch between volatility-based strategies and moving-average strategies. In volatility mode, the matrix rows represent volatility lengths and the matrix columns represent volatility factors. In crossover mode, the rows represent fast moving-average lengths and the columns represent slow moving-average lengths. Supported volatility types include the Average True Range (ATR), Standard Deviation (SD), and Mean Absolute Deviation (MAD). Supported moving-average types include the Exponential Moving Average (EMA), Simple Moving Average (SMA), Wilder’s Moving Average (RMA), and Weighted Moving Average (WMA). Supported display metrics include:
The matrix follows an intuitive percentile-based coloring framework that dynamically compares the relative performance and stability of all parameter combinations. Stronger values above or equal to the matrix median are highlighted in green, with bright green representing the top 10% of all parameter combinations. Weaker values below the matrix median are highlighted in orange, while red represents objectively weak performance based on the selected metric. Broad clusters of consistently strong results generally suggest lower parameter sensitivity and potentially greater robustness, while isolated peaks generally suggest elevated parameter sensitivity.
The summary table displayed above the matrix provides a broader distribution-level statistical overview of results across all parameter combinations. This structure allows investors to evaluate whether strong historical performance appears statistically widespread or narrowly concentrated across the parameter landscape. Stable parameter landscapes generally exhibit lower standard deviation, similar median and average values, and smaller performance gaps between the best and top 10% parameter combinations. The summary table includes the following sections:
In summary, the Strategy Sensitivity Matrix is a powerful robustness analysis tool designed to help investors make data-driven decisions when evaluating parameter combinations across trend-following strategies. By evaluating the full parameter landscape, investors can quickly determine whether strong historical performance appears broadly distributed across stable parameter regions or narrowly concentrated within isolated parameter combinations. While historical robustness can provide valuable insight into past market behavior over the selected backtest period, users should remain mindful that market structures evolve over time and that historically stable parameter regions may not necessarily persist in future market conditions.
At its core, the matrix systematically evaluates a wide range of parameter combinations, where every individual cell represents the backtest result for one unique parameter configuration. Users can switch between volatility-based strategies and moving-average strategies. In volatility mode, the matrix rows represent volatility lengths and the matrix columns represent volatility factors. In crossover mode, the rows represent fast moving-average lengths and the columns represent slow moving-average lengths. Supported volatility types include the Average True Range (ATR), Standard Deviation (SD), and Mean Absolute Deviation (MAD). Supported moving-average types include the Exponential Moving Average (EMA), Simple Moving Average (SMA), Wilder’s Moving Average (RMA), and Weighted Moving Average (WMA). Supported display metrics include:
- CAGR = Compounded Annual Growth Rate.
- Sharpe = CAGR per unit of standard deviation.
- Sortino = CAGR per unit of downside deviation.
- Martin = CAGR relative to the Ulcer Index (UI).
- Calmar = CAGR relative to maximum drawdown.
- Max DD = Largest peak-to-trough decline in value.
- Alpha (α) = Excess annualized risk-adjusted returns.
- Expectancy = Average expected return per trade.
- Profit Factor = Total gross profit per unit of losses.
- Win Rate = Ratio of profitable trades to total trades.
- Trades/Year = Average number of trades per year.
The matrix follows an intuitive percentile-based coloring framework that dynamically compares the relative performance and stability of all parameter combinations. Stronger values above or equal to the matrix median are highlighted in green, with bright green representing the top 10% of all parameter combinations. Weaker values below the matrix median are highlighted in orange, while red represents objectively weak performance based on the selected metric. Broad clusters of consistently strong results generally suggest lower parameter sensitivity and potentially greater robustness, while isolated peaks generally suggest elevated parameter sensitivity.
The summary table displayed above the matrix provides a broader distribution-level statistical overview of results across all parameter combinations. This structure allows investors to evaluate whether strong historical performance appears statistically widespread or narrowly concentrated across the parameter landscape. Stable parameter landscapes generally exhibit lower standard deviation, similar median and average values, and smaller performance gaps between the best and top 10% parameter combinations. The summary table includes the following sections:
- Start = Start month and year of the selected backtest period.
- End = End month and year of the selected backtest period.
- Metric = Performance metric currently displayed in the matrix.
- B&H = Buy-and-hold performance for the selected metric.
- Best = Best-performing parameter combination in the matrix.
- Top 10% = Average value of the top 10% parameter combinations.
- Median = Median value across all parameter combinations.
- Average = Average value across all parameter combinations.
- Std Dev = Standard deviation of all parameter combinations.
- ≥ B&H = Percentage of combinations equal or better than B&H.
In summary, the Strategy Sensitivity Matrix is a powerful robustness analysis tool designed to help investors make data-driven decisions when evaluating parameter combinations across trend-following strategies. By evaluating the full parameter landscape, investors can quickly determine whether strong historical performance appears broadly distributed across stable parameter regions or narrowly concentrated within isolated parameter combinations. While historical robustness can provide valuable insight into past market behavior over the selected backtest period, users should remain mindful that market structures evolve over time and that historically stable parameter regions may not necessarily persist in future market conditions.
Nota Keluaran
- Integrated the summary statistics table directly into the main parameter sensitivity matrix.
- Added the Interquartile Range (IQR) to measure the middle 50% dispersion of parameter combinations.
- Added Strategy and Type to the summary section for clearer visibility of the selected configuration.
Nota Keluaran
- Updated parameter combinations to improve statistical comparability across the sensitivity matrix.
- Added Efficiency metric in the menu to evaluate CAGR relative to the percentage of time invested.
- Added Exposure metric in the menu to show the current strategy exposure as 1 (bull) or 0 (bear).
Nota Keluaran
Fixed a minor misalignment in the turnover and transaction cost calculation.Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.