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 03-17-2012, 09:59 AM   #1
I_Quant
Junior Member
 
Join Date: Feb 2012
Posts: 28
Thanks: 1
Thanked 2 times in 2 posts
Default Override Plot

Hi

Quite a while back Roonius posted a simple Plot Override indicator that showed 12 static lines printed into the right margin using Plot Override. (I can't find that explicit post again, sorry). I understand how the Plot Override is working but I can't figure out how it is actually invoked.

There is an OnBarUpdate() but it has no statements in it. There is an Initialize where the pens and brushes are defined. But that's it. The lines are made to show by selecting a user parameter to "true" and it all works beautifully, But I don't see how the Plot is "called".

Can anyone shed any light on this, and/or point me in the direction of the C# explanation of this behaviour?

thanks in advance
I_Quant is offline  
Reply With Quote
Old 03-17-2012, 10:53 AM   #2
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 I_Quant View Post
Hi

Quite a while back Roonius posted a simple Plot Override indicator that showed 12 static lines printed into the right margin using Plot Override. (I can't find that explicit post again, sorry). I understand how the Plot Override is working but I can't figure out how it is actually invoked.

There is an OnBarUpdate() but it has no statements in it. There is an Initialize where the pens and brushes are defined. But that's it. The lines are made to show by selecting a user parameter to "true" and it all works beautifully, But I don't see how the Plot is "called".

Can anyone shed any light on this, and/or point me in the direction of the C# explanation of this behaviour?

thanks in advance
There is a Plot() function that is called by default on OnBarUpdate or chart refresh. You can define your own Plot() routine to override the default function. IOW, all you have to do to use a custom Plot() function is to specify said Plot() function as an override.

There is no Plot() statement in the OnBarUpdate() event handler, because the code was written to call the default Plot() function. It is just like any other event handler/function, where you can define a new function that calls another function, so that the new function when called shows no explicit call to the called function.
Last edited by koganam; 03-18-2012 at 09:31 PM.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 03-18-2012, 10:38 AM   #3
I_Quant
Junior Member
 
Join Date: Feb 2012
Posts: 28
Thanks: 1
Thanked 2 times in 2 posts
Default

many thanks for the explanation Koganam.

I'm sure with a bit more C# experience I will understand it, lol. I get the gist though, many thanks.

Can I mix this type of plot override with the usual Ninja Plot functions ? for example I would like to show 3 or 4 Ninja plots together with my own custom label plots... say by "Calling" specific instances of the custom label plot under certain circumstances.

(Edit: I will leave that question in to provide context but I think I see the answer is that I can do anything providing my C# skills are up to the mark! unlucky me then :-)

However may I ask where the arguments for the Plot Override are created?
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

The reason I ask is so that if I create my own customPlot( arguments ) I know how to create the bounds, min and max values ...

thanks again

your help is appreciated.
Last edited by I_Quant; 03-18-2012 at 11:33 AM.
I_Quant is offline  
Reply With Quote
Old 03-18-2012, 06:12 PM   #4
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 I_Quant View Post
many thanks for the explanation Koganam.

I'm sure with a bit more C# experience I will understand it, lol. I get the gist though, many thanks.

Can I mix this type of plot override with the usual Ninja Plot functions ? for example I would like to show 3 or 4 Ninja plots together with my own custom label plots... say by "Calling" specific instances of the custom label plot under certain circumstances.

(Edit: I will leave that question in to provide context but I think I see the answer is that I can do anything providing my C# skills are up to the mark! unlucky me then :-)

However may I ask where the arguments for the Plot Override are created?
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

The reason I ask is so that if I create my own customPlot( arguments ) I know how to create the bounds, min and max values ...

thanks again

your help is appreciated.
That may not really be necessary, as bounds, max and min are defined properties of the chart. However, if you want to see some examples of custom Plots, NT itself ships with a CustomPlotSample.cs file. There are other examples in pivots.cs, pricealert.cs, regressionchannel.cs, and a few others besides.
Last edited by koganam; 03-18-2012 at 09:31 PM.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
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
Access data into override Plot skuvv Indicator Development 0 12-12-2011 09:34 AM
Arraylist, List and override Plot weirdness.. darthtrader Indicator Development 0 05-16-2011 09:49 AM
Question about public override void Plot() rcsingleton Indicator Development 7 04-18-2011 10:18 AM
Plot Override chantj Indicator Development 2 04-09-2008 09:10 AM
Override Plot Method cls71 General Programming 1 03-14-2008 01:32 PM


All times are GMT -6. The time now is 03:38 PM.