OPEN-SOURCE SCRIPT
NLR-ADX Divergence Strategy Triple-Confirmed

How it works 
Builds a cleaner DMI/ADX
Check for triple divergence
For a bearish setup (potential short)
Trade logic
Key inputs you can tweak
Divergence Engine
Builds a cleaner DMI/ADX
- Recomputes classic +DI, −DI, ADX over a user-set length.
- Then “non-linear regresses” each series toward a mean (your choice: dynamic EMA of the series or a fixed Static Mid like 50).
- The further a value is from the mean, the stronger the pull (controlled by alphaMin/alphaMax and the γ exponent), giving smoother, more stable DI/ADX lines with less whipsaw.
- Optional EMA smoothing on top of that.
- Lock in values at confirmed pivots
- Uses price pivots (left/right bars) to confirm swing lows and highs.
- When a pivot confirms, the script captures (“freezes”) the current +DI, −DI, and ADX values at that bar and stores them. This avoids later drift from smoothing/EMAs.
Check for triple divergence
- For a bullish setup (potential long):
- Price makes a Lower Low vs. a prior pivot low,
- +DI is higher than before (bulls quietly stronger),
- −DI is lower (bears weakening),
- ADX is lower (trend fatigue).
For a bearish setup (potential short)
- Price makes a Higher High,
- +DI is lower, −DI is higher,
- ADX is lower.
- Adds a “no-intersection” sanity check: between the two pivots, the live series shouldn’t snake across the straight line connecting endpoints. This filters messy, low-quality structures.
Trade logic
- On a valid triple-confirm, places a strategy.entry (Long for bullish, Short for bearish) and optionally labels the bar (BUY or SELL with +DI/−DI/ADX arrows).
- Simple flip behavior: if you’re long and a new short signal prints (or vice versa), it closes the open side and flips.
Key inputs you can tweak
- Custom DMI Settings
- DMI Length — base length for DI/ADX.
- Non-Linear Regression Model
- Mean Reference — EMA(series) (dynamic) or Static mid (e.g., 50).
- Dynamic Mean Length & Deviation Scale Length — govern the mean and scale used for regression.
- Min/Max Regression & Non-Linearity Exponent (γ) — how strongly values are pulled toward the mean (stronger when far away).
Divergence Engine
- Pivot Left/Right Bars — how strict the swing confirmation is (larger = more confirmation, more delay).
- Min Bars Between Pivots — avoids comparing “near-duplicate” swings.
- Max Historical Pivots to Store — memory cap.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
