Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- //Original Credit to RicardoSantos https://www.tradingview.com/script/ZisWxP5g-RS-Function-InfoPanel/
- study("Saucy Menu",shorttitle="Saucy Menu",overlay=true)
- lable_posx = input(38, "Menu Right/Left")
- lable_posy = input(55, "Menu Up/Down")
- lable_txtsz = input(size.normal, "Menu Size")
- f_draw_infopanel(_x, _y, _line, _text, _color)=>
- _rep_text = ""
- for _l = 0 to _line
- _rep_text := _rep_text + "\n"
- _rep_text := _rep_text + _text
- var label _la = na
- label.delete(_la)
- _la := label.new(
- x=_x, y=_y,
- text=_rep_text, xloc=xloc.bar_time, yloc=yloc.price,
- color=color.black, style=label.style_labelup, textcolor=_color, size=lable_txtsz)
- posx = timenow + round(change(time)*lable_posx)
- posy = highest(lable_posy)
- res1 = input(title="", type=input.string, defval="240")
- // We functionalize TD calcs so they can also be passed to "security()".
- f_tdUp() =>
- TD = 0
- TD := close > close[4] ? nz(TD[1]) + 1 : 0
- TD - valuewhen(TD < TD[1], TD , 1 )
- f_tdDn() =>
- TS = 0
- TS := close < close[4] ? nz(TS[1]) + 1 : 0
- TS - valuewhen(TS < TS[1], TS , 1 )
- TDUp = f_tdUp()
- TDDn = f_tdDn()
- // Repainting.
- TDUp1 = security(syminfo.tickerid, res1, f_tdUp())
- TDDn1 = security(syminfo.tickerid, res1, f_tdDn())
- // No repainting.
- // TDUp1 = security(syminfo.tickerid, res1, f_tdUp()[1], lookahead = barmerge.lookahead_on)
- // TDDn1 = security(syminfo.tickerid, res1, f_tdDn()[1], lookahead = barmerge.lookahead_on)
- f_draw_infopanel(posx, posy, 2, "TD COUNT 4H: " +tostring(TDUp1 > 0 ? TDUp1 : TDDn1, "#"), TDUp1 > 0 ? color.lime : color.red)
- f_draw_infopanel(posx, posy, 0, "TD COUNT: " +tostring(TDUp > 0 ? TDUp : TDDn, "#"), TDUp > 0 ? color.lime : color.red)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement