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 03-08-2010, 01:23 PM   #1
mtthwbrnd
Senior Member
 
Join Date: Dec 2009
Location: London
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default help with indicator basics

Can anybody say why this indicator does not show up in a chart when I add it? A panel appears on the chart, but there is no line in the chart.

thanks,
Matthew.

Code:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

namespace NinjaTrader.Indicator {
    public class R_indicator : Indicator {
        uint timeCounter = 0; 
        DataSeries R;
        protected override void Initialize() {
            R = new DataSeries(this);
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "R"));
        }
        protected override void OnBarUpdate() {
             if (timeCounter > 0) R.Set(Close[0]-Close[1]); else R.Set(0);
             Print(timeCounter + "   " + R[0]);
             timeCounter += 1;
        }
    }
}
mtthwbrnd is offline  
Reply With Quote
Old 03-08-2010, 01:56 PM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,408
Thanks: 252
Thanked 975 times in 958 posts
Default

Please check into this tip here - http://www.ninjatrader-support2.com/...ead.php?t=3170

You likely see an error in the log, as you attempt to access bars not defined at the OnBarUpdate() start...
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 03-08-2010, 02:27 PM   #3
mtthwbrnd
Senior Member
 
Join Date: Dec 2009
Location: London
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Bertrand,

I added:
if (CurrentBar < 1) return;

to the start of OnBarUpdate() but I still have the same problem. Note that my timeCounter variable achieves the same anyhow. There are no errors output to the log.

Any other ideas?

Thanks,
Matthew.
mtthwbrnd is offline  
Reply With Quote
Old 03-08-2010, 04:16 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

Matthew,

You didn't set anything to a plot. You set it to the R DataSeries object which is something you created as a custom DataSeries. You need to set values to the actual plot itself, not a custom DataSeries.
NinjaTrader_Josh 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
NT and IB basics Dickythebrit Connecting 1 07-11-2009 01:27 PM
Back to basics Mindset Indicator Development 2 10-30-2008 09:26 AM


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