I would like to make an indicator that shows me the timestamp of each tick close, these timestamps will be joined by a line. As an example, the tick at 00:19 (x axis) will have a value of 1711066740. My code is here but dont draw nothing:
private int lastBarIndex = -1;
private double lastTimestampValue = 0;
protected override void OnBarUpdate()
{
// Asegurarte de que tienes suficientes datos
if (CurrentBar < 1) return;
// Obtener el timestamp del tick actual y convertirlo a un valor numérico (por ejemplo, segundos desde la medianoche)
DateTime timestamp = Time[0];
double secondsSinceMidnight = timestamp.TimeOfDay.TotalSeconds;
// Verificar si es el primer tick procesado
if (lastBarIndex == -1)
{
// Solo actualiza los valores sin dibujar una línea
lastBarIndex = CurrentBar;
lastTimestampValue = secondsSinceMidnight;
}
else
{
// Dibujar una línea desde el último tick hasta el actual
Draw.Line(this, "line" + CurrentBar, false, lastBarIndex - CurrentBar, lastTimestampValue, 0, secondsSinceMidnight, Brushes.Blue, DashStyleHelper.Solid, 2);
// Actualizar los valores para el próximo tick
lastBarIndex = CurrentBar;
lastTimestampValue = secondsSinceMidnight;
}
}
}
Comment