Advertisement
Maurizio-Ciullo

Indicatore Massimo Odierno highd0

Dec 24th, 2022
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © TheSocialCryptoClub
  3.  
  4.  
  5. //@version=5
  6. indicator("Indicatore Massimo Odierno highd0", overlay=true)
  7.  
  8. // ------------- Parametri di ingresso dell'indicatore (Input) -----------------
  9.  
  10. distanzaPercDalMasssimo = input.float(2.0, "Distanza perc dal massimo di oggi", step=0.1)
  11.  
  12. // -------------Calcolo e Visualizzazione -----------------
  13.  
  14. open_session = ta.change(time('D'))
  15. first_bar = 0
  16. if open_session
  17.     first_bar := bar_index
  18.  
  19. var max_today = 0.0
  20. var soglia_today = 0.0
  21.  
  22. if first_bar
  23.     max_today := high
  24.     soglia_today :=  max_today - (max_today / 100 * distanzaPercDalMasssimo)
  25.  
  26. if high >= max_today
  27.     max_today := high
  28.     soglia_today := max_today - (max_today / 100 * distanzaPercDalMasssimo)
  29.  
  30. timed = time('D')
  31. line line_max_today = na
  32. line line_soglia_today = na
  33. label lbMaxOdierno = na
  34. label lbSoglia = na
  35.  
  36. if barstate.islast and timeframe.isintraday
  37.     line.delete(line_max_today[1])
  38.     line_max_today := line.new(x1=timed, y1=max_today, x2=time, y2=max_today, color=color.purple, xloc=xloc.bar_time
  39.              , extend=extend.right, width=2)
  40.     lbMaxOdierno := label.new(bar_index + 15 , max_today, text="Max odierno " + "\n" + str.tostring(max_today), color=color.purple, style=label.style_label_down, textcolor=color.white)
  41.     label.delete(lbMaxOdierno[1])
  42.  
  43.     line.delete(line_soglia_today[1])
  44.     line_soglia_today := line.new(x1=timed, y1=soglia_today, x2=time, y2=soglia_today, color=color.orange, xloc=xloc.bar_time
  45.              , extend=extend.right, width=1)
  46.     lbSoglia := label.new(bar_index + 15, soglia_today, text="Soglia -" + str.tostring(distanzaPercDalMasssimo) + "%" + "\n" + str.tostring(soglia_today,format.mintick), style=label.style_label_up, color=color.orange, textcolor=color.black)
  47.     label.delete(lbSoglia[1])
  48.  
  49. // ------------- Avvisi -----------------
  50.  
  51. alertcondition(ta.crossover(high, soglia_today), title="Prezzo vicino al max di oggi",
  52.       message="Superata soglia vicinanza al massimo di giornata")
  53.  
  54.  
  55. input_colore_sfondo_1 = color.new(color.green, 90)
  56.  
  57. bgcolor(ta.crossover(high, soglia_today) ? input_colore_sfondo_1 : na)
  58.  
  59. // ------------- Info strategia -----------------
  60.  
  61. // tabella info
  62. import happyTacos35869/InfoTable/11 as tbInfo
  63.  
  64. show_tab = input.bool(false,"Mostra Tabella")
  65. string inputTextColor = input.string("giallo", "Colore testo", options=["giallo", "bianco", "nero", "blu", "arancio"])
  66.  
  67. int nrRighe = 10
  68. string txt = na
  69.  
  70. if show_tab
  71.     table tb1 = tbInfo.crea(nrRighe)
  72.     table.set_position(tb1, position.top_right)
  73.     table.set_bgcolor(tb1, color.new(color.purple, 80))
  74.     tbInfo.aggiungi(tb1, 0, "", inputTextColor)
  75.  
  76.     txt := " Indicatore massimo odierno con avviso"
  77.     tbInfo.aggiungi(tb1, 1, txt, inputTextColor)
  78.     table.cell_set_width(tb1, 0, 1, 6)
  79.  
  80.     txt := syminfo.tickerid + " - timeframe: " + str.tostring(timeframe.period)
  81.     tbInfo.aggiungi(tb1, 2, txt, inputTextColor)
  82.  
  83.     txt := str.format("Massimo odierno {0}, prezzo soglia {1} ({2} perc)", max_today, soglia_today, distanzaPercDalMasssimo)
  84.     tbInfo.aggiungi(tb1, 3, txt, _textColor=inputTextColor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement