NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-06-2011, 06:24 AM   #1
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default How to call the Plot method?

Hello,
I've implemented an indicator with some custom graphic code in the Plot() method following the example in CustomPlotSample. However, I am updating the indicator data asynchronously and I need to have it displayed immediately to the user. Is there any way I can programmatically induce a call to Plot() to achieve that?
Thanks
supernatural is offline  
Reply With Quote
Old 01-06-2011, 06:44 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Unfortunately this is more general C# then NinjaScript therefore falls out of my ability to support. I do know that everything in NinjaTrader is driven by ticks recieved however and we do not support manually updating the chart. You would need to check out or post in this thread for unsupported Tips and Tricks:

http://www.ninjatrader.com/support/f...supported+tips

Good Luck!

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-07-2011, 10:57 AM   #3
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

Brett,
I can't find the information in that thread. I understand this is unsupported but can you at least point me out to some direction? Or maybe someone in the community knows?
supernatural is offline  
Reply With Quote
Old 01-07-2011, 11:13 AM   #4
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Would have to leave open for someone form the community to assist.
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-16-2011, 04:50 PM   #5
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Plot is an override, and I presume that that is what you have done, One way to call the Plot() method without calling the actual overridden function is to duplicate your custom Plot() code and call it by a different name.

Code:
private void PaintBars(Graphics graphics, Rectangle bounds, double min, double max)
{
//duplicate of custom Plot() code here
}
In the indicator, when you want to force a plot, make a call to PaintBars().
Last edited by koganam; 01-16-2011 at 07:17 PM.
koganam is offline  
Reply With Quote
Old 01-17-2011, 07:41 AM   #6
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

Koganam,
I don't have access to the Graphics and Rectangle objects needed to be passed to the drawing method (whether Plot or your PaintBars method) so I can't directly call it. I tried storing them on a first call of Plot but it's not working if I call Plot directly with these values. Only the subsystem has them so I guess I would need to invoke a refresh of the indicator panel or the entire window so it subsequently calls Plot. Does anybody knows how can I get a reference to the indicator panel or the window containing it from the indicator's code? (or any other way to achieve a call to Plot by the subsystem)
Last edited by supernatural; 01-17-2011 at 07:54 AM.
supernatural is offline  
Reply With Quote
Old 01-17-2011, 05:25 PM   #7
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by supernatural View Post
Koganam,
I don't have access to the Graphics and Rectangle objects needed to be passed to the drawing method (whether Plot or your PaintBars method) so I can't directly call it. I tried storing them on a first call of Plot but it's not working if I call Plot directly with these values. Only the subsystem has them so I guess I would need to invoke a refresh of the indicator panel or the entire window so it subsequently calls Plot. Does anybody knows how can I get a reference to the indicator panel or the window containing it from the indicator's code? (or any other way to achieve a call to Plot by the subsystem)
I do not understand. Your very first post in the thread starts with:

Quote:
I've implemented an indicator with some custom graphic code in the Plot() method following the example in CustomPlotSample.
How then did you implement your custom Plot()?
koganam is offline  
Reply With Quote
Old 01-17-2011, 06:11 PM   #8
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

Is there a problem with things like GC lifetime? Can you squirrel away a GC and expect it to be valid later? How about the other information passed in to Plot() as parameters -- is it guaranteed to still be valid when he does his ersatz Plot()? What about if the user has resized the screen in the meantime?

--EV
ETFVoyageur is offline  
Reply With Quote
Old 01-18-2011, 11:48 AM   #9
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by koganam View Post
How then did you implement your custom Plot()?
Plot() is overridden and called by the subsystem which provides it with the necessary graphics objects. It is called at each new bar when a graphic event occurs in the graph window. I don't call Plot directly (but I'm trying to).
supernatural is offline  
Reply With Quote
Old 01-18-2011, 11:55 AM   #10
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

I agree that would not be a clean way, and anyway it's not working. Probably the proper way to achieve a call to Plot would be to call a refresh on the window containing the indicator panel, which would then force a call to Plot. The problem is how can I get a handle to that window from the indicator's code...


Quote:
Originally Posted by ETFVoyageur View Post
Is there a problem with things like GC lifetime? Can you squirrel away a GC and expect it to be valid later? How about the other information passed in to Plot() as parameters -- is it guaranteed to still be valid when he does his ersatz Plot()? What about if the user has resized the screen in the meantime?

--EV
supernatural is offline  
Reply With Quote
Old 01-18-2011, 11:58 AM   #11
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by supernatural View Post
Plot() is overridden and called by the subsystem which provides it with the necessary graphics objects. It is called at each new bar when a graphic event occurs in the graph window. I don't call Plot directly (but I'm trying to).
So is your original statement then incorrect? Have you or have you not written a custom plot that overrides the default Plot() method? Your initial statement implies that you have. Am I missing something here ?
koganam is offline  
Reply With Quote
Old 01-18-2011, 12:01 PM   #12
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by supernatural View Post
... achieve a call to Plot would be to call a refresh on the window containing the indicator panel, which would then force a call to Plot. ...
The unsupported ChartControl.Refresh() ?
koganam is offline  
Reply With Quote
Old 01-18-2011, 12:06 PM   #13
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes I did override Plot and it works. But it is called (implicitely) at each bar. And I want to call (explicitely) it between bars, at any time I want. This is because I am updating my indicator with data that is downloaded from the internet and that data is updated asynchronously.


Quote:
Originally Posted by koganam View Post
So is your original statement then incorrect? Have you or have you not written a custom plot that overrides the default Plot() method? Your initial statement implies that you have. Am I missing something here ?
supernatural is offline  
Reply With Quote
Old 01-18-2011, 12:15 PM   #14
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by supernatural View Post
Yes I did override Plot and it works. But it is called (implicitely) at each bar. And I want to call (explicitely) it between bars, at any time I want. This is because I am updating my indicator with data that is downloaded from the internet and that data is updated asynchronously.
Then from the signature of the Plot() method, your custom plot must have a graphics input.

Why do you think that a copy of that method, with the same signature, cannot access a graphics object?
koganam is offline  
Reply With Quote
Old 01-18-2011, 12:26 PM   #15
supernatural
Junior Member
 
Join Date: Jul 2009
Location: Western Europe
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

That's it! This is what I was looking for. Thanks a lot Koganam. What a relief. Very useful this ChartControl, too bad this is undocumented.

Quote:
Originally Posted by koganam View Post
The unsupported ChartControl.Refresh() ?
supernatural is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to call method 'Initialize' daven Miscellaneous Support 2 07-30-2010 07:01 AM
Failed to call method 'Initialize' for strategy ' richa61416 Version 7 Beta General Questions & Bug Reports 10 04-23-2010 04:20 AM
Can I call a method from another kaywai General Programming 2 02-24-2010 07:05 AM
failed to call method 'initialize' for indicator tinkerz General Programming 4 02-22-2010 09:46 AM
ERROR: Failed to call method 'Initialize' for indicator NinjaCustomer Indicator Development 11 12-09-2009 05:41 AM


All times are GMT -6. The time now is 12:24 PM.