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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    35 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    12 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X