Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

timestamp in graph

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    timestamp in graph


    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;
    }
    }

    }​

    #2
    Hello dcriador,

    Thank you for your post.

    Are there errors appearing on the Log tab of the Control Center?

    Is this script running Calculate.OnEachTick?

    To confirm the script is not drawing anything, if you open up the list of Drawing Objects on the chart is it blank?

    I recommend debugging using prints. Add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition. I also suggest adding a print before your Draw.Line call that prints out the values being used to draw the line, such as lastBarIndex - CurrentBar, lastTimestampValue, and secondsSinceMidnight.

    It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    ​I am happy to assist you with analyzing the output from the output window.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    16 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    4 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,407 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Working...
    X