Pinescript - ATR modified

Job ID: 32977631

Budget: $30 – $250 USD

Hi,
Need to develop 2 indicators based on the actual ATR indicator from TV.

It is composed of 2 elements:
1- create an ATR indicator (Average True Range) that is expressed in percentage instead of absolute $ value. This indicator takes as variable the length of the period and either SMA, EMA, WMA or RMA
It is just a modification of the actual ATR indicator of TradingView using a percentage for the line plotted instead of the value. By percentage, I mean that if for the period observed the ATR is 10 and the ticker is trading at 200 then the ATR in % is 5%
----------------------------
//@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))
-------------------------------------


2- The second part is another indicator to be plotted as an overlay on the main ticker window by using the ATR in % information.
The objective is to plot a small mark (like a cross or another small symbol) when the ticker is decreasing more than the ATR percentage value. As an example, if the ATR% is 5% and the ticker is decreasing more than 5% then a small red cross is plotted on the ticker.
As a parameter of this indicator, I would like to set up to 5 values that multiply the ATR%. Per example, the first value is 1 which means we take the ATR% without any change. The second parameter could be 1.2 which means that the ATR% is multiplied by 1.2 which is equal to 5% x 1.2 = 6% in our example. The value can be 0.5 which leans 5% x 0.5 = 2.5%.
Each parameter is plotted in a different color on the ticker graph.

I also need the list of all occurrences triggered by the indicator.

Remarks: The ATR is recalculated based on the timeframe used on the graph. It can be 1h, 4h, 1day.... then the ATR% is based on a moving average of n periods of the 1h or 4h or 1d timeframe.
Related categories: Pine Script