![]() |
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 |
|
Senior Member
Join Date: Jan 2008
Posts: 130
Thanks: 0
Thanked 0 times in 0 posts
|
DrawRectangle("tag1", 10, Low[10], 0, High[5], Color.Blue);
I'm doing something wrong... put that code in onBarUpdate() and it does not draw the rectangle on the right of the screen, I mean there chart plots data much past the right edge of the right side of the rectangle. How can I draw a rectangle that goes right to most recent bar? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
It depends on which bar you started drawing on. If you drew the rectangle and the market continued to add points the rectangle won't be on the edge.
The syntax is this: DrawRectangle(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2008
Posts: 130
Thanks: 0
Thanked 0 times in 0 posts
|
I am drawing it in onBarupdate, so should be at edge always.
Is it possible that it is not at the edge because markets are closed right now? Or should it be at the edge even when not connect to a datafeed? my example displayed is just trying to modify help file example so that it draws the rectangle at the edge. I want to achieve an "right edge aligned" rectangle. |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
It depends how you are doing it. Please post the code snippet.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2008
Posts: 130
Thanks: 0
Thanked 0 times in 0 posts
|
very strange... my indicator with the problem has way too much code to paste here, however when I try to put the same code that works in that indicator into a new indicator, it doesn't even draw a rectangle?!?
here is code from MyCustomIndicator which I used for testing... it uses same initialize() true/false settings as my real indicator, and the same drawrectangle line as in my real indicator. It is just that this MyCustomIndicator does nothing... don't know why. I could've sworn that yesterday I made a similar test indicator and it did work... so did a test strategy. The only problem was that '0' is not the last bar... anyhow today it doesn't even draw a rectangle. But my real indicator still draws the rectangle.... anyhow if this drawrectangle is put into my real indicator then it will draw the rectangle.. it is just that '0' is not the last bar of the chart... it is more like the middle of the chart window. There are many bars after that... I am not connected right now to any server. Code:
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
BarsRequired = 200;
AutoScale = false;
DisplayInDataBox = false;
CalculateOnBarClose = true;
PaintPriceMarkers = false;
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
DrawRectangle("abcrect", false, 10, Low[100], 0, High[0], Color.Black, Color.Black, 5);
}
Last edited by NinjaCustomer; 05-18-2008 at 01:22 PM.
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2008
Posts: 130
Thanks: 0
Thanked 0 times in 0 posts
|
note, I just tested drawregion using sample bollingband example from help file... it exhibits same behaviour... there are many bars drawn after the '0' bar, which is around the middle of the chart
|
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
The reason is because you are calling an index of 100 without first doing the CurrentBar check.
http://www.ninjatrader-support.com/v...ead.php?t=3170
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jan 2008
Posts: 130
Thanks: 0
Thanked 0 times in 0 posts
|
ok, thanks that gave me some clues as to what was going on... my indicator had a lot of code so was tough to see everything also. So solved all my problems...
just kinda confused why I need to do a bars checked in on bar update if barsrequired was 200, and I was only doing the last [100]... but doesn't matter really... |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DrawRectangle not working | Kunisoft | Indicator Development | 5 | 03-02-2009 04:51 AM |
| What I am really missing ... | michaelbb | Suggestions And Feedback | 1 | 05-09-2008 08:14 AM |
| Missing data | sambar | Charting | 2 | 04-21-2008 01:31 AM |
| Missing Link | Mrshultzy | Installation and Licensing | 1 | 04-02-2008 10:45 AM |
| Missing data | Weston | Charting | 2 | 09-10-2007 08:56 AM |