![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
I am drawing a rectangle in an area and after a certain number of bars the beginning of the rectangle disappears and starts moving forward. I want the rectangle to stay from the days opening till the close and also want it to stay and have a new rectangle plotted the next day with new parameters. I should be able to scroll back through the days and see the different rectangles still plotted.
Sample here: Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), "Zone")); { { if (CurrentBar == 0) return; } Zone.Set(0); daystart = Bars.BarsSinceSession; DrawRectangle("Zone", false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2); }
Last edited by eDanny; 07-25-2008 at 12:48 PM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
This might help: http://www.ninjatrader-support.com/v...ead.php?t=3419
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
No help at all, and have read it before. If you refer to my code you can see I do plot a rectangle but it doesn't behave as I would like. I tried this and had bad results:
DrawRectangle("Zone" + CurrentBar, false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2); It turned my rectangle solid until about the last 10 price bars, and then gradually lightened up. Also a rectangle was plotted for the previous day at the same level. I need one long rectangle plotted throughout the day, from beginning till close, and stay on chart even when the next days rectangle is starting to plot at a different level. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
The key factor is the
"Zone" + CurrentBar which you figured out already by the link I provided. This makes your rectangle unique. You now would need to figure out the startBar and endBar. As soon as CurrentBar==endBar you can issue the DrawRectangle function.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
That makes sense but I can't see how to define "endbar".
Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), "Zone")); { { if (CurrentBar == ???) << endbar? { if (CurrentBar == 0) return; } Zone.Set(0); daystart = Bars.BarsSinceSession; DrawRectangle("Zone" + CurrentBar, false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2); } }
Last edited by eDanny; 07-25-2008 at 01:15 PM.
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Sorry, I don't know by what logic your rectangle would get "closed" (which is the endBar).
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
Exactly. I don't know if it would, looks like not. Just using this for the first time today and trying to debug.
Look at edited post above yours. |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
You need to define and code the logic on when the "endBar" would get reached.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You can try checking DateTime.Now against the bar's timestamps to determine if the day is over.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
It would be nice to be able to provide a StartDateTime/EndDateTime (instead of BarsAgo) & let DrawXXX do the rest...
(with EndDateTime being able to draw into the future) |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
I still have resolved this issue. I have no idea how to stop the rectangle and start a new one the next day while keeping the old.
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
Each Rectangle is identified by its Tag.
To start a new Rect; change the Tag. The hard part (and undesireable use of resources) is to redraw the Rect with every OnBarUpdate event, having to calc the BarsAgo field. It would be nice to draw it once...and use DateTime to define the left & right sides. |
|
|
|
|
|
#14 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You could use the GetBar() method which accepts a time parameter and retuns n bars ago.
http://www.ninjatrader-support.com/H...V6/GetBar.html
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Jul 2008
Location: East Rochester, NY
Posts: 899
Thanks: 0
Thanked 19 times in 17 posts
|
Why doesn't something like this work? Doesn't the tag effectively change every day and begin a new rectangle?
daystart = Bars.BarsSinceSession; DrawRectangle("Test" + Time[0].DayOfWeek, false, daystart, TestLow, 0 , TestLow + 2, Color.Orchid, Color.Orchid, 1); |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|