NinjaTrader Support Forum  

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 02-04-2008, 01:24 PM   #1
Tiger75
Junior Member
 
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default Problems with Volume

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
Tiger75 is offline  
Reply With Quote
Old 02-04-2008, 01:52 PM   #2
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

Please post the complete OnBarUpdate method of your indicator.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 02-04-2008, 02:02 PM   #3
Tiger75
Junior Member
 
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default Code Update

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
}
}
Tiger75 is offline  
Reply With Quote
Old 02-04-2008, 04:49 PM   #4
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

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
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-04-2008, 05:14 PM   #5
Tiger75
Junior Member
 
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

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!
Tiger75 is offline  
Reply With Quote
Old 02-04-2008, 10:52 PM   #6
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

Please see here: http://www.ninjatrader-support.com/v...ead.php?t=3170
NinjaTrader_Dierk is offline  
Reply With Quote
Old 02-05-2008, 12:24 PM   #7
Tiger75
Junior Member
 
Join Date: Feb 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Your suggestions worked so thanks alot for the help guys!
Tiger75 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
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


All times are GMT -6. The time now is 06:56 PM.