EMA Edge - Multi-EMA Backtest Table with Golden/Death CrossEMA Edge — Multi-EMA Backtest Table with Golden/Death Cross
A clean, all-in-one performance dashboard that backtests 6 long-only strategies side-by-side against a Buy & Hold benchmark — 5 single-EMA crossover strategies plus a classic Golden Cross / Death Cross strategy — with on-chart cross markers and built-in alerts.
Instead of guessing which EMA length works best for a given stock or timeframe, this indicator runs the math for you and shows the answer in a single glance, ranked against simply holding the asset.
What It Does
For each of 5 user-defined EMA lengths, the indicator simulates a simple long-only strategy:
Buy when price closes above the EMA (when flat)
Sell when price closes below the EMA (when long)
Equity starts at 100 and compounds across trades using the close-to-close return of each trade
A 6th strategy row tests the classic Golden/Death Cross:
Buy when the fast EMA crosses above the slow EMA (Golden Cross)
Sell when the fast EMA crosses below the slow EMA (Death Cross)
Special first-bar handling: if the fast EMA is already above the slow EMA at the start of your backtest window (i.e., we're mid-trend with no fresh Golden Cross to wait for), the strategy enters immediately at that bar's opening price. This avoids the unrealistic outcome of sitting in cash for years waiting for a cross that already happened.
All strategies are compared against a Buy & Hold baseline that starts at the close of the first in-range bar. If a position is open at the last bar, its equity is marked-to-market so every strategy is compared on equal terms — fully invested vs. partially invested at the cutoff.
Features
5 configurable EMAs — defaults 9 / 21 / 50 / 100 / 200, fully editable
Golden/Death Cross strategy — uses independent fast/slow EMA inputs (default 50 / 200)
Performance table showing Return %, delta vs. Buy & Hold, and Outperform / Underperform status per strategy
Flexible backtest window — X weeks, X years, or full chart lifetime
On-chart GC / DC markers with optional subtle background tint on cross bars
Built-in alerts for both Golden Cross and Death Cross events
Fully customizable table — 9 position options, 6 text sizes, all colors exposed as inputs
Soft, light color palette designed not to dominate the chart
Optional EMA plotting (off by default to keep the chart clean)
How To Read The Table
ColumnMeaningStrategyThe rule being testedReturnTotal % return of the strategy over the chosen windowVs StockDifference between the strategy's return and Buy & HoldStatus▲ Outperform if the strategy beat Buy & Hold, ▼ Underperform if not
Green-tinted rows = strategy beat Buy & Hold
Red-tinted rows = strategy underperformed Buy & Hold
Cream row = the Buy & Hold baseline itself
How To Use
Add the indicator to any chart — works on stocks, ETFs, crypto, forex, any timeframe.
Choose your backtest window (e.g., 1 Year, 5 Years, or Lifetime).
Scan the table to see which strategy historically beat Buy & Hold on this asset.
Use the on-chart GC / DC labels to spot historical and live cross events. Right-click any marker → Add Alert to be notified on new crosses.
Tip: Test the same EMA lengths across daily and weekly timeframes and across different assets. You'll usually find that what works on a steady index like SPY does not work on a volatile single stock, and vice versa. That's the entire point of the table — to make those differences visible instead of assumed.
Key Inputs
EMA 1–5: Lengths for the 5 single-EMA strategies
Show EMAs: Plot EMAs on chart (off by default)
Use Lifetime Performance: Backtest from the very first bar instead of a fixed window
Performance Timeframe Type / Value: Weeks or Years lookback
Crosses group: Toggle GC/DC display, set fast/slow EMA lengths, customize colors
Table Style group: Position, text size, background and text colors
Notes & Limitations
All strategies are long-only — no shorts, no leverage, no stops, no commissions, no slippage. This is a clean rule-based comparison, not a turnkey trading system. Live results will differ.
Entries and exits use close prices, except for the GC/DC strategy's first-bar entry when already in a golden state, which uses open.
Open positions at the last bar are marked-to-market so the comparison vs. Buy & Hold is apples-to-apples.
Past performance is not indicative of future results. Use this as a research and screening tool.
The GC/DC strategy uses separate EMA lengths from the 5 table EMAs by design, so you can run 9/21/50/100/200 in the table while still testing the classic 50/200 cross.
Alerts Available
Golden Cross: Fast EMA crossed above Slow EMA
Death Cross: Fast EMA crossed below Slow EMA
If you find this useful, a boost is appreciated. Suggestions and feedback welcome in the comments.
Open-source — feel free to study, fork, and adapt.
Pine Script® 인디케이터






















