OPEN-SOURCE SCRIPT
ที่อัปเดต: kitsdih

**CMD Unified v4.4.3 — Alpha Engine Export**
CMD Unified is a directional bias indicator built on asymmetric bull/bear divergence architecture. It uses a K-Nearest Neighbors classifier trained on live market geometry to identify when bull and bear momentum are structurally diverging, then emits a directional code — Long, Short, or Neutral — only when a multi-layer validity gate is satisfied.
**How it works**
The engine tracks two independent centroid populations: bull-side and bear-side. At each bar it measures the Mahalanobis distance of current price action to each centroid cluster and scores divergence using a z-normalized delta oscillator. A directional fire is triggered only when the dominant side crosses a configurable confidence threshold and the KNN classifier has accumulated sufficient training samples.
A hold-latch mechanism sustains the last directional code for a user-defined number of bars after a crossover, smoothing signal choppiness without introducing look-ahead bias.
**Exports for cross-script consumption**
The indicator publishes three plots readable by a companion strategy via `input.source`:
- **KTS_STATE** — directional code: 1 = Long, 2 = Short, 0 = Neutral, 3 = gate not satisfied
- **KTS_STRENGTH** — signed signal strength, z-normalized and tanh-compressed, scaled by transfer entropy reliability
- **KTS_RANGE** — range-position context: negative = coiled/absorption, positive = expansion/exhaustion
**Intended use**
Designed as one component of a multi-signal combiner. Works best on liquid perpetual futures at 15m–4H timeframes with at least 500 bars of warmup history.
Release Note
i'm working on simplifying it to make comprehensible, hold on. สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน