Custom indicators access
Instantiate a custom indicator with input parameters.
General
public class CustomIndicator : Indicator{ [InputParameter("Level", 10, 0.1, 9999, 0.1, 1)] public double LevelValue = 10; [InputParameter("Slow period", 20, 1, 9999, 1, 0)] public int SlowPeriod = 30; [InputParameter("Price type", variants: new object[] { "Close", PriceType.Close, "Open", PriceType.Open, "High", PriceType.High, "Low", PriceType.Low, })] public PriceType PriceType = PriceType.Close; [InputParameter("Period")] public Period Period = Period.MIN1; public CustomIndicator() { this.Name = "Custom indicator"; this.AddLineSeries("Line", Color.DodgerBlue, 2, LineStyle.Solid); this.SeparateWindow = true; } protected override void OnUpdate(UpdateArgs args) { }}Use class constructor (Beginner)
public class CustomIndicator : Indicator{ public CustomIndicator() { this.Name = "Custom indicator"; this.AddLineSeries("Line", Color.DodgerBlue, 2, LineStyle.Solid); this.SeparateWindow = true; } public CustomIndicator(double levelValue, int slowPeriod, PriceType priceType, Period period) : this() { this.LevelValue = levelValue; this.SlowPeriod = slowPeriod; this.PriceType = priceType; this.Period = period; }}class BestIndicator : Indicator{ private Indicator customIndicator; protected override void OnInit() { this.customIndicator = new CustomIndicator(10, 500, PriceType.High, Period.DAY1); this.AddIndicator(this.customIndicator); } protected override void OnUpdate() { var indicatorValue = this.customIndicator.GetValue(); }}Use indicator settings collection (Advance)
class BestIndicator : Indicator{ private Indicator customIndicator; protected override void OnInit() { var customIndicator = new CustomIndicator(); var settings = customIndicator.Settings; try { settings.UpdateItemValue("Level", 12.5); settings.UpdateItemValue("Slow period", 55); settings.UpdateItemValue("Price type", new SelectItem("Open", PriceType.Open)); settings.UpdateItemValue("Period", Period.MONTH1); this.AddIndicator(this.customIndicator); } catch (Exception ex) { } indicator.Settings = settings; } protected override void OnUpdate() { var indicatorValue = customIndicator.GetValue(); }}Last updated
Was this helpful?