First and second Variable need
//@version=5
indicator("ema cross", overlay = true)
ema12cross_green = ta.crossover(close, ta.ema(close, 12))
plot(ta.ema(close, 12))
plotshape(ema12cross_green, title="X", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.normal)
ema12cross_green_count = ta.barssince(ema12cross_green)
// float labelY = high + 0.0002 // Change the value as needed for the vertical offset
// label.new(x = bar_index, y = labelY, text = str.tostring(ema12cross_green_count), color=color.new(color.white,100))
var int ema12cross_green_count_aktuell = na
var int ema12cross_green_count_aktuell1 = na
var int ema12cross_green_count_previous = na
if ema12cross_green[0]
ema12cross_green_count_aktuell := 1
float labelY = high + 0.0002 // Change the value as needed for the vertical offset
label.new(x = bar_index, y = labelY, text = str.tostring(ema12cross_green_count_aktuell), color=color.new(color.white,100))
// if ema12cross_green_count_aktuell == 1 and ta.barssince(ema12cross_green_count_aktuell) > barsince
// // if ema12cross_green
// ema12cross_green_count_previous := ema12cross_green_count_aktuell + 1
// float labelY = high + 0.0002 // Change the value as needed for the vertical offset
// label.new(x = bar_index, y = labelY, text = str.tostring(ema12cross_green_count_previous), color=color.new(color.white,100))
I want two Variables. First, when emaCross first an second time from actual close. See picture.
With this variables i want to count the first and the second variable (ta.barsince(close, firstCross/secondCross)
Do you have an idea?