PDA

View Full Version : Indicator not plotting


Burga1
12-06-2007, 10:03 AM
Greetings,

I have an indicator that I coded and I simply want one variable within that indicator to plot on a chart. When applying the indicator to a chart nothing plots at all...I don't understand why. The variable I want to plot is called "VarStok".

In my "Initialize" area I have this code:

Add(new Plot(Color.FromKnownColor(KnownColor.PaleTurquoise ), PlotStyle.Line, "VarStoK"));

In my "OnBarUpdate" area I have this code:

StVarK = SMA(myDataSeries, sl)[0]; Print("Current StVarK = " + StVarK);

myDataSeries3.Set(StVarK);
double VarStoK = SMA(myDataSeries3, D)[0];
myDataSeries4.Set(VarStoK); Print("Current VarStoK = " + VarStoK);

In my "Properties" area I have this code:

#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 VarStoK
{
get { return Values[0]; }
}

Any help appreciated...

ryker
12-06-2007, 01:06 PM
Maybe you could use that before anything in the OnBarUpdate():

if (CurrentBar < periodofyourindicator) return;

?

Burga1
12-06-2007, 01:23 PM
Thank you. But I already have as the first line of code withing "OnBarUpdate" the following:

if(CurrentBar < 20){return;}

ryker
12-06-2007, 01:33 PM
I find your code a bit weird, what are you exactly trying to do here?

From what I can see, you should have at least somewhere in your code something like that:

VarStoK.Set(indicvalues);

Burga1
12-06-2007, 01:47 PM
Thank you for the reply. I didn't post all the code within "OnBarUpdate", only that which applies to that particular variable calculation...can you explain a bit about your suggestion you have written?

ryker
12-06-2007, 01:49 PM
What I suggest is within the code you put, there is nowhere where you asign a value to your indicator VarStoK...
I might miss something here probably...

Burga1
12-06-2007, 01:53 PM
Thanks but does not this line assign a value to the variable?:

double VarStoK = SMA(myDataSeries3, D)[0];

It assigns the result of the simple moving average of "myDataSeries3" for the period of "D" to the variable VarStok...does it not?

ryker
12-06-2007, 01:59 PM
Well after some thoughts, I think you can use:

VarStoK.Set(SMA(SMA(myDataSeries, sl), D)[0]);

instead of your big block.

Burga1
12-06-2007, 02:04 PM
Thank you for your information. You mean I should REPLACE this line:

double VarStoK = SMA(myDataSeries3, D)[0];

With this line (what you wrote):

VarStoK.Set(SMA(myDataSeries3, D)[0]);

If that is correct do I have to add the variable definition into the "Initialize" area (i.e. double VarStok)?

ryker
12-06-2007, 02:09 PM
I mean this big block:

StVarK = SMA(myDataSeries, sl)[0]; Print("Current StVarK = " + StVarK);

myDataSeries3.Set(StVarK);
double VarStoK = SMA(myDataSeries3, D)[0];
myDataSeries4.Set(VarStoK); Print("Current VarStoK = " + VarStoK);
and nothing in initialize.

But, I can be wrong, I have just started using NT and I haven't done any C# for years, just trying to help and understand also how it works :-).

Burga1
12-06-2007, 02:18 PM
Well, I was able to make your suggested changes and that seems to have made a big difference--I now have the indicator plotting...

I thank you immensely for your time and help...you get a star for the day!

Regards

ryker
12-06-2007, 02:26 PM
Great :-).