OPEN-SOURCE SCRIPT
Market Health Indicator

# Market Health Indicator - Documentation
## Overview
The Market Health Indicator is a Pine Script technical analysis tool designed for TradingView that evaluates overall market conditions by analyzing the relationship between price and three Exponential Moving Averages (EMAs), as well as the relationships between the EMAs themselves. The indicator provides a quantitative score and actionable investment recommendations.
---
## Purpose
This indicator helps traders and investors:
- Assess the overall health and trend strength of a market or security
- Make informed decisions about position sizing
- Identify bullish, bearish, or neutral market conditions
- Determine when to increase, reduce, or exit positions
---
## Scoring Methodology
### Scoring System
The indicator evaluates **6 conditions**, each contributing either **+1** or **-1** to the total score:
#### Price vs EMA Conditions (3 conditions)
1. **Price vs EMA 21**
- Price > EMA 21 → +1
- Price < EMA 21 → -1
2. **Price vs EMA 50**
- Price > EMA 50 → +1
- Price < EMA 50 → -1
3. **Price vs EMA 100**
- Price > EMA 100 → +1
- Price < EMA 100 → -1
#### EMA Relationship Conditions (3 conditions)
4. **EMA 21 vs EMA 100**
- EMA 21 > EMA 100 → +1
- EMA 21 < EMA 100 → -1
5. **EMA 21 vs EMA 50**
- EMA 21 > EMA 50 → +1
- EMA 21 < EMA 50 → -1
6. **EMA 50 vs EMA 100**
- EMA 50 > EMA 100 → +1
- EMA 50 < EMA 100 → -1
### Total Score Range
- **Minimum Score**: -6 (all conditions bearish)
- **Maximum Score**: +6 (all conditions bullish)
---
## Market Health Status
Based on the total score, the indicator assigns one of five market health statuses:
| Score Range | Status | Interpretation |
|-------------|--------|----------------|
| 4 to 6 | **Strong Bullish** | All or most conditions favor upward momentum |
| 2 to 3 | **Bullish** | Majority of conditions are positive |
| -1 to 1 | **Neutral** | Mixed signals, no clear directional bias |
| -3 to -2 | **Bearish** | Majority of conditions are negative |
| -6 to -4 | **Strong Bearish** | All or most conditions favor downward momentum |
---
## Investment Level Recommendations
The indicator provides position sizing recommendations based on the score:
| Score Range | Investment Level | Action |
|-------------|-----------------|--------|
| 4 to 6 | **100% Invested** | Maximum exposure - strong bullish conditions |
| 2 to 3 | **75% Invested** | High exposure - moderately bullish conditions |
| 0 to 1 | **50% Invested** | Moderate exposure - neutral to slightly positive conditions |
| Below 0 | **Exit Weak Stocks** | Reduce exposure - bearish conditions, exit underperforming positions |
---
## Installation & Setup
### Installation Steps
1. Open TradingView and navigate to any chart
2. Click on **Pine Editor** at the bottom of the screen
3. Copy the entire Pine Script code
4. Paste it into the Pine Editor
5. Click **"Add to Chart"**
### Configuration Options
The indicator includes two customizable settings accessible via the settings gear icon:
#### 1. Table Position
Choose where the indicator table appears on your chart:
- **Top**: top_left, top_center, top_right
- **Middle**: middle_left, middle_center, middle_right
- **Bottom**: bottom_left, bottom_center, bottom_right
**Default**: top_right
#### 2. Table Size
Adjust the text size of the indicator table:
- **tiny**: Smallest text size
- **small**: Small text size
- **normal**: Standard text size (default)
- **large**: Large text size
- **huge**: Largest text size
**Default**: normal
---
## Understanding the Display
### Table Components
The indicator displays a table with the following rows:
1. **Header Row (Colored)**
- Left cell: Market Health status
- Right cell: Current score out of 6
- Color indicates market condition (green = bullish, yellow = neutral, red = bearish)
2. **Investment Level Row (Blue)**
- Shows recommended position sizing based on current score
- Helps with portfolio management decisions
3. **Column Headers (Gray)**
- "Condition" - describes each evaluation criteria
- "Score" - shows the +1 or -1 value
4. **Condition Rows (6 rows)**
- Each row shows one of the 6 scoring conditions
- Left column: condition description
- Right column: score value (+1 in green or -1 in red)
---
## Interpretation Guidelines
### Strong Bullish (Score 4-6)
**Characteristics:**
- Price trading above all major EMAs
- EMAs aligned in bullish order (21 > 50 > 100)
- Strong upward momentum
**Action:**
- Maintain full exposure (100% invested)
- Consider adding to winning positions
- Look for pullbacks as buying opportunities
### Bullish (Score 2-3)
**Characteristics:**
- Price above most EMAs
- Generally positive EMA alignment
- Moderate upward trend
**Action:**
- Maintain high exposure (75% invested)
- Hold existing positions
- Be selective with new entries
### Neutral (Score -1 to 1)
**Characteristics:**
- Mixed signals from price and EMAs
- No clear trend direction
- Market indecision
**Action:**
- Reduce exposure to 50%
- Wait for clearer signals
- Focus on risk management
- Consider range-bound strategies
### Bearish (Score -2 to -3)
**Characteristics:**
- Price below most EMAs
- Generally negative EMA alignment
- Moderate downward trend
**Action:**
- Exit weak positions
- Reduce overall exposure
- Raise cash levels
- Protect capital
### Strong Bearish (Score -4 to -6)
**Characteristics:**
- Price trading below all major EMAs
- EMAs aligned in bearish order (21 < 50 < 100)
- Strong downward momentum
**Action:**
- Exit weak stocks immediately
- Minimal to no long exposure
- Preserve capital
- Wait for market conditions to improve
---
## Best Practices
### Usage Tips
1. **Timeframe Selection**
- Works on all timeframes
- Higher timeframes (daily, weekly) provide more reliable signals
- Lower timeframes (intraday) may generate more frequent signals but with higher noise
2. **Combine with Other Analysis**
- Use as a component of a comprehensive trading strategy
- Complement with support/resistance levels
- Consider volume and other momentum indicators
- Factor in fundamental analysis for longer-term positions
3. **Position Sizing**
- Treat investment level recommendations as guidelines, not rigid rules
- Adjust based on your risk tolerance and account size
- Consider your overall portfolio allocation
4. **Risk Management**
- Always use stop losses regardless of indicator reading
- Don't ignore risk management during "Strong Bullish" periods
- The indicator shows trend, not specific entry/exit points
### Limitations
- **Lagging Nature**: EMAs are lagging indicators, so signals may come after trend changes have begun
- **Whipsaw Risk**: In choppy, sideways markets, the indicator may generate mixed signals
- **Not a Standalone System**: Should be used as part of a broader trading strategy
- **No Predictive Power**: Shows current conditions, not future direction
- **Market Context**: May need adjustment during extreme market conditions or unusual volatility
---
## Technical Details
### EMA Calculations
The indicator uses three standard Exponential Moving Averages:
- **EMA 21**: Short-term trend (approximately 1 month of trading days)
- **EMA 50**: Medium-term trend (approximately 2.5 months)
- **EMA 100**: Long-term trend (approximately 5 months)
EMAs give more weight to recent prices compared to Simple Moving Averages (SMAs), making them more responsive to price changes.
### Update Frequency
- The indicator recalculates on every bar close
- Real-time updates during the current bar formation
- Table displays the most recent completed bar data
### Performance
- Lightweight indicator with minimal computational overhead
- Suitable for use with multiple charts simultaneously
- No historical data storage required beyond standard EMA calculations
---
## Frequently Asked Questions
**Q: Can I change the EMA periods (21, 50, 100)?**
A: The current version uses fixed EMA periods. Modifying these would require editing the Pine Script code directly.
**Q: Does this indicator work on all assets?**
A: Yes, it works on stocks, forex, cryptocurrencies, commodities, and indices - any asset with price data.
**Q: Can I use this for day trading?**
A: Yes, but it's designed for swing trading and position trading. For day trading, consider using lower timeframes and being aware of increased signal noise.
**Q: What if the score keeps changing?**
A: Frequent score changes indicate a choppy or transitional market. Consider waiting for a more stable reading before taking action.
**Q: Should I exit ALL positions when score is negative?**
A: The recommendation is to "Exit Weak Stocks" - focus on underperforming positions. Strong stocks may still be held with appropriate stop losses.
**Q: Can I get alerts based on score changes?**
A: The current version doesn't include alerts, but this functionality could be added with Pine Script modifications.
---
## Version History
**Version 1.0**
- Initial release
- 6-condition scoring system
- Investment level recommendations
- Customizable table position and size
- Overlay on main chart
---
## Support & Feedback
For questions, suggestions, or issues with the indicator:
- Review this documentation thoroughly
- Test the indicator on historical data before live trading
- Adjust settings to match your chart layout preferences
- Always paper trade new strategies before risking real capital
---
## Disclaimer
This indicator is provided for educational and informational purposes only. It does not constitute financial advice, investment advice, trading advice, or any other type of advice. Trading and investing involve substantial risk of loss. Past performance is not indicative of future results. Always do your own research and consult with a qualified financial advisor before making investment decisions.
## Overview
The Market Health Indicator is a Pine Script technical analysis tool designed for TradingView that evaluates overall market conditions by analyzing the relationship between price and three Exponential Moving Averages (EMAs), as well as the relationships between the EMAs themselves. The indicator provides a quantitative score and actionable investment recommendations.
---
## Purpose
This indicator helps traders and investors:
- Assess the overall health and trend strength of a market or security
- Make informed decisions about position sizing
- Identify bullish, bearish, or neutral market conditions
- Determine when to increase, reduce, or exit positions
---
## Scoring Methodology
### Scoring System
The indicator evaluates **6 conditions**, each contributing either **+1** or **-1** to the total score:
#### Price vs EMA Conditions (3 conditions)
1. **Price vs EMA 21**
- Price > EMA 21 → +1
- Price < EMA 21 → -1
2. **Price vs EMA 50**
- Price > EMA 50 → +1
- Price < EMA 50 → -1
3. **Price vs EMA 100**
- Price > EMA 100 → +1
- Price < EMA 100 → -1
#### EMA Relationship Conditions (3 conditions)
4. **EMA 21 vs EMA 100**
- EMA 21 > EMA 100 → +1
- EMA 21 < EMA 100 → -1
5. **EMA 21 vs EMA 50**
- EMA 21 > EMA 50 → +1
- EMA 21 < EMA 50 → -1
6. **EMA 50 vs EMA 100**
- EMA 50 > EMA 100 → +1
- EMA 50 < EMA 100 → -1
### Total Score Range
- **Minimum Score**: -6 (all conditions bearish)
- **Maximum Score**: +6 (all conditions bullish)
---
## Market Health Status
Based on the total score, the indicator assigns one of five market health statuses:
| Score Range | Status | Interpretation |
|-------------|--------|----------------|
| 4 to 6 | **Strong Bullish** | All or most conditions favor upward momentum |
| 2 to 3 | **Bullish** | Majority of conditions are positive |
| -1 to 1 | **Neutral** | Mixed signals, no clear directional bias |
| -3 to -2 | **Bearish** | Majority of conditions are negative |
| -6 to -4 | **Strong Bearish** | All or most conditions favor downward momentum |
---
## Investment Level Recommendations
The indicator provides position sizing recommendations based on the score:
| Score Range | Investment Level | Action |
|-------------|-----------------|--------|
| 4 to 6 | **100% Invested** | Maximum exposure - strong bullish conditions |
| 2 to 3 | **75% Invested** | High exposure - moderately bullish conditions |
| 0 to 1 | **50% Invested** | Moderate exposure - neutral to slightly positive conditions |
| Below 0 | **Exit Weak Stocks** | Reduce exposure - bearish conditions, exit underperforming positions |
---
## Installation & Setup
### Installation Steps
1. Open TradingView and navigate to any chart
2. Click on **Pine Editor** at the bottom of the screen
3. Copy the entire Pine Script code
4. Paste it into the Pine Editor
5. Click **"Add to Chart"**
### Configuration Options
The indicator includes two customizable settings accessible via the settings gear icon:
#### 1. Table Position
Choose where the indicator table appears on your chart:
- **Top**: top_left, top_center, top_right
- **Middle**: middle_left, middle_center, middle_right
- **Bottom**: bottom_left, bottom_center, bottom_right
**Default**: top_right
#### 2. Table Size
Adjust the text size of the indicator table:
- **tiny**: Smallest text size
- **small**: Small text size
- **normal**: Standard text size (default)
- **large**: Large text size
- **huge**: Largest text size
**Default**: normal
---
## Understanding the Display
### Table Components
The indicator displays a table with the following rows:
1. **Header Row (Colored)**
- Left cell: Market Health status
- Right cell: Current score out of 6
- Color indicates market condition (green = bullish, yellow = neutral, red = bearish)
2. **Investment Level Row (Blue)**
- Shows recommended position sizing based on current score
- Helps with portfolio management decisions
3. **Column Headers (Gray)**
- "Condition" - describes each evaluation criteria
- "Score" - shows the +1 or -1 value
4. **Condition Rows (6 rows)**
- Each row shows one of the 6 scoring conditions
- Left column: condition description
- Right column: score value (+1 in green or -1 in red)
---
## Interpretation Guidelines
### Strong Bullish (Score 4-6)
**Characteristics:**
- Price trading above all major EMAs
- EMAs aligned in bullish order (21 > 50 > 100)
- Strong upward momentum
**Action:**
- Maintain full exposure (100% invested)
- Consider adding to winning positions
- Look for pullbacks as buying opportunities
### Bullish (Score 2-3)
**Characteristics:**
- Price above most EMAs
- Generally positive EMA alignment
- Moderate upward trend
**Action:**
- Maintain high exposure (75% invested)
- Hold existing positions
- Be selective with new entries
### Neutral (Score -1 to 1)
**Characteristics:**
- Mixed signals from price and EMAs
- No clear trend direction
- Market indecision
**Action:**
- Reduce exposure to 50%
- Wait for clearer signals
- Focus on risk management
- Consider range-bound strategies
### Bearish (Score -2 to -3)
**Characteristics:**
- Price below most EMAs
- Generally negative EMA alignment
- Moderate downward trend
**Action:**
- Exit weak positions
- Reduce overall exposure
- Raise cash levels
- Protect capital
### Strong Bearish (Score -4 to -6)
**Characteristics:**
- Price trading below all major EMAs
- EMAs aligned in bearish order (21 < 50 < 100)
- Strong downward momentum
**Action:**
- Exit weak stocks immediately
- Minimal to no long exposure
- Preserve capital
- Wait for market conditions to improve
---
## Best Practices
### Usage Tips
1. **Timeframe Selection**
- Works on all timeframes
- Higher timeframes (daily, weekly) provide more reliable signals
- Lower timeframes (intraday) may generate more frequent signals but with higher noise
2. **Combine with Other Analysis**
- Use as a component of a comprehensive trading strategy
- Complement with support/resistance levels
- Consider volume and other momentum indicators
- Factor in fundamental analysis for longer-term positions
3. **Position Sizing**
- Treat investment level recommendations as guidelines, not rigid rules
- Adjust based on your risk tolerance and account size
- Consider your overall portfolio allocation
4. **Risk Management**
- Always use stop losses regardless of indicator reading
- Don't ignore risk management during "Strong Bullish" periods
- The indicator shows trend, not specific entry/exit points
### Limitations
- **Lagging Nature**: EMAs are lagging indicators, so signals may come after trend changes have begun
- **Whipsaw Risk**: In choppy, sideways markets, the indicator may generate mixed signals
- **Not a Standalone System**: Should be used as part of a broader trading strategy
- **No Predictive Power**: Shows current conditions, not future direction
- **Market Context**: May need adjustment during extreme market conditions or unusual volatility
---
## Technical Details
### EMA Calculations
The indicator uses three standard Exponential Moving Averages:
- **EMA 21**: Short-term trend (approximately 1 month of trading days)
- **EMA 50**: Medium-term trend (approximately 2.5 months)
- **EMA 100**: Long-term trend (approximately 5 months)
EMAs give more weight to recent prices compared to Simple Moving Averages (SMAs), making them more responsive to price changes.
### Update Frequency
- The indicator recalculates on every bar close
- Real-time updates during the current bar formation
- Table displays the most recent completed bar data
### Performance
- Lightweight indicator with minimal computational overhead
- Suitable for use with multiple charts simultaneously
- No historical data storage required beyond standard EMA calculations
---
## Frequently Asked Questions
**Q: Can I change the EMA periods (21, 50, 100)?**
A: The current version uses fixed EMA periods. Modifying these would require editing the Pine Script code directly.
**Q: Does this indicator work on all assets?**
A: Yes, it works on stocks, forex, cryptocurrencies, commodities, and indices - any asset with price data.
**Q: Can I use this for day trading?**
A: Yes, but it's designed for swing trading and position trading. For day trading, consider using lower timeframes and being aware of increased signal noise.
**Q: What if the score keeps changing?**
A: Frequent score changes indicate a choppy or transitional market. Consider waiting for a more stable reading before taking action.
**Q: Should I exit ALL positions when score is negative?**
A: The recommendation is to "Exit Weak Stocks" - focus on underperforming positions. Strong stocks may still be held with appropriate stop losses.
**Q: Can I get alerts based on score changes?**
A: The current version doesn't include alerts, but this functionality could be added with Pine Script modifications.
---
## Version History
**Version 1.0**
- Initial release
- 6-condition scoring system
- Investment level recommendations
- Customizable table position and size
- Overlay on main chart
---
## Support & Feedback
For questions, suggestions, or issues with the indicator:
- Review this documentation thoroughly
- Test the indicator on historical data before live trading
- Adjust settings to match your chart layout preferences
- Always paper trade new strategies before risking real capital
---
## Disclaimer
This indicator is provided for educational and informational purposes only. It does not constitute financial advice, investment advice, trading advice, or any other type of advice. Trading and investing involve substantial risk of loss. Past performance is not indicative of future results. Always do your own research and consult with a qualified financial advisor before making investment decisions.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.