OPEN-SOURCE SCRIPT
MARS V4.0

MARS 4.0 is a trend-structure and portfolio management framework designed to identify, classify, and manage equity trends through their full lifecycle.
Rather than functioning as a traditional buy/sell indicator, MARS 4.0 acts as a market regime engine that evaluates:
structural trend quality,
trend maturity,
price extension,
trend efficiency,
portfolio suitability,
and capital deployment opportunity.
The system is built around the principle that:
“A good stock is not always a good entry.”
MARS 4.0 distinguishes between:
early-stage developing trends,
mature structural leaders,
deteriorating trends,
repair/recovery phases,
and excessively extended momentum conditions.
This allows the framework to support:
portfolio construction,
risk management,
capital rotation,
watchlist prioritisation,
and discretionary decision-making.
Core Components
Trend Structure Engine
The script evaluates:
fast trend alignment,
slow structural trend alignment,
moving average relationships,
persistence of trend behaviour,
and pullback integrity.
This creates a dynamic classification of market state.
Trend Maturity Analysis
MARS 4.0 measures how developed a trend has become.
Early trends may offer:
better asymmetry,
lower extension risk,
and stronger future upside potential.
Mature trends may still be strong holdings but require:
reduced aggression,
tighter risk control,
and careful position sizing.
Extension & Risk Framework
The system measures extension using ATR-based distance from equilibrium.
This helps identify:
chase-risk conditions,
exhaustion phases,
elevated volatility risk,
and poor reward-to-risk entries.
Rather than blindly rewarding strength, MARS evaluates whether:
the move is still investable,
or already overcrowded and statistically stretched.
Portfolio Classification System
The framework classifies securities into operational portfolio states such as:
Core Hold
Hold / Wait
Watchlist / Repair
Reduce Aggression
Avoid / No Action
This converts technical structure into practical portfolio guidance.
MARS 4.0 Scanner Engine
MARS 4.0 introduces hidden quantitative outputs that allow the framework to operate as a ranking and scanning engine.
MARS4 Alpha Score
A composite quality score combining:
regime strength,
maturity,
efficiency,
opportunity quality,
and extension risk.
Higher scores indicate stronger deployable trend quality.
MARS4 Scan State
A simplified operational state model:
State Meaning
0 Neutral
1 Watchlist / Repair
2 Fresh Money OK
3 Early Trend
4 Core Hold
5 Reduce / Avoid
This enables:
portfolio triage,
systematic scanning,
and capital allocation workflows.
Intended Use
MARS 4.0 is designed for:
swing traders,
trend-following investors,
discretionary portfolio managers,
and long-term equity trend analysis.
The framework is particularly effective for:
weekly timeframe analysis,
portfolio rotation,
and identifying institutional-quality trend behaviour.
Design Philosophy
MARS 4.0 prioritises:
clarity over complexity,
structure over prediction,
and risk-adjusted opportunity rather than pure momentum.
The system intentionally avoids excessive indicator stacking and instead focuses on refining:
trend behaviour,
market structure,
extension dynamics,
and portfolio context.
The objective is not to predict markets, but to:
systematically identify where risk/reward conditions are most favourable across the trend lifecycle.
Rather than functioning as a traditional buy/sell indicator, MARS 4.0 acts as a market regime engine that evaluates:
structural trend quality,
trend maturity,
price extension,
trend efficiency,
portfolio suitability,
and capital deployment opportunity.
The system is built around the principle that:
“A good stock is not always a good entry.”
MARS 4.0 distinguishes between:
early-stage developing trends,
mature structural leaders,
deteriorating trends,
repair/recovery phases,
and excessively extended momentum conditions.
This allows the framework to support:
portfolio construction,
risk management,
capital rotation,
watchlist prioritisation,
and discretionary decision-making.
Core Components
Trend Structure Engine
The script evaluates:
fast trend alignment,
slow structural trend alignment,
moving average relationships,
persistence of trend behaviour,
and pullback integrity.
This creates a dynamic classification of market state.
Trend Maturity Analysis
MARS 4.0 measures how developed a trend has become.
Early trends may offer:
better asymmetry,
lower extension risk,
and stronger future upside potential.
Mature trends may still be strong holdings but require:
reduced aggression,
tighter risk control,
and careful position sizing.
Extension & Risk Framework
The system measures extension using ATR-based distance from equilibrium.
This helps identify:
chase-risk conditions,
exhaustion phases,
elevated volatility risk,
and poor reward-to-risk entries.
Rather than blindly rewarding strength, MARS evaluates whether:
the move is still investable,
or already overcrowded and statistically stretched.
Portfolio Classification System
The framework classifies securities into operational portfolio states such as:
Core Hold
Hold / Wait
Watchlist / Repair
Reduce Aggression
Avoid / No Action
This converts technical structure into practical portfolio guidance.
MARS 4.0 Scanner Engine
MARS 4.0 introduces hidden quantitative outputs that allow the framework to operate as a ranking and scanning engine.
MARS4 Alpha Score
A composite quality score combining:
regime strength,
maturity,
efficiency,
opportunity quality,
and extension risk.
Higher scores indicate stronger deployable trend quality.
MARS4 Scan State
A simplified operational state model:
State Meaning
0 Neutral
1 Watchlist / Repair
2 Fresh Money OK
3 Early Trend
4 Core Hold
5 Reduce / Avoid
This enables:
portfolio triage,
systematic scanning,
and capital allocation workflows.
Intended Use
MARS 4.0 is designed for:
swing traders,
trend-following investors,
discretionary portfolio managers,
and long-term equity trend analysis.
The framework is particularly effective for:
weekly timeframe analysis,
portfolio rotation,
and identifying institutional-quality trend behaviour.
Design Philosophy
MARS 4.0 prioritises:
clarity over complexity,
structure over prediction,
and risk-adjusted opportunity rather than pure momentum.
The system intentionally avoids excessive indicator stacking and instead focuses on refining:
trend behaviour,
market structure,
extension dynamics,
and portfolio context.
The objective is not to predict markets, but to:
systematically identify where risk/reward conditions are most favourable across the trend lifecycle.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน