![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
I'm trying to create a custom indicator for use with the Market Analyzer. I'm simply trying to have the cell display 1 or 0 depending if the volume of the current bar is greater than the prior bar or not. I've tried the following script: Plot0.Set(Volume[0] > Volume[1] ? 1 : 0); But all that happens in the Market Analyzer window is that the cell shows the Last Price which is making no sense to me at all. Any suggestions welcome! Thanks |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Please post the complete OnBarUpdate method of your indicator.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
I'm really at a loss with this one as I'm getting the same error with price bar data as well now (eg High function) so I'm thinking it must be in the setup so I've included the whole lot for you.
I have only been using Ninja for a week so a fundamental stuffup on my part is definately on the books. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { ///<summary> /// Enter the description of your new custom indicator here ///</summary> [Description("Enter the description of your new custom indicator here")] [Gui.Design.DisplayName("VTest1")] publicclass VTest1 : Indicator { #region Variables // Wizard generated variables // User defined variables (add any user defined variables below) #endregion ///<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.Bar, "Plot0")); CalculateOnBarClose = true; 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. Plot0.Set(Volume[0] > Volume[1] ? 1 : 0); } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries Plot0 { get { return Values[0]; } } #endregion } } |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Hi Tiger75,
Please check the Control Center log tab for errors. I suspect your indicator would have generated an error along the lines of unaccessible data series. Please see this tip: http://www.ninjatrader-support.com/v...ead.php?t=3170
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Josh,
The error in the control centre log is "Error on calling the 'OnBarUpdate' method for indicator 'VTest1' on bar 0:Index was out of range. Must be non-negative and less than the size of the collection". I'll give the suggested solutions a go and report back. Thanks again for the help its greatly appreciated! |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Please see here: http://www.ninjatrader-support.com/v...ead.php?t=3170
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Your suggestions worked so thanks alot for the help guys!
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bid/Ask Volume combined with Hist Volume | monpere | NinjaScript File Sharing Discussion | 12 | 10-04-2011 02:25 PM |
| multicolor volume bars and volume bar projections... possible or not? | Pr0crast | Charting | 8 | 12-25-2007 06:36 PM |
| Problems testing for zero volume on range charts | zoltran | General Programming | 14 | 12-04-2007 12:59 PM |
| installing problems | jnjane | Installation and Licensing | 2 | 08-19-2007 09:35 PM |
| Installation problems | jonesr227 | Installation and Licensing | 5 | 08-09-2007 03:10 AM |