Sponsored
Market Phase Cycle Indicator (Wyckoff‑Style Histogram)
It uses a blend of EMA crossovers (trend) and RSI thresholds (momentum) to classify the market into four phases.
Sponsored Insight
Indicator Code
thinkscript# =============================
# Market Phase Histogram
#Author NiceBreakout.Com
# =============================
declare lower;
input fastLength = 8;
input slowLength = 21;
input rsiLength = 14;
input overbought = 75;
input oversold = 25;
input price = close;
def fastEMA = ExpAverage(price, fastLength);
def slowEMA = ExpAverage(price, slowLength);
def rsi = RSI(price = price, length = rsiLength);
def isAccumulation = rsi < 40 and price >= slowEMA;
def isMarkup = fastEMA > slowEMA and rsi > 45 and rsi < overbought;
def isDistribution = rsi > 70 and price < fastEMA;
def isMarkdown = fastEMA < slowEMA and rsi < 55 and rsi > oversold;
def phase = if isAccumulation then 1
else if isMarkup then 2
else if isDistribution then 3
else if isMarkdown then 4
else 0;
plot MarketPhase = phase;
MarketPhase.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
MarketPhase.SetLineWeight(3);
MarketPhase.AssignValueColor(
if phase == 1 then Color.GREEN
else if phase == 2 then Color.DARK_GREEN
else if phase == 3 then Color.RED
else if phase == 4 then Color.DARK_RED
else Color.BLUE
);
AddLabel(yes,
"Current Phase: " +
(if phase == 1 then "Accumulation"
else if phase == 2 then "Markup"
else if phase == 3 then "Distribution"
else if phase == 4 then "Markdown"
else "Neutral"),
if phase == 1 then Color.GREEN
else if phase == 2 then Color.DARK_GREEN
else if phase == 3 then Color.RED
else if phase == 4 then Color.DARK_RED
else Color.BLUE
);
# =============================
# Buy/Sell Scan Outputs
# =============================
def buySignal = phase == 2 and phase[1] != 2;
def sellSignal = phase == 4 and phase[1] != 4;
plot ScanBuy = buySignal;
plot ScanSell = sellSignal;
Original Author Credit
Created by: NiceBreakout
Website: https://www.Nicebreakout.com
Social: https://www.reddit.com/r/NiceBreakout/
Open ThinkorSwim and go to Charts > Studies (fx).
Click Edit Studies > then Create New Study.
Name your indicator (e.g., "My Custom Indicator").
Paste the ThinkScript code into the editor.
Click OK, then Apply to add it to your chart.
The lower histogram is a market phase classifier. It takes two inputs — trend (via fast and slow EMAs) and momentum (via RSI) — and reduces them into a simple cycle model. Each bar in the histogram is color‑coded to show which phase the market is currently in:
- Green (Accumulation): Market is basing after weakness. RSI is low but price is holding above the slow EMA. This suggests potential bottoming behavior.
- Dark Green (Markup): Fast EMA is above the slow EMA and RSI is supportive but not overbought. This is the bullish trending phase.
- Red (Distribution): RSI is high (overbought) but price is slipping below the fast EMA. This suggests topping or exhaustion.
- Dark Red (Markdown): Fast EMA is below the slow EMA and RSI is weak. This is the bearish trending phase.
- Blue (Neutral): None of the conditions are met. The market is in between phases, with no clear signal.
The histogram values are simply 1, 2, 3, or 4 (or 0 for neutral), but the colors make it easy to see which phase is active.
What to Look Out For
- Phase Transitions The most important thing is when the histogram changes color. A flip from green to dark green means the market is moving from basing into an uptrend. A flip from dark green to red means the uptrend is stalling and distribution is starting. These transitions are where the indicator is most informative.
- Sustained Phases Long stretches of dark green bars indicate a healthy bullish trend. Long stretches of dark red bars indicate a persistent bearish trend. These stretches can be used as a trend filter — for example, only taking long trades during markup phases.
- Neutral Periods Blue bars mean the conditions don’t fit any phase. This often happens in choppy or sideways markets. It’s a warning that the indicator doesn’t see a clear edge.
- False Starts Because the logic is based on EMAs and RSI, you may see quick flips between phases in volatile or low‑volume conditions. These are worth noting as noise rather than strong signals.
- Context Matters The histogram is not a standalone trading system. It’s best used as a market context tool — telling you whether the environment is bullish, bearish, topping, or bottoming. You can then layer your own setups on top of that context.
Sponsored
Note: This indicator code is provided free for educational purposes. Test thoroughly before using in live trading.
Legal Disclaimer & Risk Warning
Educational Purpose: This code is provided for educational and informational purposes only. It does not constitute financial, investment, or trading advice.
No Performance Guarantee: Past performance is not indicative of future results. Trading involves substantial risk, including potential loss of capital.
Test Thoroughly: Always test indicators in a paper trading environment before using real money. Verify compatibility with your platform version.
Use at Your Own Risk: You are solely responsible for your trading decisions. We are not liable for any losses resulting from use of this code.
Attribution: If you share or modify this code, please maintain proper attribution to the original author.
By using this code, you acknowledge understanding and acceptance of these terms.