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.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน