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-17-2009, 10:56 AM   #1
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default Rectangle won't draw

The following code won't draw the rectangle on tick charts.

protected override void OnBarUpdate()
{
DrawRectangle("tag1", 10, Low[10], 5, High[5], Color.PaleGreen, Color.PaleGreen, 2);
}
maxpi is offline  
Reply With Quote
Old 06-17-2009, 10:59 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please see this tip: http://www.ninjatrader-support2.com/...ead.php?t=3170
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-17-2009, 02:10 PM   #3
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

I got rectangles to draw in my indicator. I can draw a rectangle on the price pane but it's bad, I have to scale things to fit the price range. I cannot get the same code to draw a rectangle in panel2... I added the line DrawOnPricePanel =false to the initializations but nothing draws on panel2. Panel2 just sits there with a scale of 0 to 1...

I can't get it to overlay on the price either. I assume that would take care of all the scaling work...
Last edited by maxpi; 06-17-2009 at 02:21 PM.
maxpi is offline  
Reply With Quote
Old 06-17-2009, 02:21 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

You actually need something populating panel 2 if you want to draw in there. Please add a plot there and try again.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-17-2009, 03:15 PM   #5
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

It draws just vertical lines on panel2. They appear to be where the right and left edge of the rectangles are intended to be. They all have a height of 1 and the panel2 scale is 1. I can print the values at the time of generating the draw objects, they are not 1, ever..
maxpi is offline  
Reply With Quote
Old 06-17-2009, 03:20 PM   #6
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

I added in the plot by copy /paste from another indicator. It does not show up in the indicator properties as applied to the chart.. Can I fix that or is it necessary to step through the wizard and generate a new indicator?
maxpi is offline  
Reply With Quote
Old 06-17-2009, 03:28 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

maxpi,

You probably did not copy paste all the components down in the Properties region of the code.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-18-2009, 10:12 AM   #8
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

I've gone mucking about in the properties section before and had to reinstall the .net, no thanks on that idea.

The main problem I had was an assumption that the rectangle drew from left to right, I had the begin and end values reversed, it was drawing little vertical lines....

Anyhow, I have the indicator drawing rectangles on panel 2 but the scaling is a problem. I have a plot going because it is necessary. I don't really want to use the plot for anything. If I plot the same height as the rectangle, when I have the last tick on the right edge of the screen, the scaling is ok for the one rectangle that is visible at that point. If I scroll back such that the plot is not visible the scaling just becomes unity and all the rectangles have the same height... I've tried various combinations of booleans both in the indicator code, the Draw code, etc... and I just can't get that scale to be other than unity... If I don't plot, the scale is always unity.
Last edited by maxpi; 06-18-2009 at 10:17 AM.
maxpi is offline  
Reply With Quote
Old 06-18-2009, 10:31 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

maxpi,

I am not sure what you mean by unity. Please try using a plot that will just set the scale to what you want all the time and then it should work?
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-18-2009, 03:58 PM   #10
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

unity =1. The scale is zero to one except when the plotted value is shown. The entire code operates on realtime bars only, probably the plot scaling applies only to the most recent bar in that case... I have it plotting on the price panel now, I'll have to change the code to run on history bars to draw it on panel2 I'm sure..

ty
maxpi is offline  
Reply With Quote
Old 06-18-2009, 04:05 PM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Sorry not entirely following you. Just create a plot that actually has a usable scale and then you can draw on it.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-19-2009, 08:39 PM   #12
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

It all runs on realtime data only, that seems to be the crux of the matter, the scaling of panel 2 is ok only when the last tick is visible on the right edge of the screen... it draws ok now overlaying price but it really might be better if I could get it to plot in panel 2.. I'll try allowing it to run on historical data.

ty
maxpi is offline  
Reply With Quote
Old 06-22-2009, 07:07 AM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

maxpi,

Not sure what you mean by "last tick showing". The scale should work regardless as long as there are data points. Please provide screenshots/examples. Thank you.
NinjaTrader_Josh 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
Draw a rectangle to group 3 bars Winnie Indicator Development 1 03-31-2009 05:57 AM
Fancy Rectangle pdavidow Charting 9 03-16-2009 09:04 AM
Rectangle question 5iver Charting 2 11-01-2008 03:14 PM
Rectangle disappears SteveB Charting 2 07-15-2008 08:51 AM
Draw tools that draw on multiple charts of the same instrument cipher4d Suggestions And Feedback 3 04-19-2008 12:33 AM


All times are GMT -6. The time now is 08:05 AM.