![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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);
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 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. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |