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

drawing horizontal and vertical lines addplot and addline

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

    drawing horizontal and vertical lines addplot and addline

    i created an addPlot and and AddLine

    AddPlot(new Stroke(Brushes.Gold, 2), PlotStyle.Hash, "Target1"); // this will be horizontal 10 bars long NOT across the whole screen

    AddLine(Brushes.Red, 3, "ReversalLine"); // this will be vertical

    This is the code

    if(BShowVerticalLine == true)
    {
    tagNumber = tagNumber +1;
    Draw.VerticalLine(this,tagNumber.ToString(),0,fals e,"ReversalLine");
    }

    Draw.HorizontalLine(this,"tagger",High[0],false,"Target1");

    The issues are the following:
    1. brush colors and plot style don't match
    2. how do I make the horizontal line a certain length?
    3. Is the template Name ReversalLine AND Target1?

    #2
    Hello ballboy11,

    If you would like to draw a straight line between two points use Draw.Line().


    Do not use a plot which needs a value for every bar on the chart, do not use Draw.HorizontalLine() which draws across the entire chart.

    When using Draw.Line(), the template is the last string, the tagName is the first string.

    Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

    The tag name when re-used causes the drawing object to be removed and recreated (to be moved or altered). When unique this not remove the existing drawing object and will instead create a second.

    The template name would be if you created a template for the drawing object in the drawing objects window and you would like this template applied to the drawing object when it is drawn.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Drawing Lines

      Thank you I got the line to work but since my code is already half finished I have to change my parameters instead of using Addplot.

      This is what is working

      Draw.Line(this,"Tagger",true,0,High[0],-30,High[0],Brushes.Red,DashStyleHelper.Solid,2,true);

      AddPlot(new Stroke(Brushes.Gold, 2), PlotStyle.Hash, "Target1"); //5

      I did try for fun to see what would happen
      Values[5][-1] = High[0];
      And yes it does not take Negative values

      What I need to do for my targets within my parameters is to allow to change the following

      Brush color
      size
      plot style

      Since you stated I can not use AddPlot and I will be drawing 6 target lines
      How do I put Brush color ,size and plot style in my parameter list?

      Comment


        #4
        Hello ballboy11,

        Values[plotIndex][barIndex] is how a plot would be set for a specific bar.

        You are specifying that you want to set the bar of -1 barsAgo which doesn't exist. (That would be the bar in the future which hasn't been made yet)

        Also, I'm not saying that you cannot use AddPlot(), but this is not designed for what you are trying to do. If you want to draw a line use Draw.Line(). If you want to make a continuous plot across the chart use AddPlot() and create a plot and set a value for this on every bar.

        Are you asking how to change the Brush, plot width, and PlotStyle of a plot?
        Do you want to do this in AddPlot() or after the plot is already created?

        In AddPlot() there are overloads for this.
        AddPlot(Stroke stroke, PlotStyle plotStyle, string name)
        The Stroke object will hold the brush color and the width.

        If you want to modify the plot after it is created the plot will be in the Plots collection.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by timmbbo, Today, 08:59 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by KennyK, 05-29-2017, 02:02 AM
        2 responses
        1,281 views
        0 likes
        Last Post marcus2300  
        Started by fernandobr, Today, 09:11 AM
        0 responses
        3 views
        0 likes
        Last Post fernandobr  
        Started by itrader46, Today, 09:04 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by bmartz, 03-12-2024, 06:12 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X