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 12-06-2007, 02:02 PM   #1
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default can someone suggest what I'm doing wrong?

Hello,

Below is the code for an indicator which plots the volume histogram with a dot that projects end of bar volume. It compiles ok, but when I add it to a chart all I get is the pane. No volume and no indicator. I used the NT help file tutorial as a guide, I'm very new at this. Any ideas?

///<summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///</summary>
protectedoverridevoid Initialize()
{

Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "PRV"));
CalculateOnBarClose = false;
Overlay = false;
PriceTypeSupported = false;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.


double perCom = Bars.PercentComplete;
double volPRV = (1/perCom)*(Volume[0]);
PRV.Set(volPRV);
}
coolmoss is offline  
Reply With Quote
Old 12-06-2007, 02:11 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Please check the Log tab, likely an error on this indicator at runtime.
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-06-2007, 02:18 PM   #3
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

Quote:
Originally Posted by NinjaTrader_Ray View Post
Please check the Log tab, likely an error on this indicator at runtime.
Nothing on Log tab, just the usual connection messages. Thank your for your help.
coolmoss is offline  
Reply With Quote
Old 12-06-2007, 02:27 PM   #4
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

I just noticed that in the data window, the Volume field says "InfinityM".

????
coolmoss is offline  
Reply With Quote
Old 12-06-2007, 02:41 PM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Then your indicator values are infinite values. You will need to recheck your math.
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-06-2007, 03:46 PM   #6
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

OK, I started the whole thing over from scratch and played aroung with commenting out various portions to see what works and what doesn't.

Every clue I get suggests I'm using Bars.PercentComplete in an incorrect manner.

I assume, for example, on a 5 min chart that Bars.PercentComplete will return a value of 0.2 one minute into the bar, etc. Even if I just get rid of all my math and try and plot Bars.PercentComplete I get a nonsensical display.
coolmoss is offline  
Reply With Quote
Old 12-06-2007, 04:16 PM   #7
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

I think the issue is that Bars.PercentComplete is returning a value of zero on historical bars. Might screw up your math? It should return a value of 1 on a historical bar. Either way, you should ensure that you are handling any potential divide by zero issues.
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-06-2007, 04:23 PM   #8
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

Quote:
Originally Posted by NinjaTrader_Ray View Post
I think the issue is that Bars.PercentComplete is returning a value of zero on historical bars. Might screw up your math? It should return a value of 1 on a historical bar. Either way, you should ensure that you are handling any potential divide by zero issues.
Ray,

I think I figured it out, but won't know until market opens tomorrow so I can run it live. It seems as the Bars.PercentComplete does NOT return the % completed, but rather the % remaining. I'll post again if this turns out to be true. If not, than I'm really baffled, because once I made the adjustment for this, everything looked correct.

Thank you very much for your help.
coolmoss 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
Suggest Option to turn Exit confirmation off ThePatientOne Suggestions And Feedback 6 07-19-2011 10:11 AM
Forex trading - wrong reporting, wrong Close action, connecting jcervinka Miscellaneous Support 2 08-30-2007 09:42 AM
[NT6 bug?] Compiles the wrong indicator FireFly General Programming 2 04-28-2007 06:45 PM
PnL wrong display PrTester Automated Trading 6 03-05-2007 10:24 AM
Wrong strategy executed BradB Automated Trading 1 02-21-2007 02:41 AM


All times are GMT -6. The time now is 11:55 AM.