OPEN-SOURCE SCRIPT
Benford's Law Actual [Tagstrading]

Benford’s Law Chart — First Digit Analysis of Percentage Price Drops
This script visualizes the distribution of the leading digit in the percentage change of price drops, and compares it to the theoretical distribution expected by Benford’s Law.
It helps traders, analysts, and quants to detect anomalies, unnatural behavior, or price manipulation in any asset or timeframe.
How to Use
Add to any chart or symbol (stocks, crypto, FX, etc.) and select the timeframe you wish to analyze.
Set the “Number of Bars to Analyze” input (default: 500) to control the length of the historical window.
The chart will display, for the latest window:
A blue line: the actual leading-digit distribution for percentage price changes between bars.
A red line: the expected distribution per Benford’s Law.
Labels below and above: digit markers and the expected (theoretical) percentages.
Summary panel on the right: frequency counts and actual vs. theoretical % for each digit.
Interpretation:
If your actual (blue) curve or digit counts are significantly different from the red Benford’s Law curve, it could indicate unnatural price action, fraud, bot activity, or structural anomalies.
Why is this useful for TradingView?
Financial forensics: Benford’s Law is a classic tool for detecting data manipulation and fraud in accounting. On charts, it can reveal if price movements are statistically “natural.”
Transparency and confidence: Helps communities audit markets, brokers, or exchanges for irregularities.
Adaptable: Works on any market, any timeframe.
What makes this script unique?
Focuses on % price changes, not raw prices.
This provides a fair comparison across assets, symbols, and timeframes.
Measures only the direction and magnitude of drops/rises — more suitable for detecting manipulation in active markets.
Clear and customizable visualization:
The Benford line, actual data, and summary are all visible and readable in one glance.
Optimized for speed and clarity (runs efficiently on all major charts).
How is it different from stg44’s Benford’s Law script?
This script analyzes the leading digit of percentage price changes (i.e., how much the price drops or rises in %),
while the original by stg44 analyzes the leading digit of price itself.
Results are less sensitive to price scale and more comparable across volatile and non-volatile assets.
The summary panel clearly shows ( ) for actual and [ ] for Benford theoretical values.
Full code is commented and open for the community.
Credits and Inspiration
This script was inspired by “Benford’s Law” by stg44:

Thanks to the TradingView community for sharing powerful visual ideas.
—
By tags trading
This script visualizes the distribution of the leading digit in the percentage change of price drops, and compares it to the theoretical distribution expected by Benford’s Law.
It helps traders, analysts, and quants to detect anomalies, unnatural behavior, or price manipulation in any asset or timeframe.
How to Use
Add to any chart or symbol (stocks, crypto, FX, etc.) and select the timeframe you wish to analyze.
Set the “Number of Bars to Analyze” input (default: 500) to control the length of the historical window.
The chart will display, for the latest window:
A blue line: the actual leading-digit distribution for percentage price changes between bars.
A red line: the expected distribution per Benford’s Law.
Labels below and above: digit markers and the expected (theoretical) percentages.
Summary panel on the right: frequency counts and actual vs. theoretical % for each digit.
Interpretation:
If your actual (blue) curve or digit counts are significantly different from the red Benford’s Law curve, it could indicate unnatural price action, fraud, bot activity, or structural anomalies.
Why is this useful for TradingView?
Financial forensics: Benford’s Law is a classic tool for detecting data manipulation and fraud in accounting. On charts, it can reveal if price movements are statistically “natural.”
Transparency and confidence: Helps communities audit markets, brokers, or exchanges for irregularities.
Adaptable: Works on any market, any timeframe.
What makes this script unique?
Focuses on % price changes, not raw prices.
This provides a fair comparison across assets, symbols, and timeframes.
Measures only the direction and magnitude of drops/rises — more suitable for detecting manipulation in active markets.
Clear and customizable visualization:
The Benford line, actual data, and summary are all visible and readable in one glance.
Optimized for speed and clarity (runs efficiently on all major charts).
How is it different from stg44’s Benford’s Law script?
This script analyzes the leading digit of percentage price changes (i.e., how much the price drops or rises in %),
while the original by stg44 analyzes the leading digit of price itself.
Results are less sensitive to price scale and more comparable across volatile and non-volatile assets.
The summary panel clearly shows ( ) for actual and [ ] for Benford theoretical values.
Full code is commented and open for the community.
Credits and Inspiration
This script was inspired by “Benford’s Law” by stg44:

Thanks to the TradingView community for sharing powerful visual ideas.
—
By tags trading
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.