I'm just getting started with MultiCharts .Net. C# is already driving me up the wall. Be that as it may, the following code is a simple strategy that utilizes the crossover of two exponential moving averages. I think I got the codes down correct but it won't compile. Both the code and the error message is pasted below. Any pointer would be much appreciated.
Code:
using System;
using PowerLanguage.Function;
namespace PowerLanguage.Strategy
{
public class xMaxOver : SignalObject
{
private XAverage FastAverage;
private XAverage SlowAverage;
private VariableSeries<Double> FastAvg;
private VariableSeries<Double> SlowAvg;
private IOrderMarket EMA_Cross;
public xMaxOver(object _ctx) :base(_ctx)
{
SlowLength = 18;
FastLength = 9;
}
private ISeries<double> Price { get; set; }
[Input]
public int FastLength { get; set; }
[Input]
public int SlowLength { get; set; }
protected override void Create(){
FastAverage = new XAverage(this);
SlowAverage = new XAverage(this);
FastAvg = new VariableSeries<Double>(this);
SlowAvg = new VariableSeries<Double>(this);
EMA_Cross =
OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "Long", EOrderAction.Buy));
}
protected override void StartCalc(){
Price = Bars.Close;
//next 4 lines are error-prone
FastAverage.price = Price;
FastAverage.length = FastLength;
SlowAverage.price = Price;
SlowAverage.length = SlowLength;
}
protected override void CalcBar(){
FastAvg.Value = FastAverage[0];
SlowAvg.Value = SlowAverage[0];
if (Bars.CurrentBar > 1 && FastAvg.CrossesOver(SlowAvg, ExecInfo.MaxBarsBack))
{
EMA_Cross.Send();
}
}
}
}
'PowerLanguage.Function.XAverage' does not contain a definition for 'price' and no extension method 'price' accepting a first argument of type 'PowerLanguage.Function.XAverage' could be found (are you missing a using directive or an assembly reference?) "xMaxOver" [Strategy] Ln 43
'PowerLanguage.Function.XAverage' does not contain a definition for 'length' and no extension method 'length' accepting a first argument of type 'PowerLanguage.Function.XAverage' could be found (are you missing a using directive or an assembly reference?) "xMaxOver" [Strategy] Ln 44
'PowerLanguage.Function.XAverage' does not contain a definition for 'price' and no extension method 'price' accepting a first argument of type 'PowerLanguage.Function.XAverage' could be found (are you missing a using directive or an assembly reference?) "xMaxOver" [Strategy] Ln 45
'PowerLanguage.Function.XAverage' does not contain a definition for 'length' and no extension method 'length' accepting a first argument of type 'PowerLanguage.Function.XAverage' could be found (are you missing a using directive or an assembly reference?) "xMaxOver" [Strategy] Ln 46
