Miami Lakes
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3
|
I see TradingView had this indicator I'd like to use in Multicharts, it is called BBW and this is the code:
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50)
basis = sma(src, length) //This seems to be the line I am having problems with
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
plot(bbw, color=blue)
This is what I am trying to build in Multicharts .NET:
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator{
public class BBW : IndicatorObject {
public BBW(object _ctx):base(_ctx){
std = 2;
length = 20;
}
private IPlotObject plot1;
[Input]
private int std { get;set; }
[Input]
private int length { get;set; }
protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){
// indicator logic
var basis = AverageFC(Bars.CloseValue,length);
var dev = std * Bars.Close.StandardDeviationCustom(length,1);
plot1.Set( ( (basis+dev) - (basis-dev) )/basis );
}
}
}
When compiling it returns this error:
'PowerLanguage.Function.AverageFC' is a 'type' but is used like a 'variable' "BBW" [Indicator] Ln 31.
which comes from the line:
var basis = AverageFC(Bars.CloseValue,length);
What would be the right way to assign this variable "basis" its value please? The value should be the simple moving average over the last "length" close values.
As always any help is really appreciated, thank you.
|