3

I'm working on a TradingView script (Pine) and I would to develop a simply script that draw a rectangle from a start of current day to the end based on my current timeframe from Monday To Friday...

Example: First rectangle drawed from 24/03/2021 to 25/03/2021, Second Rectangle drawed from 25/03/2021 to 26/03/2021, etc...

Any solutions to achieve this result?

Thank's in advance

AnyDozer
  • 2,236
  • 2
  • 5
  • 22
bbgg2017
  • 187
  • 3
  • 10
  • What is the other dimension of the rectangle? Does it extend to the top and bottom of the viewport? If so it there actually a need for it to be a rectangle or just a line dividing days? If this is unclear take a screenshot and draw what you are trying to achieve. – bajaco Mar 24 '21 at 17:19

1 Answers1

4

I think I have understood your request. The below should help assist you

enter image description here

//@version=4
study("Daily Box", overlay=true)

Bottom = input(title="Bottom", type=input.session, defval="0000-2359:1234567")

colourcheck = 1.0
boxheight = input(title="Box Height", type=input.float, defval=3)

DailyHigh = security(syminfo.tickerid, "D", high, lookahead=true)
DailyLow = security(syminfo.tickerid, "D", low, lookahead=true)

dayrange = DailyHigh - DailyLow

BottomLowBox = DailyLow + (dayrange * 0.01 * boxheight)
TopLowBox = DailyHigh - (dayrange * 0.01 * boxheight)

BarInSession(sess) => time(timeframe.period, sess) != 0

//ASIA
BottomL = plot(DailyLow and BarInSession(Bottom) ? DailyLow : na, title="Bottom High", style=plot.style_linebr, linewidth=3, color=na)
TopL = plot(DailyHigh and BarInSession(Bottom) ? DailyHigh : na, title="Bottom Low", style=plot.style_linebr, linewidth=3, color=na)
fill(BottomL, TopL, color=color.purple, title="Fill Box", transp=50)
frien_dd
  • 154
  • 2
  • 12