OPEN-SOURCE SCRIPT
Post 9/21 EMA Cross — Paint X Bars v2.0

# **Post 9/21 EMA Cross — Time Blocks & Session Colors**
This indicator highlights candles after a **9/21 EMA crossover**, but with extra controls that let you focus only on the sessions and time windows that matter to you.
---
## 🔑 What It Does
1. **EMA Cross Trigger**
* Bullish trigger: 9 EMA crosses above 21 EMA.
* Bearish trigger: 9 EMA crosses below 21 EMA.
2. **Bar Painting**
* After a valid cross, the indicator paints a set number of bars (you choose how many).
* You can require the **2nd bar to confirm momentum** (“displacement” filter) so weak signals are ignored.
3. **Time Block Control**
* Define up to **four custom time blocks** (like `08:00–09:30` or `12:00–13:00`).
* Painting only occurs inside those blocks if you enable the filter.
4. **Session-Aware Colors**
* Use one set of bullish/bearish colors for **regular hours**, another set for **pre-market**, and another for **post-market**.
* That way you can instantly see *when* the signal occurred.
---
## 🎨 Visuals
* Candles recolored in your chosen bull/bear colors.
* Optional EMA lines plotted on the chart for reference.
* Different colors for RTH, pre-market, and post-market activity.
---
## ⚙️ Inputs
* **EMA lengths (fast & slow)**
* **Number of bars to paint after a cross**
* **Displacement filter (loose or strict)**
* **Show/hide EMA lines**
* **Up to four custom time blocks** (on/off toggles + start/end times)
* **Bull/bear colors for RTH, Pre, Post**
---
## 📈 Why Use It
* **Clarity** – Only shows cross signals in the hours you actually trade.
* **Focus** – Different colors remind you at a glance whether the move was in pre-market, RTH, or post-market.
* **Discipline** – The optional 2nd-bar displacement filter prevents false starts by requiring real momentum.
---
## 🚨 Practical Use
* Treat the painted window as a **momentum phase**: enter on confirmation, manage risk while bars are painted, and stand aside once painting ends.
* Restrict painting to time blocks that match your personal trading routine (e.g., open drive 09:30–10:00, or late-day momentum 15:00–16:00).
* Use session colors to keep pre/post-market action separate from regular session strategies.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.