OPEN-SOURCE SCRIPT

Group 2: Weekly Regime Classifier

81
This indicator classifies the weekly market regime inside monthly value so you know whether to rotate, wait, prepare for expansion, or stand aside before looking for daily trades.

Purpose: Decide whether the market is rotating, compressing, attempting to escape value, or should be avoided entirely.

What this script does

This script analyzes weekly price behavior in the context of your manually defined monthly value area. Its job is to classify the current weekly regime so you know which type of trade logic is even allowed, before you look at daily setups.

It answers one question:

“What kind of environment am I dealing with right now?”

It does not generate trades. It does not choose entries or exits. It tells you whether conditions favor:

value rotation,

expansion attempts,

waiting, or

standing aside due to instability.

How it works (in simple terms)

The script always evaluates weekly candles, even if you apply it to a daily chart.

It uses four ideas:

1. Monthly value containment

All weekly analysis is framed by your monthly VAH and VAL.

If weekly closes are outside monthly value, that matters.

If weekly closes are inside monthly value, that matters differently.

The monthly levels are manual inputs and never auto-calculated.

2. Weekly alternation (instability check)

The script checks the last 6 weekly candles:

If most candles flip direction back and forth, the environment is unstable.

This is labeled “Neutral – heavy alternation”.

In this state, trades should be skipped unless conditions are perfect.

This acts as a sector-level permission filter.

3. Weekly regime classification

Based on quantified rules, the script assigns one regime:

ROTATING (Roadmap A default)
Price is staying inside monthly value and weekly ranges are normal.
This favors mean-reversion and value-to-value trades.

COMPRESSING (Wait)
Weekly ranges and volume are shrinking while price remains inside value.
This signals energy building, but no trade yet.

ESCAPING (Roadmap B on deck)
Weekly closes cluster near one edge of monthly value and show progress toward breaking out.
This sets up possible expansion trades, pending daily confirmation.

WAIT / NEUTRAL
Conditions do not clearly support rotation or expansion.
No bias is assumed.

4. Edge proximity and progress

The script also reports whether price is:

near monthly VAH,

near monthly VAL,

or not near an edge.

For escaping regimes, it checks that price is actually moving closer to the edge, not drifting sideways.

What you see on the chart

Optional background shading by regime (informational only)

Optional monthly and weekly level lines (display only)

A dashboard showing:

current weekly regime,

alternation status,

edge proximity,

weekly RangeRatio,

weekly VolumeRatio,

flip count,

freshness of weekly levels

Nothing on the chart triggers trades or alerts.

How you’re meant to use it

Run this after Group 1

Group 1 answers: Can I trade at all?

Group 2 answers: What type of trading makes sense?

Use the regime to choose a roadmap

ROTATING → value rotation logic (Roadmap A)

ESCAPING → watch for expansion logic (Roadmap B)

COMPRESSING → wait

NEUTRAL → skip unless exceptional

Only then drop to the daily chart
Daily execution rules apply only if the weekly regime allows them.

What this script deliberately does NOT do

No entries

No exits

No targets

No stop logic

No automatic level calculation

No intraday analysis

It does not tell you what to trade.
It tells you what kind of environment you’re in.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.