![]() |
|
|
|
|
#1 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
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...
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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); } |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
No that was not what I was suggesting. I was suggesting you to use your DrawRectangle. CandleOutlineColor does not change width. It changes color.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Certified NinjaScript Consultant
|
Quote:
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 |
|
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Great suggestion roonius! Thanks.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Argb = alpha red green blue
Unfortunately we cannot offer support for ChartControl.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
Ok. How can you use argb to set color opacity to the level you want.
Is there other ways to select opace colours? Thanks |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Mar 2008
Location: UK West Sussex
Posts: 665
Thanks: 9
Thanked 9 times in 7 posts
|
That is a very elegant solution and so simple!
Brilliant. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |