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
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน