Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting time of bar closed to use as x-coordinate

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

    Getting time of bar closed to use as x-coordinate

    Hello

    How can I get the time of bar closed to use, for example, as x-coordinate in Draw.Line()?

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, DashStyleHelper dashStyle, int width)

    And, how can I achieve that line endTime be, for example, three hours later?

    I have read NT8 sample but I have not been able to carry out the code.

    Thanks


    #2
    Hi Rosario, thanks for writing in.

    Each bar will contain a timestamp value that you can use. Use the Time[] array to access the time stamp of each bar. This is a series of DateTime objects that can be used in a drawing tool:



    The line needs both time stamps are the time of drawing, so you would need to save the time stamp of first bar, then check the time on every consecutive bar. When the current time stamp (Time[0]) is three hours greater than the saved timestamp then draw the line at that time.

    Best regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    564 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    329 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X