retesere20

labels- monthly_weekly high_low

Sep 20th, 2019
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. user_color = input(title="Color", defval="green", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  3. final_color = user_color == "aqua" ? color.aqua : user_color == "black" ? color.black : user_color == "blue" ? color.blue : user_color == "fuchsia" ? color.fuchsia : user_color == "gray" ? color.gray : user_color == "green" ? color.green : user_color == "lime" ? color.lime : user_color == "maroon" ? color.maroon : user_color == "navy" ? color.navy : user_color == "olive" ? color.olive : user_color == "orange" ? color.orange : user_color == "purple" ? color.purple : user_color == "red" ? color.red : user_color == "silver" ? color.silver : user_color == "teal" ? color.teal : user_color == "white" ? color.white : user_color == "yellow" ? color.yellow : color.black
  4.  
  5.  
  6. //displaced_space1 = input(defval=" ", title="label 1 spacing")
  7. displaced_space2 = ""//input(defval=" ", title="label 2 spacing")
  8. displaced_space3 = ""//input(defval=" ", title="label 3 spacing")
  9.  
  10.  
  11. string text2 = displaced_space2 + res2 + "/H: "+ tostring(res2_high)+ " L: "+ tostring(res2_low)
  12. string text3 = displaced_space3 + res3 + "/H: "+ tostring(res3_high)+ " L: "+ tostring(res3_low)
  13.  
  14.  
  15. bool showLabelLines = false
  16.  
  17. bool lastBarCond = barstate.islast
  18. if (showLabelLines and lastBarCond)
  19. label l2_h = label.new(bar_index, res2_high, text2, color=color.red, textcolor=final_color, style=label.style_none, yloc=yloc.price)
  20. label.delete(l2_h[1])
  21. label l2_l = label.new(bar_index, res2_low , text2, color=color.red, textcolor=final_color, style=label.style_none, yloc=yloc.price)
  22. label.delete(l2_l[1])
  23.  
  24. label l3_h = label.new(bar_index, res3_high, text3, color=color.red, textcolor=final_color, style=label.style_none, yloc=yloc.price)
  25. label.delete(l3_h[1])
  26. label l3_l = label.new(bar_index, res3_low , text3, color=color.red, textcolor=final_color, style=label.style_none, yloc=yloc.price)
  27. label.delete(l3_l[1])
  28.  
  29.  
  30. //fix redraw on lastbar for Weekly/monthly line on small TF views
  31. color hintColor = #73737350
  32. if (showLabelLines and (is_newbar(res2) or lastBarCond))
  33. line line_2_h = line.new(time, res2_high, time +60*60*24, res2_high, xloc=xloc.bar_time, extend=extend.right, color=not lastBarCond ? final_color: hintColor, width=1)
  34. line line_2_l = line.new(time, res2_low , time +60*60*24, res2_low , xloc=xloc.bar_time, extend=extend.right, color=not lastBarCond ? final_color: hintColor, width=1)
  35. if (not lastBarCond)
  36. line.delete(line_2_h[1])
  37. line.delete(line_2_l[1])
  38.  
  39. if (showLabelLines and (is_newbar(res3) or lastBarCond))
  40. line line_3_h = line.new(time, res3_high, time +60*60*24, res3_high, xloc=xloc.bar_time, extend=extend.right, color=not lastBarCond ? final_color: hintColor, width=1)
  41. line line_3_l = line.new(time, res3_low , time +60*60*24, res3_low , xloc=xloc.bar_time, extend=extend.right, color=not lastBarCond ? final_color: hintColor, width=1)
  42. if (not lastBarCond)
  43. line.delete(line_3_h[1])
  44. line.delete(line_3_l[1])
RAW Paste Data