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

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 Max238, Today, 01:28 AM
        4 responses
        33 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by timko, Today, 06:45 AM
        2 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by habeebft, Today, 07:27 AM
        0 responses
        6 views
        0 likes
        Last Post habeebft  
        Working...
        X