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
Movable objects
Collapse
X
-
Movable objects
Is it possible for an indicator to be manipulated on a chart in real-time by the user? For example, if I have an indicator which simply draws a box in a specified location on a chart, is is possible within Ninjascript for a user to be able to the change the dimensions of that box, move it around, etc, in real-time, directly on the chart (without opening the indicator properties)? Thanks.Tags: None
-
Thanks for your reply. I'm having trouble though, when I try this bit of code (taken directly from the help guide), I get "The type or namespace name 'IRectangle' could not be found."
PHP Code:protected override void OnBarUpdate()
{
IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
}
Comment
-
Can this only be used in an indicator? I can get it to work just fine within an indicator (the unlocking works as expected as well), but in a strategy it always gives me that error.
Edit: Never mind....I can get it to work if I create a new blank strategy, just not in the strategy that I want to put it in. Oh well, I'll keep trying.
Edit 2: OK, I think I figured it out.
Thanks again for your suggestions, this does exactly what I wanted.Last edited by Radical; 12-02-2011, 03:23 PM.
Comment
-
Upon further testing, I've discovered another small problem. It seems that with each bar update the drawn object moves back to it's default location. For example, (using a line for simplicity's sake) if I have a line drawn at a y-value of 45.55, and I manually drag that line down to 43.50, with each update to the chart the line will reset itself back to 45.55. I'm guessing this is expected, but is there a way to stop it from happening? If I drag the object, I want it to stay where I dragged it, until I drag it someplace else.
Comment
-
Hello Radical,
Yes, this is expected. If the code submits a new Draw statement, that it will move from any manually placed locations to the code placed once.
You need to code some control so that it's not drawn again. You have one tag so the rectangle will always be redrawn each OnBarUpdate(). Unfortunately there is not a built in"OnManualMove" event you could listen for, so the control must be custom coded.Ryan M.NinjaTrader Customer Service
Comment
-
Sorry for asking so many questions, but I was thinking I could just have the rectangle be drawn at a specific time of day (5:58:00 AM in this example), but this code doesn't work. The error I get is "Embedded statement cannot be a declaration or labeled statement."
PHP Code:protected override void OnBarUpdate()
{
if (ToTime(Time[0]) = 55800)
IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
}
Comment
-
I'm glad to help. That seems like a good approach and that compile error is easy to resolve.
Change to this:
Code:if (ToTime(Time[0]) == 55800) { IRectangle rectangle = DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2); }
Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
5 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
8 responses
61 views
0 likes
|
Last Post Yesterday, 10:45 AM | ||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
4 responses
3,289 views
1 like
|
Last Post
by jgualdronc
Today, 10:02 AM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 09:55 AM | ||
Started by halgo_boulder, 04-20-2024, 08:44 AM
|
2 responses
24 views
0 likes
|
Last Post Today, 09:41 AM |
Comment