This works okay, but my fear is that it is somehow confusing NinjaTrader, since when a line is deleted it still shows up in the DrawObjects object... which is confusing MY code.
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
Invoke the LINE drawing tool from code
Collapse
X
-
Invoke the LINE drawing tool from code
Is there a proper way to invoke the Line drawing tool from ninjascript. The only way I've been able to do it is by calling: SendKeys.Send("{F2}"); (which is the hotkey for the line tool)
This works okay, but my fear is that it is somehow confusing NinjaTrader, since when a line is deleted it still shows up in the DrawObjects object... which is confusing MY code.Tags: None
-
Originally posted by neoikon View PostThis works okay, but my fear is that it is somehow confusing NinjaTrader, since when a line is deleted it still shows up in the DrawObjects collection... which is confusing MY code.
I still feel like there is a larger problem going on. I'm not sure if this work around will work in all cases either.
EDIT: And by "hidden", I mean the lines that were deleted, but are still in the DrawObjects collection.
Any help is greatly appreciated!
DanielLast edited by neoikon; 04-02-2012, 10:34 PM.
-
Originally posted by NinjaTrader_Bertrand View Postneoikon, I guess I'm not exactly sure why you're not working with the NinjaScript DrawLine commands available?
Those programmatically drawn lines could also be managed via the DrawObjects collection then as you seeked.
Thus, I am sending an "F2" to initiate it for the user, with my script listening for it. This feels like a hack. I would really like to initiate the "Line" drawing tool via code, directly.
I don't listen for every line drawn by the user, only the ones that are initiated via my tool.
Does that make sense?
Daniel
Comment
-
I see Daniel, another idea I would then have is having the user normally draw the line via F2 and then changing to a unique tag id for your tool, you can then monitor DrawObjects collection for a user drawn line with a specific tag, this is 'your' line then to be further used in the script.
Some great ideas are also contained in RyanM's script from our sharing dealing with user line Alerts - http://www.ninjatrader.com/support/f...catid=4&id=472BertrandNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Bertrand View PostI see Daniel, another idea I would then have is having the user normally draw the line via F2 and then changing to a unique tag id for your tool, you can then monitor DrawObjects collection for a user drawn line with a specific tag, this is 'your' line then to be further used in the script.
Some great ideas are also contained in RyanM's script from our sharing dealing with user line Alerts - http://www.ninjatrader.com/support/f...catid=4&id=472
What we really need is a generic string param that the programmer can set in the object to use how they see fit. The programmer could put in a delimited list of params or a unique tag name, etc in that string. It would open so many doors. I realize this doesn't exist, but it's what would help.
What I need to do is to be able to change some kind of line attribute to something unique (programmatically, so it can't be read-only) in order to identify it. Thinking outside the box, perhaps I can set the line to one very specific RGB color (that's different from the default Line color) and I look for that specific color. Is there another attribute that I could key off of? Perhaps some Pen attribute that isn't obvious that the user wouldn't commonly already have set as default?
Thanks for the script. I'm not sure it applies to me, but it does bring up an unrelated question. When looking at the DrawObjects collection and you cast a specific object to a line, is it better to cast to ILine or ChartLine? Or does it matter?
Thanks!
Daniel
Comment
-
Hi Daniel, thanks for the feedback, I will add to our product enhancement tracking lists.
I'm not sure where the ChartLine comes into play, we would support those types listed here - http://www.ninjatrader.com/support/h...drawobject.htm
The custom color sounds like a neat idea, perhaps combine that with a specific PenStyle and width for 'your' line to be used.BertrandNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Bertrand View PostI'm not sure where the ChartLine comes into play, we would support those types listed here - http://www.ninjatrader.com/support/h...drawobject.htm
PHP Code:foreach(IDrawObject DrawObj in DrawObjects)
{
if (DrawObj.DrawType == DrawType.Line)
{
ChartLine oLine = (ChartLine)DrawObj; // Using "ChartLine" as the type
...
}
}
// VERSUS
foreach(IDrawObject DrawObj in DrawObjects)
{
if (DrawObj.DrawType == DrawType.Line)
{
ILine oLine = (ILine)DrawObj; // Using ILine as the type
...
}
}
Comment
-
Originally posted by NinjaTrader_Bertrand View PostThe custom color sounds like a neat idea, perhaps combine that with a specific PenStyle and width for 'your' line to be used.
On a related note, is it possible to programmatically look at the default pen that the Line tool uses? In other words, I want to look at the default settings of a line and make sure that I am using a different color, style, etc.
Daniel
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
15 responses
3,269 views
0 likes
|
Last Post Today, 03:15 PM | ||
Started by Tim-c, Today, 02:10 PM
|
1 response
8 views
0 likes
|
Last Post Today, 02:52 PM | ||
Started by Taddypole, Today, 02:47 PM
|
0 responses
2 views
0 likes
|
Last Post
by Taddypole
Today, 02:47 PM
|
||
Started by chbruno, 04-24-2024, 04:10 PM
|
4 responses
51 views
0 likes
|
Last Post
by chbruno
Today, 02:38 PM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
10 responses
402 views
1 like
|
Last Post
by beobast
Today, 02:35 PM
|
Comment