![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
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); } |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Please check the Log tab, likely an error on this indicator at runtime.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
I just noticed that in the data window, the Volume field says "InfinityM".
???? |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Then your indicator values are infinite values. You will need to recheck your math.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
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. |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#8 | |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
Quote:
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. |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |