NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-23-2009, 01:33 PM   #1
wcmaria
Junior Member
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 0 times in 0 posts
Default Drawline

I have the following code which I would like to draw a circle below the bar the crosses and also draw a line.

if (CrossAbove(EMA(14), EMA(145), 1))
DrawDot(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Solid, 1);

When I run the indicator it works when just the drawDot line is in, when I add the drawline it does not draw the dot or the line.

Is there a reason for this?

Thanks
wcmaria is offline  
Reply With Quote
Old 06-23-2009, 01:37 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

wcmaria,

You need to place them within { } brackets for the if-statement.

Code:
if (CrossAbove.....)
{
     DrawDot(...);
     DrawLine(...);
}
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-23-2009, 02:01 PM   #3
wcmaria
Junior Member
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the input.

When I include the following code

if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);
Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawLine(CurrentBar.ToString(), false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Solid, 1);
}

it does not work (shows nothing on the screen), but when I hash out the print and drawline lines it prints the dot in the correct place.
wcmaria is offline  
Reply With Quote
Old 06-23-2009, 02:13 PM   #4
wcmaria
Junior Member
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 0 times in 0 posts
Default

It seems in my case I cannot use both the Drawdot and DrawTriangle within the same if statement. It will only work if I use one or the other.


if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot(CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
//Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawTriangleDown(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);

}

Is there a way to draw both a circle below and a several triangles at different prices above the same bar?
wcmaria is offline  
Reply With Quote
Old 06-23-2009, 02:15 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

The reason is because you are using the exact same object name. You need to use separate names if you want two separate objects.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-23-2009, 03:30 PM   #6
eDanny
Senior Member
 
eDanny's Avatar
 
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
Default

Try something like this:

if (CrossAbove (EMA(14), EMA(145), 1) )
{
DrawDot("MyDot" + CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
//Print((MAEnvelope(0.5,25).LowerBand[0]));
DrawTriangleDown("MyTriangle" + CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Red);

}
eDanny is offline  
Reply With Quote
Old 06-24-2009, 05:28 AM   #7
wcmaria
Junior Member
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the responses everyone. It worked.

Will
wcmaria is offline  
Reply With Quote
Reply

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
drawline to nowhere gg80108 Indicator Development 9 05-01-2009 12:43 PM
Drawline Does Not Work doug_p Charting 3 01-06-2009 08:57 AM
Drawline puppeye Indicator Development 2 12-22-2008 06:49 AM
DrawLine into the future? higler General Programming 4 09-10-2008 12:27 PM
DrawLine Help PrTester Charting 1 02-09-2008 08:41 PM


All times are GMT -6. The time now is 10:02 AM.