Composing .NET functions

Questions about MultiCharts .NET and user contributed studies.
Joined:15 Sep 2020
Composing .NET functions

Postby aha » 15 Sep 2020


can't figure out how to do this basic stuff. What I'm trying to do is compose custom function with the standard functions (or other functions).

Below is example just illustrating what I'm trying to. I would expect it to work like this but apparently no. What is the missing step?

Indicator composing custom function with ema

Code: Select all

using System; using System.Drawing; using System.Linq; using PowerLanguage.Function; namespace PowerLanguage.Indicator{ public class Function_Composition_Test : IndicatorObject { public Function_Composition_Test(object _ctx):base(_ctx){} private IPlotObject plot1; private FunctionCompositionTest functionCompositionTest; private XAverage emaOfTest; protected override void Create() { plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red)); functionCompositionTest = new FunctionCompositionTest(this); emaOfTest = new XAverage(functionCompositionTest); } protected override void StartCalc() { emaOfTest.Length = 20; } protected override void CalcBar(){ // indicator logic plot1.Set(emaOfTest[0]); } } }
test function

Code: Select all

using System; using System.Drawing; using System.Linq; namespace PowerLanguage { namespace Function { public sealed class FunctionCompositionTest : FunctionSeries<System.Double> { public FunctionCompositionTest(CStudyControl _master) : base(_master) { } public FunctionCompositionTest(CStudyControl _master, int _ds) : base(_master, _ds) { } private int counter = 0; protected override void Create() { this.counter = 0; } protected override void StartCalc() { } protected override System.Double CalcBar() { this.counter++; return (double) this.counter % 5; } } } }

Return to “MultiCharts .NET”