Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Drawing a rectangle OnBarClose to the right, into the current developing bar
Collapse
X
-
Drawing a rectangle OnBarClose to the right, into the current developing bar
What would my "endBarsAgo" value be to print a rectangle into a developing column if I am using an "on bar close" indicator? My "startBarsAgo" would be zero to start the rectangle on the first fully developed bar, right?. This is the draw method I am using:
Code:Tags: None
-
Hello rbeckmann05,
Thank you for your note.
When calculating On Bar Close, you won't be able to draw into the currently developing bar. You would be able to draw up to the bar right before the currently developing bar. The same could be observed with other indicators, such as an EMA - if you set it to calculate On Bar Close, it will show values up to the last fully formed bar. If you change it to On Price Change or On Each Tick, then it will calculate during the currently forming bar.
When it comes to barsAgo indexes, they count from the right backward. The "current bar" is 0 bars ago and the bar before that to the left is 1 barsAgo, etc. We have a page about referencing the correct bar here:
If you want the rectangle to start on the first bar on the chart all the way to the left, that would be the value of CurrentBar for the startBarsAgo.
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
-
Hi Emily,
Thank you for the helpful response. Is there some way for me to start a yhighlight at the first complete bar, and extend the highlight only to the right or for a defined length? That should do the trick just fine.
Best regards,
Ryan Beckmann
Comment
-
Hello Ryan,
Thank you for your reply.
It is not supported to extend an object into the future; the anchors for the object must be associated with a time/bar index that already exists on the chart or else you could experience unexpected behavior. Please provide an example of a "defined length" that you have in mind and I would be glad to provide a code snippet for you.
I look forward to assisting you further.Emily C.NinjaTrader Customer Service
Comment
-
For example, if I draw a yhighlight in an OnBarClose program anchored at bar[0] (the first completed bar before a developing bar), is there some way to tell the yhighlight to only extend from the anchor point to the right? If not, Is there a way to tell the yhighlight to start at anchor point (bar[0]), and end on the developing bar? I am using a 1 minute chart, so maybe there is some way to set the end point to a predictable value such as 1 minute in the future, or 1 bar index to the right? Thank you for the help
Comment
-
Originally posted by rbeckmann05 View PostFor example, if I draw a yhighlight in an OnBarClose program anchored at bar[0] (the first completed bar before a developing bar), is there some way to tell the yhighlight to only extend from the anchor point to the right? If not, Is there a way to tell the yhighlight to start at anchor point (bar[0]), and end on the developing bar? I am using a 1 minute chart, so maybe there is some way to set the end point to a predictable value such as 1 minute in the future, or 1 bar index to the right? Thank you for the help
For example, the following rectangle would be drawn from the first bar on the left of the chart up until the current bar. The startY value is the current day's high and the endY value is the current day's low:
Code:Draw.Rectangle(this, "tag", false, CurrentBar, CurrentDayOHL().CurrentHigh[0], 0, CurrentDayOHL().CurrentLow[0], Brushes.Blue, Brushes.Blue, 30);
Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, Brush areaBrush, int areaOpacity)
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tin34, Today, 03:30 AM
|
2 responses
15 views
0 likes
|
Last Post
by Tin34
Today, 04:11 AM
|
||
Started by sastrades, Yesterday, 09:59 AM
|
2 responses
29 views
0 likes
|
Last Post Today, 04:06 AM | ||
Started by ETFVoyageur, Today, 12:52 AM
|
1 response
15 views
0 likes
|
Last Post Today, 03:36 AM | ||
Started by lollers, Today, 03:26 AM
|
0 responses
10 views
0 likes
|
Last Post
by lollers
Today, 03:26 AM
|
||
Started by aliyahany, Today, 03:16 AM
|
0 responses
2 views
0 likes
|
Last Post
by aliyahany
Today, 03:16 AM
|
Comment