OPEN-SOURCE SCRIPT
Market Mode Risk Indicator

Market Mode Risk Indicator v1.1
This custom indicator helps traders gauge market risk sentiment by monitoring Exponential Moving Average (EMA) or Simple Moving Average (SMA) crossovers on key indices like BIST 100 (for Turkish markets), NASDAQ Composite (tech-focused US), or Dow Jones Industrial Average (industrial US). It dynamically categorizes the market into three actionable modes based on the index's position relative to layered MAs, providing a quick visual snapshot without cluttering your chart.
Risk Modes Explained:
RISK OFF (Red): Index closes below the Long MA (default 50 periods) – signals bearish caution; time to tighten stops or reduce exposure.
RISK TEST (Orange): Index above Medium MA1 (21 periods) and Extra Long MA (55 periods), but below Short MA (10 periods) and above Long MA – a transitional "test" phase; watch for confirmation before entering.
RISK ON (Green): Index above all MAs (Short, Medium, Long, Extra Long) – bullish green light; favorable for longs or momentum plays.
How It Works:
The core logic uses boolean checks on the index's close price against user-defined MA lengths. For example:
It pulls live data from your selected index via request.security.
Computes MAs with ternary operators for EMA (ta.ema) or SMA (ta.sma) based on your choice.
Mode detection relies on AND/OR conditions (e.g., aboveShort and aboveMed1 and aboveLong and aboveExtraLong for RISK ON) to filter noise and focus on meaningful shifts.
No lookahead bias – all calculations are historical and real-time compatible. Defaults (10/21/50/55) are inspired by common Fibonacci-inspired periods for balanced sensitivity.
Alerts fire only on mode transitions (e.g., from RISK OFF to ON) to prevent spam, using alertcondition with dynamic messages including price and ticker.
Customization Options:
Index & MA Settings: Switch EMA/SMA; tweak lengths (min 1 period) for your timeframe (e.g., shorter for intraday).
Display: Position the table (top/bottom, left/right); toggle MA values on/off.
Looks: Background/border/text colors, transparency (0-100%) for theme matching.
Built in Pine Script v5 for efficiency – lightweight, no repaints.
Usage Tips:
Add to any stock chart (e.g., GARAN for BIST analysis).
Select your index in settings; refresh chart if switching MA type.
Use on daily/4H timeframes for swing trading; alerts via email/SMS for hands-free monitoring.
Pro Tip: Combine with volume or RSI for confirmation – RISK ON + rising volume = stronger buy signal.
This custom indicator helps traders gauge market risk sentiment by monitoring Exponential Moving Average (EMA) or Simple Moving Average (SMA) crossovers on key indices like BIST 100 (for Turkish markets), NASDAQ Composite (tech-focused US), or Dow Jones Industrial Average (industrial US). It dynamically categorizes the market into three actionable modes based on the index's position relative to layered MAs, providing a quick visual snapshot without cluttering your chart.
Risk Modes Explained:
RISK OFF (Red): Index closes below the Long MA (default 50 periods) – signals bearish caution; time to tighten stops or reduce exposure.
RISK TEST (Orange): Index above Medium MA1 (21 periods) and Extra Long MA (55 periods), but below Short MA (10 periods) and above Long MA – a transitional "test" phase; watch for confirmation before entering.
RISK ON (Green): Index above all MAs (Short, Medium, Long, Extra Long) – bullish green light; favorable for longs or momentum plays.
How It Works:
The core logic uses boolean checks on the index's close price against user-defined MA lengths. For example:
It pulls live data from your selected index via request.security.
Computes MAs with ternary operators for EMA (ta.ema) or SMA (ta.sma) based on your choice.
Mode detection relies on AND/OR conditions (e.g., aboveShort and aboveMed1 and aboveLong and aboveExtraLong for RISK ON) to filter noise and focus on meaningful shifts.
No lookahead bias – all calculations are historical and real-time compatible. Defaults (10/21/50/55) are inspired by common Fibonacci-inspired periods for balanced sensitivity.
Alerts fire only on mode transitions (e.g., from RISK OFF to ON) to prevent spam, using alertcondition with dynamic messages including price and ticker.
Customization Options:
Index & MA Settings: Switch EMA/SMA; tweak lengths (min 1 period) for your timeframe (e.g., shorter for intraday).
Display: Position the table (top/bottom, left/right); toggle MA values on/off.
Looks: Background/border/text colors, transparency (0-100%) for theme matching.
Built in Pine Script v5 for efficiency – lightweight, no repaints.
Usage Tips:
Add to any stock chart (e.g., GARAN for BIST analysis).
Select your index in settings; refresh chart if switching MA type.
Use on daily/4H timeframes for swing trading; alerts via email/SMS for hands-free monitoring.
Pro Tip: Combine with volume or RSI for confirmation – RISK ON + rising volume = stronger buy signal.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน