Smooth ATR - MetaTrader 4 Script | Trading Script Download - MT4/MT5 Resources - MetaTrader 5 Resources








The indicator is based on the true range, which is the maximum of (High - Low), Abs (High - Close [1]) and Abs (Low - Close [1]), where Abs is the mathematical absolute value.
To get the first data, it calculates the true range values for multiple bars (i.e. the input length) and then calculates the SMA of these values (i.e. the sum of all these values divided by the length - the simple average). This average is set as the first ATR value.
Smoothing method:
RMA: Coefficient alpha is defined as: alpha = 1/Length. RMA is calculated as: rma = alpha * (true range value of the candle) + (1-alpha) * (last rma).
SMA: For each bar, it calculates the simple average of the true range values for a defined number (length) of bars. This mode is equal to the iATR value.
EMA: Coefficient alpha is defined as: alpha = 2/(1+Length). The calculation formula of EMA is: ema = alpha * (the true range value of the candle) + (1-alpha) * (the last ema).
WMA: For each bar, it calculates the weighted average of the true range values for the defined number (length) of bars as follows:
Sum = N * (tr[0]) + (N-1) * (tr[1]) + ... + 1 * (tr[N-1]); tr is the true range value of the candle
wma = sum/ (N*(N+1)/2)
Example: XAUUSD, H1
Attachment download
📎 atr-with-smoothing.mq4 (4.46 KB)
Source: MQL5 #36438
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •