how can i output a horizontal line with pine script that follows the EMA8. You should do a small calculation and print the line on the desired time with price on the right side.
EMA 8 (close) minus 1/2 of the ATR(14) = line output.
how can i output a horizontal line with pine script that follows the EMA8. You should do a small calculation and print the line on the desired time with price on the right side.
EMA 8 (close) minus 1/2 of the ATR(14) = line output.
To subtract atr you can call built-in atr function
atr14 = atr(14)
To plot a horizontal ray you can set the trackprice argument of the plot function. However it will extent the line to the left as well.
//@version=3
study("LINE", overlay=true)
ma_len = 8
src = close
res = "D"
htf_ma = sma(src, ma_len)
out = security(tickerid, res, htf_ma)
plot(out, color=red, show_last=1, linewidth=3)
atr14 = atr(14)
plot(out - (atr14/2), color=red, linewidth=3, show_last=1, trackprice = true)