OPEN-SOURCE SCRIPT
Double Moving Average

## 📊 Double Moving Average (DMA)
**General Description:**
An indicator composed of two completely independent Moving Averages (MAs), each configured with its own parameters. Unlike a standard MA, each MA #1 and MA #2 can use a different timeframe, even if the chart displays another timeframe.
---
### **MA #1 - Parameters**
| Parameter | Default | Range | Description |
|-----------|---------|-------|-------------|
| **Enable MA #1** | ✓ | Yes/No | Activate/deactivate the first MA |
| **Length** | 50 | 1-500 | Calculation period of the MA |
| **Source** | Close | Open/High/Low/Close | Price source |
| **Offset** | 0 | 0-100 | Shift the curve to the right |
| **Type** | EMA | SMA/EMA/WMA | Type of moving average |
### **MA #2 - Parameters**
Identical to MA #1 but with default **Length: 200**
---
### **Smoothing - Per MA**
Each MA can have its own smoothing:
| Parameter | Options |
|-----------|---------|
| **Enable Smoothing** | Yes/No |
| **Type** | None / SMA / EMA / WMA |
| **Length** | 1-100 |
| **BB StdDev** | 0.1-10 (Bollinger Bands) |
---
### **Timeframe (Period) - Per MA**
Each MA calculates on an independent timeframe:
**Options:** 1min, 2min, 5min, 10min, 15min, 30min, 1hr, 2hr, 4hr, 1day
**"Wait for Close":** Waits for the timeframe candle to close before confirmation
---
### **Main Functions**
1. **`f_convert_timeframe()`** - Converts timeframe formats for Pine Script
2. **`f_calculate_ma()`** - Calculates SMA, EMA, or WMA
3. **`f_apply_smoothing()`** - Applies smoothing if enabled
---
### **Use Cases**
- Display short-term MA (5min) for scalping
- Display long-term MA (1day) for overall trend
- All on the same chart, independent of the displayed timeframe
- Compare two different trend periods simultaneously
**General Description:**
An indicator composed of two completely independent Moving Averages (MAs), each configured with its own parameters. Unlike a standard MA, each MA #1 and MA #2 can use a different timeframe, even if the chart displays another timeframe.
---
### **MA #1 - Parameters**
| Parameter | Default | Range | Description |
|-----------|---------|-------|-------------|
| **Enable MA #1** | ✓ | Yes/No | Activate/deactivate the first MA |
| **Length** | 50 | 1-500 | Calculation period of the MA |
| **Source** | Close | Open/High/Low/Close | Price source |
| **Offset** | 0 | 0-100 | Shift the curve to the right |
| **Type** | EMA | SMA/EMA/WMA | Type of moving average |
### **MA #2 - Parameters**
Identical to MA #1 but with default **Length: 200**
---
### **Smoothing - Per MA**
Each MA can have its own smoothing:
| Parameter | Options |
|-----------|---------|
| **Enable Smoothing** | Yes/No |
| **Type** | None / SMA / EMA / WMA |
| **Length** | 1-100 |
| **BB StdDev** | 0.1-10 (Bollinger Bands) |
---
### **Timeframe (Period) - Per MA**
Each MA calculates on an independent timeframe:
**Options:** 1min, 2min, 5min, 10min, 15min, 30min, 1hr, 2hr, 4hr, 1day
**"Wait for Close":** Waits for the timeframe candle to close before confirmation
---
### **Main Functions**
1. **`f_convert_timeframe()`** - Converts timeframe formats for Pine Script
2. **`f_calculate_ma()`** - Calculates SMA, EMA, or WMA
3. **`f_apply_smoothing()`** - Applies smoothing if enabled
---
### **Use Cases**
- Display short-term MA (5min) for scalping
- Display long-term MA (1day) for overall trend
- All on the same chart, independent of the displayed timeframe
- Compare two different trend periods simultaneously
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.