OPEN-SOURCE SCRIPT
更新済 Stock Earnings Tracker

This indicator tracks a stock's earnings history directly on the chart. Each time an earnings report is detected, it calculates the price reaction over a defined window, keeps a running record of past earnings reactions, and displays a live statistics table summarizing win rate, average return, sample size, and days elapsed since the last report.
How it works
Earnings detection: The script pulls TradingView's built-in earnings calendar data (via the ESD: ticker syntax) to identify the exact bar on which a company reported earnings. This only works on symbols of type stock or dr (depositary receipts); other instrument types will show no data.
Pre-earnings window return: On each detected earnings day, the script measures the percentage change from the prior day's open to the earnings day's close. This approximates the market's immediate reaction to the report.
Historical sample tracking: Each new earnings-day return is stored in an array (default: last 20 events, adjustable up to 100). Older samples are dropped once the limit is reached, so statistics reflect a rolling recent history rather than the stock's entire earnings record.
Win rate / average return: From the stored sample set, the script calculates the percentage of earnings events with a positive reaction ("win rate") and the average reaction size across all stored samples.
Days since labels: A label is placed at each earnings event; when the next earnings event occurs, the prior label is updated to show how many calendar days elapsed between the two reports.
Visual cues: Labels and a subtle background tint are color-graded (green/red/gray) based on the magnitude of the earnings-day return, and a table in the top-right corner summarizes the current statistics in real time.
Inputs
Show Days Since Last Earnings Labels—toggles the days-since labeling feature on/off.
Max Historical Earnings Samples to Track—controls how many past earnings events (5–100) are retained for the win-rate/average-return calculations.
Limitations
Only functions on stocks and depositary receipts with available earnings-calendar data; results will show "N/A" elsewhere.
Statistics are based on a limited, rolling sample and may carry low statistical significance for stocks with infrequent or sparse earnings history.
The "pre-earnings window" return captures open-to-close price action around the report, not the full multi-day drift some stocks exhibit after earnings.
Recommended Usage: Weekly Timeframe
While the script will run on any timeframe, it's best suited for the WEEKLY chart:
Matches earnings cadence. Public companies report roughly once per quarter (~13 weeks apart). On a daily chart, that's 60+ bars of space between each earnings label—the weekly chart compresses this into a handful of bars, making the historical pattern of reactions much easier to read at a glance.
Cleaner statistics table context. Because max_samples defaults to a rolling window of past events, viewing on weekly lets a 20-sample lookback span roughly 5 years of earnings history in a single, uncluttered view—versus a daily chart where the same 20 samples are scattered across a much wider, harder-to-navigate range.
Less label overlap. The "Pre-E Window" and "Days Since" labels are less likely to visually collide with price action or with each other when spaced out across weekly bars.
Disclaimer
This script is provided for informational and educational purposes only. Past earnings-day performance shown by this indicator does not predict or guarantee future results. It is not financial advice and should not be used as the sole basis for any trading decision. Always combine with your own analysis and risk management.
This description was written with the assistance of AI and reviewed by the author before publishing.
Original code © patinum, licensed under the Mozilla Public License 2.0.
How it works
Earnings detection: The script pulls TradingView's built-in earnings calendar data (via the ESD: ticker syntax) to identify the exact bar on which a company reported earnings. This only works on symbols of type stock or dr (depositary receipts); other instrument types will show no data.
Pre-earnings window return: On each detected earnings day, the script measures the percentage change from the prior day's open to the earnings day's close. This approximates the market's immediate reaction to the report.
Historical sample tracking: Each new earnings-day return is stored in an array (default: last 20 events, adjustable up to 100). Older samples are dropped once the limit is reached, so statistics reflect a rolling recent history rather than the stock's entire earnings record.
Win rate / average return: From the stored sample set, the script calculates the percentage of earnings events with a positive reaction ("win rate") and the average reaction size across all stored samples.
Days since labels: A label is placed at each earnings event; when the next earnings event occurs, the prior label is updated to show how many calendar days elapsed between the two reports.
Visual cues: Labels and a subtle background tint are color-graded (green/red/gray) based on the magnitude of the earnings-day return, and a table in the top-right corner summarizes the current statistics in real time.
Inputs
Show Days Since Last Earnings Labels—toggles the days-since labeling feature on/off.
Max Historical Earnings Samples to Track—controls how many past earnings events (5–100) are retained for the win-rate/average-return calculations.
Limitations
Only functions on stocks and depositary receipts with available earnings-calendar data; results will show "N/A" elsewhere.
Statistics are based on a limited, rolling sample and may carry low statistical significance for stocks with infrequent or sparse earnings history.
The "pre-earnings window" return captures open-to-close price action around the report, not the full multi-day drift some stocks exhibit after earnings.
Recommended Usage: Weekly Timeframe
While the script will run on any timeframe, it's best suited for the WEEKLY chart:
Matches earnings cadence. Public companies report roughly once per quarter (~13 weeks apart). On a daily chart, that's 60+ bars of space between each earnings label—the weekly chart compresses this into a handful of bars, making the historical pattern of reactions much easier to read at a glance.
Cleaner statistics table context. Because max_samples defaults to a rolling window of past events, viewing on weekly lets a 20-sample lookback span roughly 5 years of earnings history in a single, uncluttered view—versus a daily chart where the same 20 samples are scattered across a much wider, harder-to-navigate range.
Less label overlap. The "Pre-E Window" and "Days Since" labels are less likely to visually collide with price action or with each other when spaced out across weekly bars.
Disclaimer
This script is provided for informational and educational purposes only. Past earnings-day performance shown by this indicator does not predict or guarantee future results. It is not financial advice and should not be used as the sole basis for any trading decision. Always combine with your own analysis and risk management.
This description was written with the assistance of AI and reviewed by the author before publishing.
Original code © patinum, licensed under the Mozilla Public License 2.0.
リリースノート
text formattingオープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。