PROTECTED SOURCE SCRIPT
Directional Flow Index (DFI) — v2.4

Directional Flow Index (DFI) — v2.4 
✨ 1) What DFI measures (conceptual)
DFI aims to quantify directional flow—i.e., whether trading activity is skewed toward buying (supportive pressure) or selling (resistive pressure)—and then present it as a normalized oscillator that is easy to compare across symbols and timeframes. It is designed to highlight high-confidence thrusts within a prevailing trend and to detect fatigue as momentum decays.
While multiple “flow” proxies exist, this version emphasizes a True Volume Delta (TVD) workflow (default) that tallies buy vs. sell volume from a lower timeframe (LTF) inside an anchor timeframe bar, producing a more realistic per-bar delta when supported by the symbol’s data.
✨ 2) Core pipeline (how it works)
Flow construction (TVD default).
CVD-style accumulation.
High-pass de-trending + smoothing.
Z-score normalization.
SuperTrend (regime filter).
Fatigue % (0–100).
Gradient highlight (confidence shading).
Histogram color transparency blends three ingredients:
Result: darker bars indicate higher confidence in thrust quality; faint bars warn of weaker, stale, or misaligned pushes.
✨ 3) Interpreting the plots
DFI histogram (columns):
Signal (line): EMA of DFI used for momentum regime checks.
Zero line: structural reference for thrust crossovers.
Fatigue Table (optional): shows Fatigue%, SuperTrend regime, and selected Flow Method.
✨ 4) Alerts (examples)
✨ 5) How to set the TVD Lower TF (important)
TVD needs a sensible LTF/Anchor ratio for balanced accuracy and performance. As a rule of thumb, aim for ~30–120 LTF bars inside one anchor bar:
Notes: Some symbols/exchanges do not provide seconds. Too small an LTF can be heavy/noisy; too large becomes coarse/laggy.
✨ 6) Practical usage patterns
Trend-following entries:
Trend-following exits / de-risking:
Avoid chop:
✨ 7) Inputs (summary)
✨ 8) Compatibility & performance notes
✨ 9) Limitations and good practice
✨ 10) Disclaimer
This script is for educational purposes only and does not constitute financial advice. Trading involves risk, including possible loss of principal.
---------------------------------------------------------------------------------------------------------------------
한국어 번역 / Korean version below
✨DFI란 무엇인가?
DFI는 시장의 매수·매도 우위를 Flow(흐름) 형태로 분석하여
그 에너지를 정규화된 오실레이터로 표현하는 지표입니다.
가격의 단순 변동이 아니라, “얼마나 일관성 있는 압력(Flow)이 유지되는가”를 보여줍니다.
기본 방식인 True Volume Delta (TVD)는 상위 봉(Anchor) 내부의 하위 타임프레임(LTF) 데이터를 스캔해
실제 매수/매도 체결량 차이를 계산합니다.
이로써 단순 가격 변화가 아닌 실제 체결 흐름의 방향성을 반영합니다.
✨DFI의 계산 과정 (개념적 흐름)
1. Flow 계산 (TVD 또는 대체 방식)
2. 누적(CVD) 구성
3. 고역통과(High-pass) 필터
4. Z-score 정규화
5. SuperTrend 레짐(추세 상태) 인식
6. Fatigue% (피로도 지수)
7. 그라디언트 하이라이트 (Gradient Highlight)
✨DFI 차트 해석법
DFI 히스토그램 (컬럼):
Signal 선:
Zero 선:
Fatigue Table:
✨알림 조건 (Alerts)
TVD (True Volume Delta) 설정 가이드
TVD는 Anchor:LowerTF = 약 30~120배 비율이 가장 효율적입니다.
참고:
일부 거래소는 초 단위를 지원하지 않습니다 → 분 단위로 대체.
너무 짧은 LTF → 과부하/노이즈,
너무 긴 LTF → 신호 지연/정밀도 저하.
✨활용 전략 예시
추세 추종 (Trend-following):
리스크 축소 (De-risking):
횡보 회피:
✨한계 및 권장 사용법
✨면책 (Disclaimer)
이 스크립트는 교육용 도구(Educational purpose)이며,
투자 조언(Financial advice)이 아닙니다.
모든 트레이딩에는 손실의 위험이 있으며,
DFI의 신호나 수치가 수익을 보장하지 않습니다.
✨정리
DFI는 단순한 “추세 오실레이터”가 아니라,
에너지의 흐름 + 피로도 + 레짐 정렬이라는 3요소를 결합해
“지속 가능한 방향성”을 시각적으로 표현하는 지표입니다.
즉, 단순한 ‘방향’이 아니라 “추세의 질(Quality)”을 보여주는
새로운 형태의 Flow 분석 도구입니다.
✨ 1) What DFI measures (conceptual)
DFI aims to quantify directional flow—i.e., whether trading activity is skewed toward buying (supportive pressure) or selling (resistive pressure)—and then present it as a normalized oscillator that is easy to compare across symbols and timeframes. It is designed to highlight high-confidence thrusts within a prevailing trend and to detect fatigue as momentum decays.
- Positive DFI (> 0): net buy-side pressure dominates.
- Negative DFI (< 0): net sell-side pressure dominates.
- Magnitude reflects intensity after de-trending and Z-score normalization.
While multiple “flow” proxies exist, this version emphasizes a True Volume Delta (TVD) workflow (default) that tallies buy vs. sell volume from a lower timeframe (LTF) inside an anchor timeframe bar, producing a more realistic per-bar delta when supported by the symbol’s data.
✨ 2) Core pipeline (how it works)
Flow construction (TVD default).
- Using ta.requestVolumeDelta(LTF, Anchor), the script approximates up-volume vs. down-volume inside each anchor bar.
- A per-bar delta is derived (with a reset on anchor switches to avoid jumps).
- If TVD is unsupported on the symbol, DFI can fall back to synthetic proxies (e.g., Synthetic Delta Volume: (close-low)/(high-low) × vol), but TVD is the intended default.
CVD-style accumulation.
- Per-bar delta is cumulatively summed into a running flow line (CVD-like), providing temporal context to the net pressure.
High-pass de-trending + smoothing.
- A high-pass step (EMA-based) removes slow drifts (trend bias) from the CVD line.
- A short EMA smoothing reduces noise while preserving thrust.
Z-score normalization.
- The de-trended series is standardized (rolling mean/std), so DFI readings are comparable across markets/timeframes.
- The Signal line is an EMA of DFI and is used for momentum cross checks.
SuperTrend (regime filter).
- A lightweight SuperTrend (ATR len=5, factor=6 by default) provides up/down regime.
- DFI coloring and alerts can be conditioned on the regime (optional).
Fatigue % (0–100).
- Tracks energy (EMA of |DFI|) vs. peak energy (with adaptive half-life decay).
- When energy stays far below the decaying peak, Fatigue% rises, suggesting momentum exhaustion.
- The decay rate adapts to DFI volatility and regime alignment, so decay is faster when thrusts are misaligned with trend, slower when aligned and orderly.
Gradient highlight (confidence shading).
Histogram color transparency blends three ingredients:
- DFI strength (|DFI| vs user-set bands)
- Low fatigue (fresher thrusts score higher)
- Regime alignment (DFI sign vs SuperTrend direction)
Result: darker bars indicate higher confidence in thrust quality; faint bars warn of weaker, stale, or misaligned pushes.
✨ 3) Interpreting the plots
DFI histogram (columns):
- Green above zero for buy-side thrust, Red below zero for sell-side thrust.
- Opacity encodes confidence (darker = stronger alignment & lower fatigue).
Signal (line): EMA of DFI used for momentum regime checks.
Zero line: structural reference for thrust crossovers.
Fatigue Table (optional): shows Fatigue%, SuperTrend regime, and selected Flow Method.
✨ 4) Alerts (examples)
- Long Thrust: DFI crosses above zero while in Up regime.
- Short Thrust: DFI crosses below zero while in Down regime.
- Loss of Momentum (Up): DFI crosses below Signal while DFI > 0 (warns of weakening long thrust).
- Loss of Momentum (Down): DFI crosses above Signal while DFI < 0 (warns of weakening short thrust).
✨ 5) How to set the TVD Lower TF (important)
TVD needs a sensible LTF/Anchor ratio for balanced accuracy and performance. As a rule of thumb, aim for ~30–120 LTF bars inside one anchor bar:
- 1h chart → 1–2m LTF (if seconds not available).
- 4h → 3–5m.
- 1D → 15–30m.
- 1W → 1–2h.
- 1M → 4h–1D.
Notes: Some symbols/exchanges do not provide seconds. Too small an LTF can be heavy/noisy; too large becomes coarse/laggy.
✨ 6) Practical usage patterns
Trend-following entries:
- Look for DFI > 0 in Up regime (green) with low Fatigue%, and DFI crossing above zero or above its Signal.
- Prefer darker (higher-confidence) histogram bars.
Trend-following exits / de-risking:
- Rising Fatigue% toward your high threshold (e.g., 80–90) suggests exhaustion.
- DFI vs Signal crosses against your position can be used to scale down.
Avoid chop:
- When DFI oscillates around zero with faint bars and Fatigue% rises quickly, quality is low—be selective.
✨ 7) Inputs (summary)
- Flow Method: default True Volume Delta (LTF scan); synthetic fallbacks available.
- Processing: Detrend length, smoothing EMA, Z-score window, Signal EMA.
- Regime: SuperTrend ATR length & factor (default 5 & 6).
- Fatigue%: EMA length, base half-life, adaptive volatility coupling (enable/disable, sensitivity).
- UI Highlight: strength thresholds, fatigue cap, alignment weights, opacity range.
- Table: toggle Fatigue table, decimals, position.
✨ 8) Compatibility & performance notes
- TVD requires supported data for the symbol; if unavailable, DFI can switch to synthetic deltas.
- Smaller LTFs increase request load and may introduce noise; prefer a balanced ratio.
- The indicator is designed to be self-contained; no other overlays are needed to read the outputs.
✨ 9) Limitations and good practice
- This is an oscillator, not a price predictor. Extreme values can persist in strong trends.
- Normalization (Z-score) makes values comparable, but distributions differ across assets/timeframes.
- Always combine with risk management and position sizing; avoid interpreting any single condition as a guarantee.
✨ 10) Disclaimer
This script is for educational purposes only and does not constitute financial advice. Trading involves risk, including possible loss of principal.
---------------------------------------------------------------------------------------------------------------------
한국어 번역 / Korean version below
✨DFI란 무엇인가?
DFI는 시장의 매수·매도 우위를 Flow(흐름) 형태로 분석하여
그 에너지를 정규화된 오실레이터로 표현하는 지표입니다.
가격의 단순 변동이 아니라, “얼마나 일관성 있는 압력(Flow)이 유지되는가”를 보여줍니다.
- DFI > 0: 매수세 우위 (상방 압력)
- DFI < 0: 매도세 우위 (하방 압력)
- 값의 크기: 모멘텀의 강도 (Z-score 기반 정규화)
기본 방식인 True Volume Delta (TVD)는 상위 봉(Anchor) 내부의 하위 타임프레임(LTF) 데이터를 스캔해
실제 매수/매도 체결량 차이를 계산합니다.
이로써 단순 가격 변화가 아닌 실제 체결 흐름의 방향성을 반영합니다.
✨DFI의 계산 과정 (개념적 흐름)
1. Flow 계산 (TVD 또는 대체 방식)
- ta.requestVolumeDelta()를 사용하여 상·하위 TF간 볼륨 델타를 계산합니다.
- TVD 미지원 심볼은 자동으로 Synthetic Delta Volume 등 대체 방식으로 전환됩니다.
2. 누적(CVD) 구성
- Flow를 CVD처럼 누적하여 순매수/순매도 압력을 누적 추적합니다.
3. 고역통과(High-pass) 필터
- 누적 흐름(CVD)에서 장기 추세 성분을 제거하여 순수한 변동 에너지만 남깁니다.
4. Z-score 정규화
- 평균과 표준편차로 표준화해 DFI의 크기를 **일정한 스케일(0 중심)**로 만듭니다.
- 다른 종목·시간대 간 비교가 용이합니다.
5. SuperTrend 레짐(추세 상태) 인식
- ATR 기반 ST(기본: Length=5, Factor=6)를 통해 시장이 상승/하락/중립 중 어디에 있는지를 감지합니다.
- DFI 컬럼 색상 및 알림은 이 ST 방향에 따라 동작합니다
6. Fatigue% (피로도 지수)
- 최근 에너지 평균과 역사적 피크(감쇠)를 비교해 0~100%로 “신선도”를 표현합니다.
- 높을수록 피로한 상태, 낮을수록 신선한 추세.
- 또한 변동성과 정렬 여부에 따라 Adaptive Half-Life로 감쇠 속도가 자동 조정됩니다.
7. 그라디언트 하이라이트 (Gradient Highlight)
- DFI 강도(|DFI|), Fatigue%, 레짐 정렬 상태를 종합해 히스토그램의 투명도를 연속적으로 변화시킵니다.
- 강하고 신선하며 정렬된 추세일수록 더 진하게 표시, 반대로 약하거나 피로한 구간은 흐리게 표시됩니다.
✨DFI 차트 해석법
DFI 히스토그램 (컬럼):
- 위로 향한 초록색 = 매수 우위,
- 아래로 향한 빨강색 = 매도 우위.
- 진할수록 “신뢰도 높은 흐름(Aligned + Low Fatigue)”
- 흐릴수록 “노이즈성 움직임 / 피로 구간”
Signal 선:
- DFI의 EMA.
- DFI와의 교차는 모멘텀 전환 신호로 사용.
Zero 선:
- 추세 전환의 기준선.
Fatigue Table:
- Fatigue%, Regime, Flow Method 정보를 실시간 표시.
✨알림 조건 (Alerts)
- DFI Long Thrust: 상승 레짐에서 DFI가 0 위로 돌파.
- DFI Short Thrust: 하락 레짐에서 DFI가 0 아래로 돌파.
- Loss of Momentum (Up): DFI>0 상태에서 Signal 아래로 하락.
- Loss of Momentum (Down): DFI<0 상태에서 Signal 위로 상승.
TVD (True Volume Delta) 설정 가이드
TVD는 Anchor:LowerTF = 약 30~120배 비율이 가장 효율적입니다.
- 1시간봉 -> 30초~2분
- 4시간봉 -> 2~8분
- 일봉(1D) -> 12~48분
- 주봉(1W) -> 1~4시간
- 월봉(1M) -> 4시간~ 1일
참고:
일부 거래소는 초 단위를 지원하지 않습니다 → 분 단위로 대체.
너무 짧은 LTF → 과부하/노이즈,
너무 긴 LTF → 신호 지연/정밀도 저하.
✨활용 전략 예시
추세 추종 (Trend-following):
- Up Regime에서 DFI>0 & Fatigue% 낮을 때 롱 신호 우선.
- DFI가 Signal 위로 돌파하는 시점이 thrust 시작점.
리스크 축소 (De-risking):
- Fatigue%가 80~90 이상이면 추세 과열로 간주.
- DFI가 Signal을 역방향으로 교차 시 포지션 축소 고려.
횡보 회피:
- DFI가 0선 부근에서 얕게 진동하며 흐릿하게 표시될 때는
- 방향성이 약한 구간 → 진입 회피.
✨한계 및 권장 사용법
- TVD는 심볼/거래소의 지원 여부에 따라 제한될 수 있습니다.
- Z-score 정규화로 수치 간 비교는 용이하지만, 자산마다 분포 특성이 달라 절대값 해석은 주의 필요.
- Fatigue%는 “모멘텀 신선도” 개념이지, 반전 타이밍이 아닙니다.
- 리스크 관리 및 전략적 컨텍스트 안에서 사용하세요.
✨면책 (Disclaimer)
이 스크립트는 교육용 도구(Educational purpose)이며,
투자 조언(Financial advice)이 아닙니다.
모든 트레이딩에는 손실의 위험이 있으며,
DFI의 신호나 수치가 수익을 보장하지 않습니다.
✨정리
DFI는 단순한 “추세 오실레이터”가 아니라,
에너지의 흐름 + 피로도 + 레짐 정렬이라는 3요소를 결합해
“지속 가능한 방향성”을 시각적으로 표현하는 지표입니다.
즉, 단순한 ‘방향’이 아니라 “추세의 질(Quality)”을 보여주는
새로운 형태의 Flow 분석 도구입니다.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
