PDA

View Full Version : indicator not plotting


bluejay
12-01-2008, 11:32 AM
Hi

new to NJ programming, finding it a bit tricky. One example, this following text inside an inidicator compiles OK but the indicator will not plotanything.
Any hints about a possible solution ?
Thanks in advance
Chris

BarsRequired=50;

calculclose[0]=facteurclose*(Close[0]-Close[1]);
data=SMA(calculclose,period)[0];
Plot0.Set(data);

NinjaTrader_Bertrand
12-01-2008, 12:09 PM
Hi bluejay,

Thanks for posting.

Please check out this link - http://www.ninjatrader-support2.com/vb/showthread.php?t=3170

Then add this check to the start of your OnBarUpdate() code section -


if (CurrentBar < Period)
return;

roonius
12-01-2008, 12:10 PM
Try:
BarsRequired=50;
if (CurrentBar<BarsRequired) return;
calculclose[0]=facteurclose*(Close[0]-Close[1]);
data=SMA(calculclose,period)[0];
Plot0.Set(data);

Hi

new to NJ programming, finding it a bit tricky. One example, this following text inside an inidicator compiles OK but the indicator will not plotanything.
Any hints about a possible solution ?
Thanks in advance
Chris

BarsRequired=50;

calculclose[0]=facteurclose*(Close[0]-Close[1]);
data=SMA(calculclose,period)[0];
Plot0.Set(data);

bluejay
12-03-2008, 11:08 AM
Thanks for the input, still doesnt plot anything ! |:((

Chris

NinjaTrader_Bertrand
12-03-2008, 11:21 AM
Hi bluejay,

Then please post the code here, so we can take a look and advise...

Thanks!

bluejay
12-03-2008, 11:43 AM
here is the code in total
the problem occurs as soon as I start using Close[1], ie anything different from Close[0]

thx in advance
Chriss


///</summary>
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "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.

BarsRequired=50;
if (CurrentBar < Period)
return;

calculclose[0]=facteurclose*(Close[0]-Close[1]);
data=SMA(calculclose,period)[0];
Plot0.Set(data);

}
#region Properties

roonius
12-03-2008, 12:01 PM
Period is not the same as period (Case sensitive)

And it is not complete code, show your variables too...

TAJTrades
12-03-2008, 12:02 PM
if "calculclose" is supposed to be a data series then the dataSeries has not been defined. Do a Help search on DataSeries and I believe all the info is there to get you going.

bluejay
12-03-2008, 12:08 PM
here are the variables . I cannot post all the lines at once, the NT forum tells me it exceeds 10000 characters !

Thx

[Description("Enter the description of your new custom indicator here")]
publicclass Bullbearclose : Indicator
{
#region Variables
// Wizard generated variables
privateint period = 20; // Default setting for Period
privatedouble facteurclose = 1; // Default setting for Facteurclose
privatedouble diff ;
private DataSeries calculclose;
privatedouble data;
// User defined variables (add any user defined variables below)
#endregion

roonius
12-03-2008, 12:10 PM
you are missing the following line in Initialize section:

calculclose = new DataSeries(this);

NinjaTrader_Bertrand
12-03-2008, 12:10 PM
Hi bluejay,

Please add this to the Variables section of your code -


new DataSeries calculclose;


then this to the Initialize section:


calculclose = new DataSeries(this);


Finally change your code in the OnBarUpdate -

BarsRequired=50;
if (CurrentBar < Period)
return;

calculclose.Set(facteurclose * (Close[0] - Close[1]));
data = SMA(calculclose, Period)[0];
Plot0.Set(data);


Also please review this link - http://www.ninjatrader-support2.com/vb/showthread.php?t=7299 (http://www.ninjatrader-support2.com/vb/showthread.php?t=7299)

TAJTrades
12-03-2008, 12:12 PM
You must finish defining the data Series with a line of code in the

protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;

ANOTHER LINE OF CODE FOR THE DATA SERIES GOES HERE;
}

I do not recall the exact syntax but it is in the Help Files

bluejay
12-03-2008, 12:27 PM
YES !! Working !

thanks to all for the input, seems simple when you have the answer, but this is learning I guess !!

Chris