I see in the help how to draw horizontal lines, but I would like to draw a box around a specific number of bars (to identify custom patterns) and have that drawing stay with those bars. After searching here I found plenty on drawing horizontal lines, but how would I draw the sides to close it into a box and have it stay on those bars? Maybe I am not searching the right terms. If you could point me to a post that would be great, thank you.
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 box or line around a specific number of bars.
Collapse
X
-
Drawing a box or line around a specific number of bars.
Hello,
I see in the help how to draw horizontal lines, but I would like to draw a box around a specific number of bars (to identify custom patterns) and have that drawing stay with those bars. After searching here I found plenty on drawing horizontal lines, but how would I draw the sides to close it into a box and have it stay on those bars? Maybe I am not searching the right terms. If you could point me to a post that would be great, thank you.Tags: None
-
Hello HaveGunsWillTravel,
Thanks for your post.
If you are wanting to draw a box or rectangle, you could consider using Draw.Rectangle() to draw a rectangle on the chart.
See this help guide documentation for more information about Draw.Rectangle(): https://ninjatrader.com/support/help..._rectangle.htm
Let us know if we may assist further.Brandon H.NinjaTrader Customer Service
- Likes 1
-
[QUOTE=NinjaTrader_BrandonH;n1181140]Hello HaveGunsWillTravel,
Ha! Go figure, I saw draw line and got saturated on that thinking I need to draw four... Thanks again.
Comment
-
am struggling...Originally posted by NinjaTrader_BrandonH View PostHello HaveGunsWillTravel,
Thanks for your post.
If you are wanting to draw a box or rectangle, you could consider using Draw.Rectangle() to draw a rectangle on the chart.
See this help guide documentation for more information about Draw.Rectangle(): https://ninjatrader.com/support/help..._rectangle.htm
Let us know if we may assist further.
protected override void OnBarUpdate()
{
//Want to draw rectangle around these bars if they occur
if((Close[0] < Close[1]) && (Close[1] < Close[2]) && (Open[0] > Open[1]) && (Open[1] > Open[2]))
Draw.Rectangle(this, "iii", 2, Low[2] - TickSize, 0, High[0] + TickSize, Brushes.White);
}
}
Comment
-
Hello HaveGunsWillTravel,
Thanks for your note.
When the condition to draw the rectangle becomes true, the rectangle will be drawn on the chart.
I have tested your Draw.Rectangle() method without the condition and the rectangle is drawn on the chart without issue. See the attached example strategy.
To understand why the script is behaving as it is, such as drawing objects or not drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.
In the script, add prints (outside of any conditions) that print the values of every variable used in every condition along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
Please let me know if I may further assistAttached FilesBrandon H.NinjaTrader Customer Service
- Likes 1
Comment
-
[QUOTE=NinjaTrader_BrandonH;n1181213]Hello HaveGunsWillTravel,
Thank you! I think I got it working now...
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,407 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
98 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
160 views
0 likes
|
Last Post Yesterday, 10:23 PM |
Comment