Я хотел бы нанести индекс последнего бара ("5830", см. скриншот ниже) на ценовой график, а не на график CCI.
Вот мой код:
//@version=5
indicator("Mon script", overlay=false)
// CCI
cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)
plot(bar_index % 2 ? na: 100, color=color.gray, style=plot.style_linebr)
plot(bar_index % 2 ? na: -100, color=color.gray, style=plot.style_linebr)
plot(cci, title = "CCI",color=color.fuchsia)
if (barstate.islast)
label.new(bar_index, open, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)
Любая идея о том, как это сделать?
С наилучшими пожеланиями
Вы уже использовали метку, поэтому измените свойства индикатора на overlay=true
//@version=5
indicator("Mon script", overlay=true)
// CCI
cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)
if (barstate.islast)
label.new(bar_index, low, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_label_up, textcolor = color.white, size = size.normal)
Кроме того, вы можете сделать его в виде таблицы
//@version=5
indicator("Mon script", overlay=true)
// CCI
cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)
var table table1 = na
var table2 = table.new(position.top_left, na, na)
if barstate.islastconfirmedhistory
var table3 = table.new(position = position.top_right, columns = 1, rows = 1, bgcolor = color.yellow, border_width = 1)
table.cell(table_id = table3, column = 0, row = 0, text = str.tostring(bar_index, format.mintick))