Average True Value (ATR) on pine (tradingview)

I have created this code to help me with the trades, independently of the long term trades or swing trades.

The code

//@version=1
// @author = joapen.com , how I use it
//
// If you use this code in its orignal/modified form, do drop me a note. I would like to learn about better improvements of it 
// 
//1.- Define Stop Loss
//2.- Check if the goal makes sense or not,
//3.- Compare with Bollinger bands.
//4.- Refine the trade...
study(title="joapen-ATR-analysis", overlay = true)

nATRPeriod = input(defval = 10, title="# periodos", type=integer)
nATRMultip = input(defval = 1.8, title="factor multiplicador", type=float)

xATR = atr(nATRPeriod)
nLoss = nATRMultip * xATR
// the "goal reference" must be at least twice the stop loss
nObjetivo = nATRMultip * xATR *2

xATRStop = close - nLoss
xATRObjetivo = close + nObjetivo

plot(xATRStop, color=red, title="ATR Stop")
plot(xATRObjetivo, color=blue, title="ATR Objetivo")

Any additional support is welcomed

Leave a Comment