EMA Slope Angle Autothreshold V3### Overview
This publication is an **indicator** for **chart analysis and visualization**. It does **not** place trades, manage risk, or guarantee any outcome. Market behavior depends on your instrument, session, liquidity, and chart type; past indicator readings do not predict future prices.
**Pine version:** v6.
### What makes it different from a plain moving average
A standard EMA shows level; this script emphasizes **how quickly the EMA is changing** by converting the EMA’s change over `Slope Lookback Bars` into a **slope angle** (degrees) and using that value to drive **regime coloring**, optional **transition markers**, and **distribution-style statistics** in the dashboard.
### How the angle is calculated
On each bar the script compares the current EMA to the EMA `slopeLookback` bars ago, takes the difference, and applies:
`angleDeg = atan(delta / slopeLookback) * (180 / π)`
So the output is a smooth, bounded interpretation of EMA momentum rather than only the raw price/EMA distance.
### Regime logic (FLAT / RISING / FALLING)
- **Manual mode (default):** Uses your inputs for flat band and rising/falling triggers in degrees.
- **Auto mode (optional):** Over a rolling **analysis period**, estimates the mean and standard deviation of `angleDeg`, then derives band edges using a **normal-distribution approximation** for quartiles (0.674×σ to the 25th/75th band). When auto mode is active and enough bars are available, those derived values replace the manual flat/rising/falling thresholds and the color saturation cap. If dispersion is zero or history is short, the script falls back to manual values or shows a **WAIT** state in the table where applicable.
The regime label is **descriptive** (slope classification), not a verified trading signal.
### Visual markers (“signals”)
When enabled, small shapes can print on bars where the script detects a **first move out of FLAT** into RISING or FALLING under the current threshold rules. These are **exploratory visuals** for regime changes, not buy/sell recommendations.
### KPI table and statistics
The table (top-right by default) can show:
- EMA length, current angle (rounded), regime, and a text state for the last marker event
- Optional **auto-threshold** diagnostics (mean, standard deviation, effective thresholds)
- Optional **angle histogram** counts by bucket; buckets can follow **fixed degree edges** or **scale with σ** when auto thresholds are enabled and enough data exists
Table statistics accumulate on **confirmed bars** while the stats option is on; changing symbol or timeframe resets counters by design.
### Inputs (high level)
- **EMA Length** and **Slope Lookback Bars** — core smoothing and responsiveness
- **Angle Settings** — manual thresholds, optional auto mode, analysis length, color saturation cap
- **Colors** — uptrend, downtrend, flat base colors (EMA uses dynamic transparency by normalized angle)
- **Signals** — toggle transition markers
- **Statistics** — toggle bucket stats and dashboard text size
### Chart and compatibility notes
- **Overlay** on the main series; works on standard chart types. Interpretation can change on non-standard aggregation; if you use exotic chart types, validate whether the angle semantics still match your workflow.
- **No `request.security()`** in this script; calculations use the chart’s OHLC/series only.
- **Repainting:** marker and table updates are tied to **confirmed bars** where noted in the logic; nonetheless, any visual can **lag** fast markets by one bar when confirmation is required.
### Limitations and disclosures
- **Not financial advice.** The author and script provide tools for analysis only.
- **No performance claims** are made for signals, regimes, or auto thresholds.
- **Auto thresholds** assume a stable statistical window; structural breaks (news, rolls, session gaps) can make rolling means and standard deviations **misleading** until the window adapts.
- **Bucket labels** reuse internal counter names from fixed-width defaults; when auto buckets scale, read the **numeric ranges** in the table rather than the legacy counter variable names.
## 5. Key features (bullets)
- EMA overlay with **angle-driven** dynamic coloring (opacity scales with normalized angle)
- **FLAT / RISING / FALLING** regime from degree thresholds
- Optional **auto thresholds** from rolling angle mean and dispersion (quartile-style band)
- Optional **transition markers** when slope leaves the flat band
- **KPI table:** angle, regime, last marker state, optional distribution fields
- **Angle bucket statistics** with fixed or auto-scaled bin edges
- Pine **v6**; chart-native series only (no higher-timeframe security calls in this file)
---
Indicador Pine Script®






















