NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-22-2011, 02:42 PM   #1
Hawk Arps
Member
 
Join Date: Oct 2008
Location: Lopez Island Washington
Posts: 47
Thanks: 32
Thanked 0 times in 0 posts
Default 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);}
}
Hawk Arps is offline  
Reply With Quote
Old 06-22-2011, 02:52 PM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
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.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 06-22-2011, 03:24 PM   #3
Hawk Arps
Member
 
Join Date: Oct 2008
Location: Lopez Island Washington
Posts: 47
Thanks: 32
Thanked 0 times in 0 posts
Default

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);
Hawk Arps is offline  
Reply With Quote
Old 06-22-2011, 03:36 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Hawk Arps,

Yes, this is possible. Please see this forum post which explains the approach:
http://www.ninjatrader.com/support/f...ead.php?t=4977
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Reply

Tags
drawline, plots

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
zigzag mullum Automated Trading 10 06-17-2011 12:12 AM
ZigZag Help GreenTrade Indicator Development 7 05-27-2011 05:42 AM
ZigZag on last bar ssierra NinjaScript File Sharing Discussion 3 02-02-2008 01:33 AM
ZigZag with labels dkelly NinjaScript File Sharing Discussion 3 01-25-2008 11:03 AM
ZigZag indicator... funk101 Miscellaneous Support 2 11-24-2007 06:53 PM


All times are GMT -6. The time now is 11:58 PM.