NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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 04-21-2008, 07:53 PM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default Problem with adding plots

Greetings,

Can I get an explanation as to why I cannot add variables/plots to my indicators? Although it compiles there is no plot being made...

#region Variables
double VSLOPE; double VSLOPE2; double VSLOPE_DIFF; double VSLOPE_ROC;
#endregion
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "ROC"));
}
protectedoverridevoid OnBarUpdate()
{
VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF = Math.Abs(VSLOPE - VSLOPE2); VSLOPE_ROC = Math.Abs(VSLOPE_DIFF / VSLOPE2);
ROC.Set(VSLOPE_ROC);
}

Any explanation would be GREATLY appreciated, it is very frustrating to not have these plots and not know why...
Burga1 is offline  
Reply With Quote
Old 04-22-2008, 12:10 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Not sure what TRENDSLOPE[] is, but check your logs for errors. Use print functions to debug at each step.

You will also most likely need to watch out for division by 0.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-23-2008, 06:28 PM   #3
mgbloomfield
Senior Member
 
Join Date: Dec 2006
Location: Seattle, Washington, USA
Posts: 150
Thanks: 0
Thanked 0 times in 0 posts
Default

Does your ROC have a DataSeries?

Do you have something like this in your code?

#region Properties

[Browsable(false)]
[XmlIgnore()]
public DataSeries ROC
{
get { return Values[0]; }
}

#endregion
mgbloomfield is offline  
Reply With Quote
Old 04-24-2008, 11:26 AM   #4
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the replies. Yes I do have the commands in the Properties similar to as shown. What is a "Plot method: Overflow Error"??

Is there a way to have Plot info display in the "Data Box" however NOT PLOT on the indicator display itself? I simply want a quick and easy way to view the data values, not necessarily anything displayed visually...I'm trying to plot the data for 1 plot but only display the values in the Data Box for another...
Burga1 is offline  
Reply With Quote
Old 04-24-2008, 11:28 AM   #5
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

>> "Plot method: Overflow Error"
Where have you seen this.
a) on a NT standard indicator? which one or
b) on a custom indicator? or
c) on a custom indicator where you have overwitten the Plot() method?
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-24-2008, 01:09 PM   #6
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,

On a custom indicator where I have added a Plot() method, not overwritten...the original Plot() is still there. The error is in the log.
Burga1 is offline  
Reply With Quote
Old 04-24-2008, 01:23 PM   #7
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

- can you reproduce this issue in the logs?
- are you on latest 6.5.1000.1?
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-24-2008, 02:00 PM   #8
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes on both questions.
Burga1 is offline  
Reply With Quote
Old 04-24-2008, 02:02 PM   #9
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

Quote:
Originally Posted by Burga1 View Post

protected override void OnBarUpdate()
{
VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF =
I suspect that the solution is that you need to add the following before you attempt to access "[1]"...

Code:
if (CurrentBar < 1) return;
KBJ is offline  
Reply With Quote
Old 04-24-2008, 02:13 PM   #10
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes, I have such a condition already. Here is the complete code within OnBarUpdate:

if(CurrentBar < 50){return;}
Print(Time[
0].ToString()); Print("Current CurrentBar = " + CurrentBar);

TRENDSLOPE.Set(Slope(FIBTREND(
1).Middle, 2, 0));
//VSLOPE = TRENDSLOPE[0]; VSLOPE2 = TRENDSLOPE[1]; VSLOPE_DIFF = Math.Abs(VSLOPE - VSLOPE2);
//VSLOPE_ROC = Math.Abs(VSLOPE_DIFF / VSLOPE2); ROC.Set(VSLOPE_ROC);

The above works fine with everything commented out as displayed. When I "uncomment" those lines that causes the "re-producable" error in the log about the Overflow...
Burga1 is offline  
Reply With Quote
Old 04-24-2008, 02:29 PM   #11
clearpicks
Senior Member
 
Join Date: Jan 2008
Posts: 257
Thanks: 0
Thanked 0 times in 0 posts
Default

When VSLOPE2 == 0 it would cause an overflow. divided by 0.
clearpicks is offline  
Reply With Quote
Old 04-24-2008, 02:30 PM   #12
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

Well, when all else fails, you can always open the Output window and just pepper your code with Print statements.

But it sounds like you need to do this in your Plot() method.

If you add the Print statements and open your Output window, it will become obvious what's going on (or at least what statement is objectionable). This is generally just a 5 to 10 minute exercise, start to finish.
KBJ is offline  
Reply With Quote
Old 04-24-2008, 02:34 PM   #13
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

divide by 0 errors normally appear in the log...do they not? I know I've seen them before there so I assume they always do so.
Burga1 is offline  
Reply With Quote
Old 04-24-2008, 02:43 PM   #14
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

Divide by zero would display an error in the log... if it gets that far.

What I would do is this: put in some Print statements and see.

It's less typing to put in a Print statement than to answer this post!
KBJ is offline  
Reply With Quote
Old 04-24-2008, 10:40 PM   #15
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Quote:
Originally Posted by Burga1 View Post
Yes on both questions.
Great. Please send this info to "christian AT ninjatrader DOT com" and refer to this post:
- your custom indicator in question
- your zipped DB (e.g. by Help->Mail to support)
- which instrument is this?
- which indicator settings have you applied?

Thanks
NinjaTrader_Dierk 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
Adding Plots to Strategy's... Sidhartha Strategy Development 2 04-14-2008 06:32 AM
plots converging ATI user General Programming 8 03-11-2008 04:15 PM
How come plots disappear ? grd974 Indicator Development 1 12-02-2007 06:38 PM
Adding Plots rt-trader General Programming 5 02-09-2007 01:01 AM
Plots[?].Min & Plots[?].Max Don't work AlohaBob Indicator Development 6 01-06-2007 08:31 PM


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