Advertisement
PineCoders

Saucy Menu

Aug 27th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. //@version=4
  2. //Original Credit to RicardoSantos https://www.tradingview.com/script/ZisWxP5g-RS-Function-InfoPanel/
  3. study("Saucy Menu",shorttitle="Saucy Menu",overlay=true)
  4.  
  5. lable_posx = input(38, "Menu Right/Left")
  6. lable_posy = input(55, "Menu Up/Down")
  7. lable_txtsz = input(size.normal, "Menu Size")
  8. f_draw_infopanel(_x, _y, _line, _text, _color)=>
  9. _rep_text = ""
  10. for _l = 0 to _line
  11. _rep_text := _rep_text + "\n"
  12. _rep_text := _rep_text + _text
  13. var label _la = na
  14. label.delete(_la)
  15. _la := label.new(
  16. x=_x, y=_y,
  17. text=_rep_text, xloc=xloc.bar_time, yloc=yloc.price,
  18. color=color.black, style=label.style_labelup, textcolor=_color, size=lable_txtsz)
  19.  
  20. posx = timenow + round(change(time)*lable_posx)
  21. posy = highest(lable_posy)
  22.  
  23. res1 = input(title="", type=input.string, defval="240")
  24.  
  25. // We functionalize TD calcs so they can also be passed to "security()".
  26. f_tdUp() =>
  27. TD = 0
  28. TD := close > close[4] ? nz(TD[1]) + 1 : 0
  29. TD - valuewhen(TD < TD[1], TD , 1 )
  30.  
  31. f_tdDn() =>
  32. TS = 0
  33. TS := close < close[4] ? nz(TS[1]) + 1 : 0
  34. TS - valuewhen(TS < TS[1], TS , 1 )
  35.  
  36. TDUp = f_tdUp()
  37. TDDn = f_tdDn()
  38.  
  39. // Repainting.
  40. TDUp1 = security(syminfo.tickerid, res1, f_tdUp())
  41. TDDn1 = security(syminfo.tickerid, res1, f_tdDn())
  42. // No repainting.
  43. // TDUp1 = security(syminfo.tickerid, res1, f_tdUp()[1], lookahead = barmerge.lookahead_on)
  44. // TDDn1 = security(syminfo.tickerid, res1, f_tdDn()[1], lookahead = barmerge.lookahead_on)
  45.  
  46.  
  47. f_draw_infopanel(posx, posy, 2, "TD COUNT 4H: " +tostring(TDUp1 > 0 ? TDUp1 : TDDn1, "#"), TDUp1 > 0 ? color.lime : color.red)
  48. 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