'how to create pine script indicator for only today
my script is to take daily ATR and apply to todays 15 min chart using the ATR =/- from prev close a trading Range
I want it to be applied only to current day and not show the previous day because it just messes up the screen
please advice how to make it so that only next day levels are shown
CODE i am using --
timeFrame = input.timeframe(defval="D")
curratr=ta.atr(14)
atr=request.security(syminfo.tickerid,timeFrame,curratr[1])
prevClose = request.security(syminfo.tickerid,"D",close[1],gaps =
barmerge.gaps_off, lookahead=barmerge.lookahead_on)
plot(prevClose+atr, color=color.red, linewidth=2)
plot(prevClose+atr*0.5, color=color.red, linewidth=2)
plot(prevClose, color=color.black, linewidth=2)
plot(prevClose-atr*0.5, color=color.green, linewidth=2)
plot(prevClose-atr,color=color.green, linewidth = 2)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|