![]() |
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 2009
Location: London
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
|
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;
}
}
}
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,408
Thanks: 252
Thanked 975 times in 958 posts
|
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...
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2009
Location: London
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |