Portfolio Strategy TesterThe Portfolio Strategy Tester is an institutional-grade backtesting framework that evaluates the performance of trend-following strategies on multi-asset portfolios. It enables users to construct custom portfolios of up to 30 assets and apply moving average crossover strategies across individual holdings. The model features a clear, color-coded table that provides a side-by-side comparison between the buy-and-hold portfolio and the portfolio using the risk management strategy, offering a comprehensive assessment of both approaches relative to the benchmark.
Portfolios are constructed by entering each ticker symbol in the menu, assigning its respective weight, and reviewing the total sum of individual weights displayed at the top left of the table. For strategy selection, users can choose between Exponential Moving Average (EMA), Simple Moving Average (SMA), Wilder’s Moving Average (RMA), Weighted Moving Average (WMA), Moving Average Convergence Divergence (MACD), and Volume-Weighted Moving Average (VWMA). Moving average lengths are defined in the menu and apply only to strategy-enabled assets.
To accurately replicate real-world portfolio conditions, users can choose between daily, weekly, monthly, or quarterly rebalancing frequencies and decide whether cash is held or redistributed. Daily rebalancing maintains constant portfolio weights, while longer intervals allow natural drift. When cash positions are not allowed, capital from bearish assets is automatically redistributed proportionally among bullish assets, ensuring the portfolio remains fully invested at all times. The table displays a comprehensive set of widely used institutional-grade performance metrics:
CAGR = Compounded annual growth rate of returns.
Volatility = Annualized standard deviation of returns.
Sharpe = CAGR per unit of annualized standard deviation.
Sortino = CAGR per unit of annualized downside deviation.
Calmar = CAGR relative to maximum drawdown.
Max DD = Largest peak-to-trough decline in value.
Beta (β) = Sensitivity of returns relative to benchmark returns.
Alpha (α) = Excess annualized risk-adjusted returns relative to benchmark.
Upside = Ratio of average return to benchmark return on up days.
Downside = Ratio of average return to benchmark return on down days.
Tracking = Annualized standard deviation of returns versus benchmark.
Turnover = Average sum of absolute changes in weights per year.
Cumulative returns are displayed on each label as the total percentage gain from the selected start date, with green indicating positive returns and red indicating negative returns. In the table, baseline metrics serve as the benchmark reference and are always gray. For portfolio metrics, green indicates outperformance relative to the baseline, while red indicates underperformance relative to the baseline. For strategy metrics, green indicates outperformance relative to both the baseline and the portfolio, red indicates underperformance relative to both, and gray indicates underperformance relative to either the baseline or portfolio. Metrics such as Volatility, Tracking Error, and Turnover ratio are always displayed in gray as they serve as descriptive measures.
In summary, the Portfolio Strategy Tester is a comprehensive backtesting tool designed to help investors evaluate different trend-following strategies on custom portfolios. It enables real-world simulation of both active and passive investment approaches and provides a full set of standard institutional-grade performance metrics to support data-driven comparisons. While results are based on historical performance, the model serves as a powerful portfolio management and research framework for developing, validating, and refining systematic investment strategies.
Backtester
Risk Reward Optimiser [ChartPrime]█ CONCEPTS
In modern day strategy optimization there are few options when it comes to optimizing a risk reward ratio. Users frequently need to experiment and go through countless permutations in order to tweak, adjust and find optimal in their data.
Therefore we have created the Risk Reward Optimizer.
The Risk Reward Optimizer is a technical tool designed to provide traders with comprehensive insights into their trading strategies.
It offers a range of features and functionalities aimed at enhancing traders' decision-making process.
With a focus on comprehensive data, it is there to help traders quickly and efficiently locate Risk Reward optimums for inbuilt of custom strategies.
█ Internal and external Signals:
The script can optimize risk to reward ratio for any type of signals
You can utilize the following :
🔸Internal signals ➞ We have included a number of common indicators into the optimizer such as:
▫️ Aroon
▫️ AO (Awesome Oscillator)
▫️ RSI (Relative Strength Index)
▫️ MACD (Moving Average Convergence Divergence)
▫️ SuperTrend
▫️ Stochastic RSI
▫️ Stochastic
▫️ Moving averages
All these indicators have 3 conditions to generate signals :
Crossover
High Than
Less Than
🔸External signal
▫️ by incorporating your own indicators into the analysis. This flexibility enables you to tailor your strategy to your preferences.
◽️ How to link your signal with the optimizer:
In order to be able to analysis your signal we need to read it and to do so we would need to PLOT your signal with a defined value
plot( YOUR LONG Condition ? 100 : 0 , display = display.data_window)
█ Customizable Risk to Reward Ratios:
This tool allows you to test seven different customizable risk to reward ratios , helping you determine the most suitable risk-reward balance for your trading strategy. This data-driven approach takes the guesswork out of setting stop-loss and take-profit levels.
█ Comprehensive Data Analysis:
The tool provides a table displaying key metrics, including:
Total trades
Wins
Losses
Profit factor
Win rate
Profit and loss (PNL)
This data is essential for refining your trading strategy.
🔸 It includes a tooltip for each risk to reward ratio which gives data for the:
Most Profitable Trade USD value
Most Profitable Trade % value
Most Profitable Trade Bar Index
Most Profitable Trade Time (When it occurred)
Position and size is adjustable
█ Visual insights with histograms:
Visualize your trading performance with histograms displaying each risk to reward ratio trade space, showing total trades, wins, losses, and the ratio of profitable trades.
This visual representation helps you understand the strengths and weaknesses of your strategy.
It offers tooltips for each RR ratio with the average win and loss percentages for further analysis.
█ Dynamic Highlighting:
A drop-down menu allows you to highlight the maximum values of critical metrics such as:
Profit factor
Win rate
PNL
for quick identification of successful setups.
█ Stop Loss Flexibility:
You can adjust stop-loss levels using three different calculation methods:
ATR
Pivot
VWAP
This allows you to align risk-reward ratios with your preferred risk tolerance.
█ Chart Integration:
Visualize your trades directly on your price chart, with each trade displayed in a distinct color for easy tracking.
When your take-profit (TP) level is reached , the tool labels the corresponding risk-reward ratio for that specific TP, simplifying trade management.
█ Detailed Tooltips:
Tooltips provide deeper insights into your trading performance. They include information about the most profitable trade, such as the time it occurred, the bar index, and the percentage gain. Histogram tooltips also offer average win and loss percentages for further analysis.
█ Settings:
█ Code:
In summary, the Risk Reward Optimizer is a data-driven tool that offers traders the ability to optimize their risk-reward ratios, refine their strategies, and gain a deeper understanding of their trading performance. Whether you're a day trader, swing trader, or investor, this tool can help you make informed decisions and improve your trading outcomes.
Trade Helper [Trading Nerd]Position Size Calculator / Lot Size Calculator
Disclaimer: I do my best to avoid wrong calculations and bugs. I provide this indicator without warranties of any kind. You bear all risks associated with the use of this indicator.
Inputs:
Market: Adds a name tag to the Table to keep track of the trades.
Entry Price: The entry Price of the Position.
Entry Time: The entry Time/Candle of the Position. If Stop Loss Type is 'ATR' or 'HH/LL' the Value for this is calculated by this Candle.
Stop Loss Type: Changes the Stop Loss Type.
Direction: Define if the trade direction is 'Long' or 'Short'. Has no effect on Stop Loss Type 'Custom'. For this you can just set the Stop Loss below/above the Entry Price .
ATR Multiplier: Multiplies the ATR Value by this number. Has only an effect on Stop Loss Type 'ATR'.
HH/LL Lookback Length: Lookback length for determine Highest High/Lowest Low value. Has only an effect on Stop Loss Type 'HH/LL'.
Custom SL Price: The Stop Loss Price if the Stop Loss Type is set to 'Custom'.
Risk Reward Ratio: The Risk is multiplied by this number to determine the Take Profit Price.
Balance: Balance Amount and Currency
Contract Size: The Position Size is divided by this number. E.G. in Forex one Lot is 100.000 Contracts. Change this Value depending on your Broker and Market.
Risk in %: Percent that is risked of the Balance for one Trade.