Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Indicator Development

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

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 12-06-2007, 03:02 PM   #1
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 460
Thanks: 48
Thanked 70 times in 55 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, 03:11 PM   #2
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,095
Thanks: 31
Thanked 266 times in 105 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, 03:18 PM   #3
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 460
Thanks: 48
Thanked 70 times in 55 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, 03:27 PM   #4
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 460
Thanks: 48
Thanked 70 times in 55 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, 03:41 PM   #5
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,095
Thanks: 31
Thanked 266 times in 105 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, 04:46 PM   #6
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 460
Thanks: 48
Thanked 70 times in 55 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, 05:16 PM   #7
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,095
Thanks: 31
Thanked 266 times in 105 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, 05:23 PM   #8
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 460
Thanks: 48
Thanked 70 times in 55 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 Platform Technical Support 2 08-30-2007 09:42 AM
[NT6 bug?] Compiles the wrong indicator FireFly General Development 2 04-28-2007 06:45 PM
PnL wrong display PrTester Platform Technical Support 6 03-05-2007 11:24 AM
Wrong strategy executed BradB Platform Technical Support 1 02-21-2007 03:41 AM


All times are GMT -6. The time now is 03:36 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.