PROTECTED SOURCE SCRIPT

BG EMA MTF

47
**BG EMA MTF**
*Multi‐Timeframe Exponential Moving Averages Sentiment*

---

## Overview

BG EMA MTF calculates a single “sentiment score” by checking the direction of five user-defined EMAs across five user-defined timeframes. It aggregates 25 individual EMA signals (rising vs. falling) into one percentage and displays it as a small, color-coded overlay table.

---

## Features

* **Five EMAs (configurable)**: Default lengths are 5, 20, 50, 70, and 200.
* **Five Timeframes (configurable)**: Any valid Pine timeframe (e.g., “1”, “5”, “15”, “60”, “240”, “D”, “W”).
* **Trend Detection**: Each EMA is considered “rising” if its current value > value two bars ago.
* **Sentiment Aggregation**: Counts how many “rising” EMA signals out of 25 total (5 EMAs × 5 timeframes) and converts it to a 0–100% score.
* **Overlay Display**:

* Text: `BG EMA MTF : XX %`
* Background color:

* **Green** (80% opacity) when score > 50% (bullish).
* **Red** (80% opacity) when score < 50% (bearish), showing 100 – raw for symmetry.
* **Gray** (80% opacity) when score = 50% (neutral).
* Percentage text remains black for maximum contrast.
* Hover tooltip shows “Bullish (N Bullish / M Bearish on 25 signals)” or “Bearish…” / “Neutral (12 Bullish / 13 Bearish)”.

---

## Inputs

1. **Timeframes (tf1…tf5)**

* Five `input.timeframe` fields.
* Default: “1”, “1”, “3”, “5”, “15”.
2. **EMA Lengths (len1…len5)**

* Five `input.int` fields.
* Default: 5, 20, 50, 70, 200.
3. **Table Position**

* `input.string`: “top\_left”, “top\_right” (default), “bottom\_left”, “bottom\_right”.
4. **Text Size**

* `input.string`: “tiny”, “small”, “normal” (default), “large”, “huge”.
5. **Colors**

* `col_bullish` (default: lime), `col_bearish` (default: red), `col_neutral` (default: gray).

---

## How to Use

1. Add the script to your chart.
2. Customize timeframes and EMA lengths to match your strategy (e.g., scalping vs. swing trading).
3. The overlay shows the current sentiment:

* **> 50% (green)** → majority of EMA signals are rising → bullish bias.
* **< 50% (red)** → majority are falling → bearish bias.
* **= 50% (gray)** → neutral.
4. Hover over the table to see the exact breakdown of bullish vs. bearish EMAs (e.g., “Bullish (18 Bullish / 7 Bearish on 25 signals)”).

---

## Disclaimer

This indicator is for informational purposes only. It does not constitute trading advice. Always test strategies on historical data before using in live trading.

---

**Version 1.0**
© babtrader24 – Licensed under MPL 2.0 ([mozilla.org/MPL/2.0/](https://mozilla.org/MPL/2.0/))

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。