Questions about MultiCharts .NET and user contributed studies.
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times


Postby shivax » 16 Jul 2014

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator{
public class variable_sample : IndicatorObject {
public variable_sample(object _ctx):base(_ctx){}

private IPlotObject plot1, plot2;
private AverageFC f_avg;

VariableObject <double> simple_var;
VariableSeries <double> series_var;

public int length { get; set; }

protected override void Create() {
plot1 = AddPlot(new PlotAttributes("1", EPlotShapes.Line, Color.Red));
plot2 = AddPlot(new PlotAttributes("2", EPlotShapes.Line, Color.Yellow));

f_avg = new Function.AverageFC(this);

simple_var = new VariableObject<double>(this);
series_var = new VariableSeries<double>(this);

protected override void StartCalc() {
f_avg.length = length;
f_avg.price = Bars.Close;

protected override void CalcBar() {
simple_var.Value = series_var.Value = f_avg[0];
plot1.Set(simple_var [0] - simple_var[1]);
plot2.Set(series_var[0] - series_var[1]);

When i compile it..i don't see error....But...i can't put in my graph..said me there is error....
Immagine111.png (150.97 KiB) Viewed 303 times

User avatar
Henry MultiСharts
Posts: 9040
Joined: 25 Aug 2011
Has thanked: 1247 times
Been thanked: 2898 times

Re: Compile

Postby Henry MultiСharts » 16 Jul 2014

Hello shivax,

The name of the study should match the name in the code.
These two lines:

Code: Select all

public class variable_sample : IndicatorObject {
public variable_sample(object _ctx):base(_ctx){}

must be changed to:

Code: Select all

public class Prova2 : IndicatorObject {
public Prova2(object _ctx):base(_ctx){}
These users thanked the author Henry MultiСharts for the post:

Return to “MultiCharts .NET”