Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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 ETFVoyageur, 05-07-2024, 07:05 PM
      10 responses
      71 views
      0 likes
      Last Post ETFVoyageur  
      Started by Zeezee, Today, 12:45 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by ldanenberg, Today, 03:19 PM
      0 responses
      2 views
      0 likes
      Last Post ldanenberg  
      Started by TheTradingMantis, 01-19-2023, 02:05 AM
      42 responses
      914 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by _Zero_, 04-10-2020, 03:21 PM
      144 responses
      7,896 views
      6 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X