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 Properties

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

    Draw.Line Properties

    I’m trying to draw a line on a chart and get it to use the attributes set under the UI that is setup by AddPlot(). I have 3 instances that I’m using, 2 of them work ok but the one using Draw.line doesn’t use the attributes …. line type, color etc set in the UI that is setup by AddPlot(). Here is the code example. Thanks for your help.




    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"My Test.";
    Name = "MyTest";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = true;
    AddPlot(new Stroke(Brushes.Orange, DashStyleHelper.Dash, 4), PlotStyle.Line, "LineProperties");

    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if(CurrentBar < 10)
    return;

    Draw.Line(this, "AB", true, 9, High[9], 0, Low[0], true, "LineProperties");

    LineProperties[0] = 72.45; //This draws a line at the price of 68.55 and is controlled by the color, linetype etc From AddPlot

    //Values[0][0] = Median[0]; //This draws a line from the middle of each bar and is controlled by the color, linetype etc From AddPlot

    }

    #region Properties
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> LineProperties
    {
    get { return Values[0]; }
    }
    #endregion

    }

    #2
    Hello jamarc,

    Thanks for your post.

    You would need to use the correct method overload to set the line properties of color, dashstyle and width. From the help guide here: https://ninjatrader.com/support/help...?draw_line.htm ,the overload that provides those parameters is:
    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, DashStyleHelper dashStyle, int width)

    With reference to the help guide section here: https://ninjatrader.com/support/help...-us/?plots.htm you can obtain the plot characteristics and then use them in the above method overload. For example:

    Draw.Line(this, "AB", true, 9, High[9], 0, Low[0], Plots[0].Brush, Plots[0].DashStyleHelper, (int) Plots[0].Width);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul. Working Now

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by trilliantrader, 04-18-2024, 08:16 AM
      4 responses
      18 views
      0 likes
      Last Post trilliantrader  
      Started by mgco4you, Today, 09:46 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by wzgy0920, Today, 09:53 PM
      0 responses
      9 views
      0 likes
      Last Post wzgy0920  
      Started by Rapine Heihei, Today, 08:19 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 08:25 PM
      0 responses
      10 views
      0 likes
      Last Post Rapine Heihei  
      Working...
      X