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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-02-2008, 01:31 AM   #1
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default High Light Boxes

I am trying to draw boxes around the candles that confirms a Simple moving average cross. The code I have so far come up with is:

if (CrossAbove(SMA(Close, 5), SMA(Close, 20), 1))
{
DrawRectangle(
"My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Blue,BackColor,2);
}
if (CrossBelow(SMA(Close, 5), SMA(Close, 20), 1))
{
DrawRectangle(
"My rectangle2"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Red,BackColor,2);
}

The edges of the boxes go through the middle of the candles not either side of the correct candle.Is there a way of correcting this?
Can I change the color of the inside high light?
For some reason not all crosses are high lighted. Any ideas why?

Many thanks
cptrader is offline  
Reply With Quote
Old 12-02-2008, 05:46 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader,

I briefly checked your code on the Dec ES 3 min chart and saw all crosses in relation to your SMA settings (5 / 20) plotted correctly.

The start of the rectangle was set at the time coordinate 1 bar ago to the bar on which the cross was detected, which is what your code set out to do.

You can change the fill color, by setting the 'BackColor' to your desired color, see my code change in red below.

Code:
DrawRectangle("My blue rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Blue, Color.Blue, 2);
Please also review this link - http://www.ninjatrader-support.com/H...Rectangle.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-02-2008, 06:40 AM   #3
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default High Light Boxes

Thanks for the reply
Is there any way to adjust code so to have the box go around the candle rather than from middle of one candle to the middle of the next.
cptrader is offline  
Reply With Quote
Old 12-02-2008, 07:28 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader,

Maybe there is a simpler way to accomplish what you seek - you could change either the bar color or the outline color of the candles according to your cross over condition.

Please see these links - http://www.ninjatrader-support.com/H...lineColor.html

http://www.ninjatrader-support.com/H.../BarColor.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-02-2008, 07:43 AM   #5
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default High Light Boxes

Good idea. I did notice when I change timeframes the correct bar is not always colored. Is there a reason for this?
I also tried putting diamonds using
DrawDiamond("tag2", true,1, Low[0] - TickSize, Color.Red);

Is there a way to put diamonds on all occurrance and not just last occurance
cptrader is offline  
Reply With Quote
Old 12-02-2008, 08:05 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader,

Please post a screenshot of where you think a drawing is missing. Keep in mind a cross can be visually hard to identify sometimes, because values can be very close. So comparing values in the DataBox bar by bar may help you out.

Please create a unique tag by using this format: 'Your Tag Name' + CurrentBar, then you should see all the Diamonds in your chart.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-03-2008, 07:01 AM   #7
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Tick Size

I have tried placing diamonds above or below cross overs.
I am having some issue with ticksize.
For ES-1208 ticksize appears to be 1 full point and not a tick.
For Currencies ticksize does not use decimals so my charts are distorted when I plot the diamonds.
Is there a way to get ticksize to use the increments of the instrument being used?
cptrader is offline  
Reply With Quote
Old 12-03-2008, 07:52 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader,

Just did a quick test and get the correct TickSize of the ES with 0.25, not a full point.

For the EURUSD I get 0.0001, which is 1 Pip, so also correct.

Please check your settings for ES in the Instrument Manager, Tick Size should be 0.25 and Point Value 50.

For EURUSD 0.0001 TickSize and Pointvalue of 100000.

http://www.ninjatrader-support.com/H...struments.html
NinjaTrader_Bertrand 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
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
Day Light saving time and Charts akwonline Historical NinjaTrader 6.5 Beta Threads 11 04-02-2008 01:08 AM
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 07:32 PM.