0
votes

Hello everyone PineScript noob here. Just had a quick question about the capabilities of PineScript. Tryingto figure out a way that I could write a script to plot a 2 linear lines using the Opening Price of a stock that day as the value to calculate the two other lines - one extending left that calculates off opening price of that day -1/2 of the 14 day ATR below the opening day price and one line that is 1/2 ATR above the opening price.

--------------------------- 1/2 ATR (14 day) visible linear line

--------------------------- Opening Day Price - this line does not need to be visible

--------------------------- -1/2 ATR (14 day) visible linear line

Is this possible?? Iv'e played around and tried my hand at it but gotta say I'm learning but just plain stuck. Any thoughts if this is doable?? Thanks!

1

1 Answers

0
votes

I hope this answers your question

//@version=4
study("Open ATR Band", "", true)
//Session Rules
bartimeSess = time('D')
newbarSess = bartimeSess != bartimeSess[1]

O = valuewhen(newbarSess,open,0)
range = security(syminfo.tickerid, "D", atr(14))
Uatr = O + range
Latr = O - range

plot(O, color=color.black, linewidth=2)
plot(Uatr, color=color.blue)
plot(Latr, color=color.blue)