indicator · own pane · open source
Market Phase Detector
Running…
Loading chart…
About
Market Phase Detector — bins the market into 3 regimes using ADX (trending vs ranging) and MACD histogram (bullish vs bearish): +1 = trending bullish, -1 = trending bearish, 0 = ranging.
- Use to switch strategy: only trend-follow when |phase| = 1.
Source code
//@version=5
indicator("Market Phase Detector", overlay=false)
[plus, minus, adx] = ta.dmi(14, 14)
[m, s, h] = ta.macd(close, 12, 26, 9)
phase = adx > 25 and h > 0 ? 1 : adx > 25 and h < 0 ? -1 : 0
hline(1, "Bull trend", color=color.gray)
hline(-1, "Bear trend", color=color.gray)
p_Phase = plot(phase, "Phase", color=color.blue, style=plot.style_columns, linewidth=2)
alertcondition(phase == 1 and phase[1] != 1, "Bull phase", "Entered bull trend phase")
alertcondition(phase == -1 and phase[1] != -1, "Bear phase", "Entered bear trend phase")
No comments yet.
Sign in to comment.