OPEN-SOURCE SCRIPT

Tokyo Rules v6

467
Tokyo Rules [Rob Booker] v6

Description

Tokyo Rules is a market regime identification system based on Rob Booker's original "Arizona Rules" methodology, re-imagined with Tokyo district names that intuitively reflect each phase of market behavior.

The core idea is simple but powerful: **before deciding how to trade, first decide where you are.** The indicator reads the relationship between three moving averages (EMA 62, SMA 200, SMA 800) to classify the market into one of four phases — each named after a distinct Tokyo district that mirrors its character.



🟡 Ginza — Range Phase
The market is quiet, polished, and going nowhere fast.

EMA 62 is sandwiched between SMA 200 and SMA 800. No clear trend exists. Like Ginza on a slow afternoon — elegant but still. Trade both bullish and bearish MACD divergences; target the nearest moving average.

🔵 Shinagawa — Trend Start Phase
The train is leaving the station.

EMA 62 has crossed SMA 800, but SMA 200 has not yet followed. A new trend is emerging. Like Shinagawa Station — the departure point of the Shinkansen. Trade divergences aligned with the emerging trend direction only; target EMA 62 or SMA 800.

🟢 Shibuya — Trend Continuation Phase
Full energy. All signals aligned.

All three moving averages are fully stacked in order (EMA 62 > SMA 200 > SMA 800 for bullish, or the reverse for bearish). Like Shibuya Scramble Crossing at peak hour — maximum momentum. Trade breakouts or pullback divergences in the trend direction; target SMA 800.

🔴 Roppongi — Chaos Phase
No clear direction. Stay out.

Moving averages are tangled and contradictory. Like Roppongi at 3am — exciting but dangerous. This is a no-trade zone. Step back, drop to a lower timeframe, and look for a Ginza phase there instead.



Divergence Detection

The indicator automatically detects MACD divergences against price pivot highs and lows:

- Bullish Divergence — Price makes a lower low while MACD makes a higher low → potential long opportunity
- Bearish Divergence — Price makes a higher high while MACD makes a lower high → potential short opportunity

Divergence signals are filtered by phase — only signals appropriate to the current market context are shown, reducing noise significantly.

A Stochastic oscillator (9-3-3) provides a second confirmation layer. BUY/SELL triangle markers appear only when both divergence and Stochastic overbought/oversold conditions align simultaneously.



Indicators Used

| Indicator | Settings | Role |
|---|---|---|
| EMA | 62 | Short-term trend & phase pivot |
| SMA | 200 | Mid-term trend reference |
| SMA | 800 | Long-term trend anchor |
| MACD | 12-26-9 | Divergence detection |
| Stochastic | 9-3-3 | Entry confirmation |



Visual Features

- Background color changes with each phase for instant recognition
- Phase labels appear on the chart at every phase transition
- Divergence lines drawn directly on price with phase name tags
- Info table (top-right) shows current phase, direction, MA values, and Stoch %K in real time
- 3 built-in alerts: Bullish Divergence, Bearish Divergence, Phase Change



Recommended Usage

- Timeframe: 1H (primary), 15M (secondary / drill-down from Roppongi phase)
- Markets: Forex, indices, crypto — any liquid instrument with sufficient history for SMA 800
- Note: SMA 800 requires at least 800 bars of history. Use a timeframe and symbol with sufficient data loaded.



Settings

All parameters are fully adjustable via the Inputs panel:

- MA periods (EMA 62 / SMA 200 / SMA 800)
- MACD settings (Fast / Slow / Signal)
- Divergence pivot sensitivity (Left / Right bars)
- Stochastic settings and OB/OS thresholds
- Display toggles (background, MAs, labels, divergence lines)



Credits

Original concept: Rob Booker — "The Arizona Rules" (2007)
Tokyo district adaptation & Pine Script v6 implementation by the author.

This indicator is a creative reinterpretation of Rob Booker's market phase framework. The underlying logic is faithful to the original methodology; only the naming convention has been adapted.



This indicator is for educational and informational purposes only. It does not constitute financial advice. Always apply your own risk management.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。