Building a Monthly Strategy Returns and Drawdown Table in Pine Script
Summary
This Pine Script combines an illustrative long-only moving-average pullback strategy with a reusable performance table. The example enters when price is above a long moving average but below a shorter one, then exits above the short average, on a configurable lower-close rule, or after a percentage loss threshold. The table code tracks closed-trade returns and aggregates performance by month and year. It also calculates measures such as compounded annual growth, realized-equity drawdown, drawdown duration, and trade counts, with options for display, precision, colors, and paging.
The document provides implementation logic rather than evidence that the example strategy is profitable. Its drawdown calculations use closed-trade equity, so they can differ from a platform report based on open equity; this distinction is surfaced in the table’s explanatory text. The displayed source is also truncated, preventing full review of the table calculations. Treat the example rules and reported metrics as analysis tools to validate, not as proof of performance or a ready-made trading system.
Key ideas
- The sample strategy buys a pullback while price remains above a longer-term moving average.
- A shorter-average exit, optional lower-close confirmation, and percentage loss threshold govern exits.
- The table groups realized trade returns by month and year and summarizes performance statistics.
- Closed-trade equity drawdowns can differ from drawdowns calculated using open positions.
- The source shown is incomplete, and the example contains no evidence of strategy profitability.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.