Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IEnumerable not compiling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    IEnumerable not compiling

    I'm trying to create anchors (first time). I used the helpGuide example as a basic template, but when I compile, I get "... no suitable method found to override" on the line public override IEnumerable<ChartAnchor> Anchors. The helpGuide clearly states that "override" is required. When I remove "override", it compiles fine.

    Do I really need it "override" directive or and I doing something else wrong?.

    Thanks for your help.


    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class LogrithmicTrend : Indicator
    {
    public ChartAnchor Anchor1 { get; set; }
    public ChartAnchor Anchor2 { get; set; }
    public ChartAnchor Anchor3 { get; set; }
    
    // Create the Anchor Collection
    public override IEnumerable<ChartAnchor> Anchors
    {
    get
    {
    return new[] {Anchor1, Anchor2, Anchor3};
    }
    }
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Attempt to build a logrithmic trend indicator";
    Name = "LogrithmicTrend";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    Anchor1 = new ChartAnchor();
    Anchor2 = new ChartAnchor();
    Anchor3 = new ChartAnchor();
    Anchor1.DisplayName = "First Marker";
    Anchor2.DisplayName = "Second Marker";
    Anchor3.DisplayName = "Last Marker";
    Anchor1.IsBrowsable = false;
    Anchor2.IsBrowsable = false;
    Anchor3.IsBrowsable = false;
    IsSuspendedWhileInactive = true;
    CurveColor = Brushes.Gold;
    AddPlot(Brushes.Orange, "CurveLine1");
    }
    else if (State == State.Configure)
    {
    }
    }
    
    protected override void OnRender (ChartControl chartControl, ChartScale chartScale)
    {
    foreach (ChartAnchor anchor in Anchors)
    {
    Print (anchor.DisplayName);
    }
    }
    
    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    }
    
    #region Properties
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="CurveColor", Description="Curve Color", Order=1, GroupName="Parameters")]
    public Brush CurveColor
    { get; set; }
    
    [Browsable(false)]
    public string CurveColorSerializable
    {
    get { return Serialize.BrushToString(CurveColor); }
    set { CurveColor = Serialize.StringToBrush(value); }
    }
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> CurveLine1
    {
    get { return Values[0]; }
    }
    #endregion
    }

    #2
    Hello TheBean236,

    The override you are trying to use is for a DrawingTool but it looks like you are using an indicator which would not have that override.

    Are you trying to make a collection of anchors that your indicator can use to store other anchors? What is your end goal?

    The override specifically would only be used for a drawing object and is how it stores its anchor collection.

    I look forward to being of further assistance.

    Comment


      #3
      I understand. Thanks. I tried it under DrawingTools and it compiles fine.
      I'll do my initial development there.

      Thanks again,
      Michael

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      606 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      351 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X