Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plot-time

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

    plot-time

    Hello,

    I can plot my lines accessing bars or time, both for current day. But I could not find how I can plot the day before and 2 days ago.

    What do I have to change in the code please for having this line plotted on the chart not today but yesterday and the day before please:

    Today (works ok): Draw.Line(this, "pivot0", false, new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 00, 0), pivot0, new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 22, 00, 0), pivot0, Brushes.Green, DashStyleHelper.Solid, 2);

    Yesterday: Draw.Line(this, "pivot1", false, ???, pivot1, ???, pivot1, Brushes.Green, DashStyleHelper.Solid, 2);
    2 days ago: Draw.Line(this, "pivot2", false, ???, pivot2, ???, pivot2, Brushes.Blue, DashStyleHelper.Solid, 2);

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for your post.

    You could use DateTime.AddDays to add a negative number of days to the current time and use those values to plot your lines:

    Returns a new DateTime that adds the specified number of days to the value of this instance.


    DateTime OneDayAgo = Time[0].AddDays(-1);

    DateTime TwoDaysAgo = Time[0].AddDays(-2);

    You can then use that to build a DateTime like you have in your example.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    77 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X