Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Line with (double startY) set to chart.Control

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

    Draw.Line with (double startY) set to chart.Control

    Hi,

    Is it possible in code to start plotting a line on the left side of the chart?
    Also, will the plot start move as you scroll on chart?

    example
    Draw.Line(this,"Settlement",true, chartControl.CanvasLeft, SM, -100, SM, Brushes.Gray, DashStyleHelper.Solid, 2);

    Thanks, Woody

    #2
    Hello woodyfox,

    It is possible to create a line that is attached to left side of a chart, but you would not want to use ChartControl.CanvasLeft for this. You would want to call ChartControl.GetTimeByX(ChartPanel.X) to get the appropriate input to attach the line to the edge of a chart. You will also want to call this line within OnRender() to have its position update as you scroll a chart.

    Please consider the follow as an example:

    Code:
    private DateTime MyTime;
    private double ClosePrice;
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    	if(ChartControl != null)
    		Draw.Line(this,"Settlement",true, ChartControl.GetTimeByX(ChartPanel.X), ClosePrice, MyTime, ClosePrice, Brushes.Gray, DashStyleHelper.Solid, 2);
    }
    I am using two variables to hold the current time and the current price to use as input with the line. You may update these variables within OnBarUpdate(), because you will not be able to access the normal price and time series' directly from OnRender().

    You may reference the following documentation:

    Draw.Line() - https://ninjatrader.com/support/help...?draw_line.htm

    OnRender() - https://ninjatrader.com/support/help.../?onrender.htm

    GetTimeByX() - https://ninjatrader.com/support/help...gettimebyx.htm

    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    75 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    101 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    289 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X