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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X