Attachments forums

List of attachments posted on this forum.


All files on forums: 153015

Re: ATR indicators for MT4

mrtools, Mon Jul 01, 2024 3:29 am

oskison wrote: Sun Jun 30, 2024 12:07 am HI.
Would any of you be able to add the RMA smoothing to the ATR indicator as it is on the trading view platform? There is no smoothing option in the standard metatrade 4 indicator

Code

Code: Select all

//@version=5
indicator(title="Average True Range", shorttitle="ATR", overlay=false, timeframe="", timeframe_gaps=true)
length = input.int(title="Length", defval=14, minval=1)
smoothing = input.string(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, length) =>
	switch smoothing
		"RMA" => ta.rma(source, length)
		"SMA" => ta.sma(source, length)
		"EMA" => ta.ema(source, length)
		=> ta.wma(source, length)
plot(ma_function(ta.tr(true), length), title = "ATR", color=color.new(#B71C1C, 0))
:
Made this one. In the screenshot is the built in Atr which uses a simple moving average.
All files in topic