Gostaria que alterasse esse script para que eu somente copie e cole ele por inteiro, mas que adicione linhas horizontais com escritas no centro dessas linhas encima de cada caixa macro definida, que essas scritas indiquem o horario de início dessa caixa e o fim dela por exemplo : 10:20 - 10:40 estaria escrito em uma linha horizontal acima da caixa:
// ---------------------------------------- Variables & Constants --------------------------------------------------
m1_time = not na(time("", m1, gmt_timezone))
m2_time = not na(time("", m2, gmt_timezone))
m3_time = not na(time("", m3, gmt_timezone))
m4_time = not na(time("", m4, gmt_timezone))
m5_time = not na(time("", m5, gmt_timezone))
m6_time = not na(time("", m6, gmt_timezone))
m7_time = not na(time("", m7, gmt_timezone))
m8_time = not na(time("", m8, gmt_timezone))
m9_time = not na(time("", m9, gmt_timezone))
m10_time = not na(time("", m10, gmt_timezone))
m11_time = not na(time("", m11, gmt_timezone))
m12_time = not na(time("", m12, gmt_timezone))
m13_time = not na(time("", m13, gmt_timezone))
m14_time = not na(time("", m14, gmt_timezone))
m15_time = not na(time("", m15, gmt_timezone))
m16_time = not na(time("", m16, gmt_timezone))
m17_time = not na(time("", m17, gmt_timezone))
m18_time = not na(time("", m18, gmt_timezone))
m19_time = not na(time("", m19, gmt_timezone))
m20_time = not na(time("", m20, gmt_timezone))
m21_time = not na(time("", m21, gmt_timezone))
m22_time = not na(time("", m22, gmt_timezone))
m23_time = not na(time("", m23, gmt_timezone))
m24_time = not na(time("", m24, gmt_timezone))
m25_time = not na(time("", m25, gmt_timezone))
m26_time = not na(time("", m26, gmt_timezone))
var m1_box = array.new_box()
var m2_box = array.new_box()
var m3_box = array.new_box()
var m4_box = array.new_box()
var m5_box = array.new_box()
var m6_box = array.new_box()
var m7_box = array.new_box()
var m8_box = array.new_box()
var m9_box = array.new_box()
var m10_box = array.new_box()
var m11_box = array.new_box()
var m12_box = array.new_box()
var m13_box = array.new_box()
var m14_box = array.new_box()
var m15_box = array.new_box()
var m16_box = array.new_box()
var m17_box = array.new_box()
var m18_box = array.new_box()
var m19_box = array.new_box()
var m20_box = array.new_box()
var m21_box = array.new_box()
var m22_box = array.new_box()
var m23_box = array.new_box()
var m24_box = array.new_box()
var m25_box = array.new_box()
var m26_box = array.new_box()
// ---------------------------------------- Core Logic --------------------------------------------------
if timeframe.in_seconds("") <= timeframe.in_seconds(max_timeframe)
// Macro 1
if use_m1
if m1_time and not m1_time[1]
if show_macros
m1_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m1_color, bgcolor = m1_color, text = show_macros_text ? m1_text : na, text_color = m1_color))
else if m1_time
adjust(m1_box.get(0))
// Macro 2
if use_m2
if m2_time and not m2_time[1]
if show_macros
m2_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m2_color, bgcolor = m2_color, text = show_macros_text ? m2_text : na, text_color = m2_color))
else if m2_time
adjust(m2_box.get(0))
// Macro 3
if use_m3
if m3_time and not m3_time[1]
if show_macros
m3_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m3_color, bgcolor = m3_color, text = show_macros_text ? m3_text : na, text_color = m3_color))
else if m3_time
adjust(m3_box.get(0))
// Macro 4
if use_m4
if m4_time and not m4_time[1]
if show_macros
m4_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m4_color, bgcolor = m4_color, text = show_macros_text ? m4_text : na, text_color = m4_color))
else if m4_time
adjust(m4_box.get(0))
// Macro 5
if use_m5
if m5_time and not m5_time[1]
if show_macros
m5_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m5_color, bgcolor = m5_color, text = show_macros_text ? m5_text : na, text_color = m5_color))
else if m5_time
adjust(m5_box.get(0))
// Macro 6
if use_m6
if m6_time and not m6_time[1]
if show_macros
m6_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m6_color, bgcolor = m6_color, text = show_macros_text ? m6_text : na, text_color = m6_color))
else if m6_time
adjust(m6_box.get(0))
// Macro 7
if use_m7
if m7_time and not m7_time[1]
if show_macros
m7_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m7_color, bgcolor = m7_color, text = show_macros_text ? m7_text : na, text_color = m7_color))
else if m7_time
adjust(m7_box.get(0))
// Macro 8
if use_m8
if m8_time and not m8_time[1]
if show_macros
m8_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m8_color, bgcolor = m8_color, text = show_macros_text ? m8_text : na, text_color = m8_color))
else if m8_time
adjust(m8_box.get(0))
// Macro 9
if use_m9
if m9_time and not m9_time[1]
if show_macros
m9_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m9_color, bgcolor = m9_color, text = show_macros_text ? m9_text : na, text_color = m9_color))
else if m9_time
adjust(m9_box.get(0))
// Macro 10
if use_m10
if m10_time and not m10_time[1]
if show_macros
m10_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m10_color, bgcolor = m10_color, text = show_macros_text ? m10_text : na, text_color = m10_color))
else if m10_time
adjust(m10_box.get(0))
// Macro 11
if use_m11
if m11_time and not m11_time[1]
if show_macros
m11_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m11_color, bgcolor = m11_color, text = show_macros_text ? m11_text : na, text_color = m11_color))
else if m11_time
adjust(m11_box.get(0))
// Macro 12
if use_m12
if m12_time and not m12_time[1]
if show_macros
m12_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m12_color, bgcolor = m12_color, text = show_macros_text ? m12_text : na, text_color = m12_color))
else if m12_time
adjust(m12_box.get(0))
// Macro 13
if use_m13
if m13_time and not m13_time[1]
if show_macros
m13_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m13_color, bgcolor = m13_color, text = show_macros_text ? m13_text : na, text_color = m13_color))
else if m13_time
adjust(m13_box.get(0))
// Macro 14
if use_m14
if m14_time and not m14_time[1]
if show_macros
m14_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m14_color, bgcolor = m14_color, text = show_macros_text ? m14_text : na, text_color = m14_color))
else if m14_time
adjust(m14_box.get(0))
// Macro 15
if use_m15
if m15_time and not m15_time[1]
if show_macros
m15_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m15_color, bgcolor = m15_color, text = show_macros_text ? m15_text : na, text_color = m15_color))
else if m15_time
adjust(m15_box.get(0))
// Macro 16
if use_m16
if m16_time and not m16_time[1]
if show_macros
m16_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m16_color, bgcolor = m16_color, text = show_macros_text ? m16_text : na, text_color = m16_color))
else if m16_time
adjust(m16_box.get(0))
// Macro 17
if use_m17
if m17_time and not m17_time[1]
if show_macros
m17_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m17_color, bgcolor = m17_color, text = show_macros_text ? m17_text : na, text_color = m17_color))
else if m17_time
adjust(m17_box.get(0))
// Macro 18
if use_m18
if m18_time and not m18_time[1]
if show_macros
m18_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m18_color, bgcolor = m18_color, text = show_macros_text ? m18_text : na, text_color = m18_color))
else if m18_time
adjust(m18_box.get(0))
// Macro 19
if use_m19
if m19_time and not m19_time[1]
if show_macros
m19_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m19_color, bgcolor = m19_color, text = show_macros_text ? m19_text : na, text_color = m19_color))
else if m19_time
adjust(m19_box.get(0))
// Macro 20
if use_m20
if m20_time and not m20_time[1]
if show_macros
m20_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m20_color, bgcolor = m20_color, text = show_macros_text ? m20_text : na, text_color = m20_color))
else if m20_time
adjust(m20_box.get(0))
// Macro 21
if use_m21
if m21_time and not m21_time[1]
if show_macros
m21_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m21_color, bgcolor = m21_color, text = show_macros_text ? m21_text : na, text_color = m21_color))
else if m21_time
adjust(m21_box.get(0))
// Macro 22
if use_m22
if m22_time and not m22_time[1]
if show_macros
m22_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m22_color, bgcolor = m22_color, text = show_macros_text ? m22_text : na, text_color = m22_color))
else if m22_time
adjust(m22_box.get(0))
// Macro 23
if use_m23
if m23_time and not m23_time[1]
if show_macros
m23_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m23_color, bgcolor = m23_color, text = show_macros_text ? m23_text : na, text_color = m23_color))
else if m23_time
adjust(m23_box.get(0))
// Macro 24
if use_m24
if m24_time and not m24_time[1]
if show_macros
m24_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m24_color, bgcolor = m24_color, text = show_macros_text ? m24_text : na, text_color = m24_color))
else if m24_time
adjust(m24_box.get(0))
// Macro 25
if use_m25
if m25_time and not m25_time[1]
if show_macros
m25_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m25_color, bgcolor = m25_color, text = show_macros_text ? m25_text : na, text_color = m25_color))
else if m25_time
adjust(m25_box.get(0))
// Macro 26
if use_m26
if m26_time and not m26_time[1]
if show_macros
m26_box.unshift(box.new(bar_index, high, bar_index, low, border_color = m26_color, bgcolor = m26_color, text = show_macros_text ? m26_text : na, text_color = m26_color))
else if m26_time
adjust(m26_box.get(0))
Para adicionar linhas horizontais com escritas no centro acima de cada caixa macro indicando os horários de início e fim, você pode utilizar a função line.new() do Pine Script para desenhar as linhas e label.new() para adicionar os textos. Abaixo, ajustei o script para incluir essa funcionalidade. Copie e cole o script atualizado no TradingView:
Este script foi adaptado para incluir uma função draw_line_and_label que desenha uma linha horizontal e uma etiqueta de texto com os horários de início e término acima de cada caixa macro. Repita a lógica mostrada no exemplo do Macro 1 para cada macro que você deseja desenhar no gráfico. Por questões de simplicidade e espaço, a demonstração foi feita apenas para um macro, mas o conceito é o mesmo para todos. Certifique-se de repetir as seções relevantes de código para cada um dos seus macros, ajustando as variáveis e chamadas de função conforme necessário.