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 01-09-2009, 04:24 AM   #1
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Boxes

I have been trying to find a way of placing a highligh box around a bar for a certain condition. At the moment all I can do is create a boxwhose edges are on the main body of the bar. I have attached a screen shot of what I mean. I have also placed an insert from another program that does what I wish

if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
}

The code above is what I have used. Can you suggest a way to alter code to achieve what I am looking for.
Attached Images
File Type: png High Light Boxes.png (15.5 KB, 55 views)
cptrader is offline  
Reply With Quote
Old 01-09-2009, 06:47 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Hi cptrader, basically you look for a way to center the rectangles. Easiest would be to color your conditions by changing the BarColor and then uppen the thickness of the bar...
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-09-2009, 07:12 AM   #3
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Boxes

Thanks for your reply
Not entirely sure what you mean.
I have added code to change colour but not sure how to change the thickness.Are you saying that if condition bar is thicker then the boxes will be off centre?

if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
{BarColor = Color.Blue
DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
}

cptrader is offline  
Reply With Quote
Old 01-09-2009, 07:32 AM   #4
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

You cannot create a box that has anchor points not on the center line of a bar. What you can try is outlining the bar via a box that encompasses the prior bar and the next bar.

If this is unacceptable your only option is to override the Plot method and this is unfortunately advanced C# programming that we cannot offer support for.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-09-2009, 07:42 AM   #5
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default boxes

Were you suggesting using CandleOutlineColor = Color.Purple; and thickening it

Can you please explain how to increase thickness of an individual bar or the candle outline
cptrader is offline  
Reply With Quote
Old 01-09-2009, 07:56 AM   #6
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

No that was not what I was suggesting. I was suggesting you to use your DrawRectangle. CandleOutlineColor does not change width. It changes color.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-09-2009, 11:49 AM   #7
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 3 times in 3 posts
Send a message via Skype™ to roonius
Default

Quote:
Originally Posted by cptrader View Post
I have been trying to find a way of placing a highligh box around a bar for a certain condition. At the moment all I can do is create a boxwhose edges are on the main body of the bar. I have attached a screen shot of what I mean. I have also placed an insert from another program that does what I wish

if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
}

The code above is what I have used. Can you suggest a way to alter code to achieve what I am looking for.
I can offer you another way to achieve what you want avoiding overrinding plot method.

You can draw a line on the bar you want to highligh, just set line width more than bar width and set color opacity to the level you want.

This way has a downside - "box" width won't change if you change x scale until you refresh indicator (f5). If this does not suit you - the only way remaining is to override the plot method.

Attached is simple example.
Hope it helps

roonius
Attached Images
File Type: jpg outline.jpg (46.1 KB, 75 views)
Attached Files
File Type: zip outline.zip (3.5 KB, 24 views)
roonius is offline  
Reply With Quote
Old 01-09-2009, 11:53 AM   #8
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

Great suggestion roonius! Thanks.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-15-2009, 07:10 AM   #9
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Boxes

This was exactly the solution I was looking for. Thanks roonius

Just a few clarifications with code

Firstly

Color myColor = Color.FromArgb(50,0,0,255);

Can someone clarify what the inter imputs stand for?

DrawLine("line"+CurrentBar.ToString(),0,Low[0]-TickSize,0,High[0]+TickSize,myColor,DashStyle.Solid,
ChartControl.ChartStyle.GetBarPaintWidth(ChartCont rol.BarWidth)+
2);

GetBarPaintWidth(ChartControl.BarWidth)+2);

Can some please explain this function? I have altered the integer value (2) but there appears no change to chart.appearance.

cptrader is offline  
Reply With Quote
Old 01-15-2009, 07:13 AM   #10
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

Argb = alpha red green blue

Unfortunately we cannot offer support for ChartControl.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-15-2009, 07:26 AM   #11
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Boxes

Ok. How can you use argb to set color opacity to the level you want.
Is there other ways to select opace colours?


Thanks
cptrader is offline  
Reply With Quote
Old 11-06-2009, 09:45 AM   #12
Mindset
Senior Member
 
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
Default Roonius

That is a very elegant solution and so simple!
Brilliant.
Mindset 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
High Light Boxes cptrader General Programming 7 12-03-2008 07:52 AM
Allow for line width 0 when drawing boxes tobbe Suggestions And Feedback 2 08-10-2008 04:39 AM
Removal of the popup boxes in NT Mike_32 Suggestions And Feedback 5 05-13-2008 09:23 PM
Useless Message boxes all day long. bi9foot Charting 15 01-16-2008 08:24 AM
Unmoveable properties boxes Antraman Charting 2 09-15-2006 04:16 PM


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