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
Accessing the DrawingTool properties window programmatically
Collapse
X
-
Accessing the DrawingTool properties window programmatically
Hi! How can I programmatically access a properties window of a DrawingTool? For example if I need to scan all objects on the chart and check which of them are Text and which text in particular these objects contain?Tags: None
-
Hello akuntysh, and thank you for your question.
This code example demonstrates how to do this with a generic drawing tool, as well as how to access other features only available to certain drawing tools. Please let us know if there are any other ways we can help.
Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.Attached FilesLast edited by NinjaTrader_JessicaP; 03-27-2017, 03:24 PM.Jessica P.NinjaTrader Customer Service
-
Hello Jessica! Thank you for your answer! However this code
foreach (IDrawingTool myDrawObject in DrawObjects){
DrawingTools.Rectangle rect = myDrawObject as DrawingTools.Rectangle;
}
or this code
foreach (IDrawingTool myDrawObject in DrawObjects){
Rectangle rect = myDrawObject as Rectangle;
}
returns a null to the "rect" variable. I have drawn a rectangle on a chart of course. Am I missing something?
Comment
-
Hi Jessica! I have identified the issue. To some reason if I draw an object before I applied an indicator to a chart - the indicator is unable to covert the drawing tool to a specific type and so returns null (despite it can "see" the object on the chart). However, after a modification of any parameter of a drawn object (even simply accessing the properties window and closing it) the indicator is able to "see" the object and convert it to a specific type.
If I draw an object after I applied the indicator to a chart - it can "see" and convert it without any problems.
Could you please advise on if there is a possible solution for this?
Comment
-
I was not able to see quite the same thing on my end that you are seeing on yours. The attached script can display information about rectangles added before the script. Please review your code against the attached test. We are happy to help with any questions we may.Attached FilesJessica P.NinjaTrader Customer Service
Comment
-
Hi Jessica! Thank you! I have created a script with the code you have sent me and it still can recognize only those rectangles that I have drawn/changed-properties-of after I have applied the script on the chart. However, I have found that I need to open and close the properties window of only one (any) of the objects that are on the chart to make the script "see" all objects. So it is a very minor problem now and I don't want to waste your time any more. Thank you for your attention!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
147 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Comment