OPEN-SOURCE SCRIPT
Обновлено

Monthly Performance Table (Drop-in)

102
A monthly and yearly performance grid you can paste into any Pine strategy.

The table is the point of this publication. The RSI entries in the script are a placeholder so that the code compiles and shows something on a chart out of the box — they are marked as such in the source and are not meant to be traded or evaluated.


WHAT THE TABLE SHOWS

• One row per year, one column per month, plus a Year column
• A Buy & Hold column: the return of simply holding the chart symbol over the same period, so you can see whether the strategy earned its complexity
• A summary strip: CAGR, max drawdown, MAR, number of closed trades, win rate and profit factor
• Under the Year and Buy & Hold columns, the totals for the whole backtest


HOW TO USE IT IN YOUR OWN STRATEGY

1. Open the source of this script
2. Copy everything between the "COPY FROM HERE" and "TO HERE" comment lines
3. Paste it anywhere inside your own strategy() script

That is the whole procedure. The block declares its own inputs, colors, helper functions and state, and every name inside it is prefixed with mpt_ so it will not collide with your variables. It reads only two things from the outside: strategy.equity and close. It does not place orders, does not draw on the price scale, and does not change how your strategy behaves.

It requires a strategy() script. An indicator() has no equity curve to measure.


HOW IT IS CALCULATED

Period boundaries: the script watches for the first bar whose month or year differs from the previous bar. On that bar the period that just ended is closed out using the equity of the previous bar, and a new period starts from the same value. The very first bar is skipped because it has no previous bar to compare against.

Monthly return: equity at the end of the month divided by equity at the start of that month, minus one. Yearly return is the same calculation over the year, so the twelve monthly figures in a row compound to the Year figure rather than adding up to it.

Net profit mode: the same boundaries, but the cell holds the change in equity in account currency instead of a ratio.

The month and year in progress are shown as running values that update on every bar. They are not final until the period closes.

Max drawdown: a running high of equity is kept on every bar, and the largest percentage fall from that high is recorded. It is measured bar by bar rather than at period boundaries, so a drop that recovers within a month is still counted.

CAGR: the total growth factor raised to the power of one divided by the number of elapsed years, where a year is 365.25 days measured from the first bar of the backtest. Under one year the cell shows "< 1y" instead of a number, because annualising a few months produces a figure that looks precise and is not. There is a setting to show it anyway.

MAR: CAGR divided by max drawdown percent. It is left blank when CAGR is not shown.

Buy & Hold: an equity curve that starts with the same initial capital, buys the chart symbol on the first bar and holds. Yearly figures are the change in that curve over each year. It carries no commission, no slippage and no position sizing, so treat it as a rough reference rather than a like-for-like comparison.


SETTINGS

• Theme — dark or light palette for the table
• Position / Size — where the table sits and how large the text is
• Cell value — percent, net profit, or both stacked in one cell
• Years to show — limit the grid to the most recent N years, 0 shows all
• Buy & Hold column — on or off
• Scale cell colors by magnitude — fades each cell in proportion to its size against the largest value on screen, turning the grid into a heat map. Off by default, because one outlier washes everything else out
• Highlight best / worst month — colors the text of the two extreme cells
• Summary row — on or off
• Show CAGR on periods under one year — see above

Color and the best/worst decision always use percent, even in net profit mode. Currency amounts grow as the account grows, so a heat map built on them would make later years look more significant than they were.


LIMITATIONS

• Everything here is computed from a backtest. Past results do not predict future results.
• strategy.equity includes the open profit or loss of a position that is still running, so a month that ends mid-trade reflects an unrealised value.
• Returns are measured on equity, which means they inherit every assumption in your strategy: fill assumptions inside a bar, commission, slippage and position sizing. Change those and the table changes.
• CAGR assumes compounding and is sensitive to the length of the tested period and to where that period starts. Two strategies with the same CAGR can behave very differently.
• The Buy & Hold column has no costs applied, which flatters it relative to a strategy that does pay costs.
• A very long history produces a tall table. Use "Years to show" rather than shrinking the text until it cannot be read.


DEFAULT PROPERTIES OF THE DEMO

Initial capital 10,000, order size 100% of equity, commission 0.05%, slippage 2 ticks, margin 100% for long and short. These are the settings used for the published chart. They exist to keep the demo honest; they are not a recommendation, and you will replace them along with the signal.

Open source. Use it, change it, and no credit is required.
Информация о релизе
-
Информация о релизе
This table shows two things the Strategy Tester's totals do not.

Yearly Buy & Hold comparison - each year's strategy return sits next to the Buy & Hold return for the same year. A strategy that wins over the whole period often loses in most individual years, with one or two exceptional years carrying the total. The totals alone cannot show this.

CAGR and MAR - CAGR makes backtests of different lengths comparable on a yearly basis. MAR (CAGR divided by max drawdown) shows how much drawdown the return cost. It is a standard measure for comparing strategies in systematic trading: around 1 is the practical floor for real money, 2 or above is strong.

Max drawdown is measured on every bar, and CAGR is hidden on periods under one year.

The strategy report on the published chart comes from the placeholder RSI signal and is not a performance claim.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.