Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X