Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ZigZag Lines

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

    ZigZag Lines

    I am trying to create a custom 'ZigZag' tool, but when applied to the chart it will only draw the last two lines... how do I get NinjaScript to draw the zigzag lines over the entire range of price data?
    I'm using the following code structure...wherein 'flipup' and 'flipdn' represent the bars on which a confirmed trend-change occurs.


    if(flipdn)
    {
    {DrawLine("UpLine",false,CurrentBar-PvtBar[1],PvtPrice[1],PvtHiBarsBack,PivotHigh,Color.Blue,DashStyle.Soli d,2);}
    }

    if(flipup)
    {
    {DrawLine("DnLine",false,CurrentBar-PvtBar[1],PvtPrice[1],PvtLoBarsBack,PivotLow,Color.Red,DashStyle.Solid, 2);}
    }

    #2
    Originally posted by Hawk Arps View Post
    I am trying to create a custom 'ZigZag' tool, but when applied to the chart it will only draw the last two lines... how do I get NinjaScript to draw the zigzag lines over the entire range of price data?
    I'm using the following code structure...wherein 'flipup' and 'flipdn' represent the bars on which a confirmed trend-change occurs.


    if(flipdn)
    {
    {DrawLine("UpLine",false,CurrentBar-PvtBar[1],PvtPrice[1],PvtHiBarsBack,PivotHigh,Color.Blue,DashStyle.Soli d,2);}
    }

    if(flipup)
    {
    {DrawLine("DnLine",false,CurrentBar-PvtBar[1],PvtPrice[1],PvtLoBarsBack,PivotLow,Color.Red,DashStyle.Solid, 2);}
    }
    To draw multiple lines, your lines must have unique tags. The most common method used in these parts is to append the CurrentBar to a prefix. Using your syntax, your lines will then be tagged:

    "UpLine" + CurrentBar.ToString()and
    "DnLine" + CurrentBar.ToString()

    respectively.

    Comment


      #3
      Is it possible to declare the color parameter as a variable which could be referenced by input options.
      ie:
      private Color UpColor =Color.Blue;
      private Color trendcolor;

      if (something){trendcolor=UpColor;}
      DrawLine(.........,trendcolor,2);

      Comment


        #4
        Hi Hawk Arps,

        Yes, this is possible. Please see this forum post which explains the approach:
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X