Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error code CS0426 line 149 Column 63

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

    Error code CS0426 line 149 Column 63

    I started a thread on this indicator for error code but could not post all the code pictures because it exceeded the maximum number of attachments. So I am sending the code in text in this new thread. The error code is
    Click image for larger version

Name:	image.png
Views:	230
Size:	15.3 KB
ID:	1260079​#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 UDIndicator : Indicator
    {
    private int fontSize = 9; // Default setting for FontSize
    private DateTime beginTime, endTime;
    private int UpCounter, DownCounter;
    private int TotalUpCounter, TotalDownCounter;
    private DateTime triggerDate;

    private int DownCycleBar, UpCycleBar;
    private SimpleFont vFont;
    private Brush iVerticalLinesColor = Brushes.Blue;
    private bool SessionEnded = false;

    private Series<double> textValues;

    private SessionIterator sessionIterator;

    region Properties

    region Font Settings

    [XmlIgnore()]
    [Display(Name = "Font Color", Order = 1, GroupName = "Font Settings")]
    public Brush FontColor
    {
    get; set;
    }
    [Browsable(false)]
    public string FontColorSerialize
    {
    get { return Serialize.BrushToString(FontColor); }
    set { FontColor = Serialize.StringToBrush(value); }
    }

    [XmlIgnore()]
    [Display(Name = "Outline Color", Order = 2, GroupName = "Font Settings")]
    public Brush OutLineColor
    {
    get; set;
    }
    [Browsable(false)]
    public string OutLineColorSerialize
    {
    get { return Serialize.BrushToString(OutLineColor); }
    set { OutLineColor = Serialize.StringToBrush(value); }
    }

    [Range(1, Int32.MaxValue)]
    [Display(Name = "Font Size", Order = 3, GroupName = "Font Settings")]
    public int FontSize
    {
    get; set;
    }

    [Display(Name = "ShowTotalsEndofSession", Order = 4, GroupName = "Font Settings")]
    public bool ShowTotalsEndofSession
    {
    get; set;
    }

    [Display(Name = "ShowTotalsEachChange", Order = 5, GroupName = "Font Settings")]
    public bool ShowTotalsEachChange
    {
    get; set;
    }

    [Range(1, Int32.MaxValue)]
    [Display(Name = "Text Shift", Order = 6, GroupName = "Font Settings")]
    public int TextShift
    {
    get; set;
    }

    #endregion

    region Vertical Line Style

    [Display(Name = "Vertical Line Style", Order = 1, GroupName = "Vertical Line Style")]
    public DashStyleHelper VerticalLineStyle
    {
    get; set;
    }

    [Display(Name = "ShowVerticalLines", Order = 2, GroupName = "Vertical Line Style")]
    public bool ShowVerticalLines
    {
    get; set;
    }

    [Display(Name = "VerticalLineWidth", Order = 3, GroupName = "Vertical Line Style")]
    public int VerticalLineWidth
    {
    get; set;
    }

    [XmlIgnore()]
    [Display(Name = "Vertical Lines Color", Order = 4, GroupName = "Vertical Line Style")]
    public Brush VerticalLinesColor
    {
    get; set;
    }
    // Serialize our Color object
    [Browsable(false)]
    public string VerticalLinesColor_Serialize
    {
    get { return Serialize.BrushToString(VerticalLinesColor); }
    set { VerticalLinesColor = Serialize.StringToBrush(value); }
    }



    #endregion

    region Time Parameters

    [Display(Name = "BarsPeriod", Order = 0, GroupName = "Time Parameters")]
    public BarsPeriod BarsPeriodToUse
    {
    get; set;
    }

    [Display(Name = "ResetType", Order = 0, GroupName = "Time Parameters")]
    public NinjaTrader.NinjaScript.Indicators.UDIndicator.Res etType MyResetType
    {
    get; set;
    }

    [Display(Name = "UseTimeRange", Order = 1, GroupName = "Time Parameters")]
    public bool UseTimeRange
    {
    get; set;
    }

    private string tradingStartTime = @"16:00:01";
    private string tradingStopTime = @"16:00:00";
    [Display(Name = "Begin Time", Order = 2, GroupName = "Time Parameters")]
    public string BeginTime
    {
    get { return tradingStartTime; }
    set { tradingStartTime = value; }
    }

    [Display(Name = "End Time", Order = 3, GroupName = "Time Parameters")]
    public string EndTime
    {
    get { return tradingStopTime; }
    set { tradingStopTime = value; }
    }

    #endregion

    [Display(Name = "MinimumVolumeThreshold", Order = 20, GroupName = "Parameters")]
    public int MinimumVolumeThreshold
    {
    get; set;
    }

    [Display(Name = "ShowAbbreviatedFormat", Order = 21, GroupName = "Parameters")]
    public bool ShowAbbreviatedFormat
    {
    get; set;
    }

    #endregion

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"";
    Name = "UDIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = true;

    FontColor = Brushes.Blue;
    FontSize = 12;
    TextShift = 10;

    BarsPeriodToUse = new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 1 };
    MyResetType = ResetType.Daily;
    MinimumVolumeThreshold = 2000;
    UseTimeRange = false;

    VerticalLineStyle = DashStyleHelper.Solid;
    VerticalLineWidth = 2;
    VerticalLinesColor = Brushes.Blue;

    OutLineColor = Brushes.Transparent;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodToUse);
    }
    else if (State == State.DataLoaded)
    {
    sessionIterator = new SessionIterator(BarsArray[1]);

    DateTime.TryParse(tradingStartTime, out beginTime);
    DateTime.TryParse(tradingStopTime, out endTime);

    vFont = new SimpleFont("Arial", FontSize);

    textValues = new Series<double>(this, MaximumBarsLookBack.Infinite);
    }
    }

    protected override void OnBarUpdate()
    {
    for (int x = 0; x < BarsArray.Length; x++)
    if (CurrentBars[x] < 1)
    return;

    if (BarsInProgress == 1)
    {
    int index = BarsInProgress;

    if (UseTimeRange && sessionIterator.IsInSession(BarsArray[index].GetTime(CurrentBar)))
    {
    if (MyResetType == ResetType.Daily && BarsInProgress == 1 && CurrentBar > 0)
    {
    if (BarsArray[1].IsFirstBarOfSession)
    {
    if (TotalUpCounter != 0 || TotalDownCounter != 0)
    {
    ShowTotalsEndofSession = true;
    SessionEnded = true;
    }
    else
    SessionEnded = false;
    }
    else
    {
    SessionEnded = false;
    }
    }

    if (CurrentBar == 0)
    {
    triggerDate = BarsArray[index].GetTime(CurrentBar);
    if (beginTime <= triggerDate && triggerDate <= endTime)
    {
    Draw.Line(this, "SessionStartTimeLine", false, triggerDate, High[0] + TickSize, triggerDate, Low[0] - TickSize, VerticalLinesColor, VerticalLineStyle, VerticalLineWidth);
    }
    }
    else if (CurrentBar == BarsArray[index].Count - 1)
    {
    triggerDate = BarsArray[index].GetTime(CurrentBar);
    if (beginTime <= triggerDate && triggerDate <= endTime)
    {
    Draw.Line(this, "SessionEndTimeLine", false, triggerDate, High[0] + TickSize, triggerDate, Low[0] - TickSize, VerticalLinesColor, VerticalLineStyle, VerticalLineWidth);
    }
    }
    else
    {
    triggerDate = BarsArray[index].GetTime(CurrentBar);
    if (beginTime <= triggerDate && triggerDate <= endTime)
    {
    Draw.Line(this, "SessionLine", false, triggerDate, High[0] + TickSize, triggerDate, Low[0] - TickSize, VerticalLinesColor, VerticalLineStyle, VerticalLineWidth);
    }
    }
    }


    #2
    // Existing code...

    // New code for additional output format
    if (ShowTotalsEachChange && ShowAbbreviatedFormat)
    {
    if (Close[0] > High[1] && Volume[0] > MinimumVolumeThreshold)
    {
    DownCounter = 0;
    UpCounter++;
    TotalUpCounter++;

    if (UpCounter == 1)
    UpCycleBar = CurrentBar;

    string upCounterText = UpCounter == 1 ? "U" : UpCounter.ToString();
    Draw.Text(this, "UpCounter" + UpCycleBar, true, upCounterText, 0, High[0], TextShift, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);

    if (TotalUpCounter - TotalDownCounter > 0)
    {
    Draw.Text(this, "TotalDifference" + UpCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, High[0], TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.LawnGreen, 50);
    Draw.Text(this, "TotalUpCounter" + UpCycleBar, true, TotalUpCounter.ToString(), 0, High[0], TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalDownCounter" + UpCycleBar, true, TotalDownCounter.ToString(), 0, High[0], TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }
    else if (TotalUpCounter - TotalDownCounter < 0)
    {
    Draw.Text(this, "TotalDifference" + UpCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, High[0], TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.PeachPuff, 50);
    Draw.Text(this, "TotalDownCounter" + UpCycleBar, true, TotalDownCounter.ToString(), 0, High[0], TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalUpCounter" + UpCycleBar, true, TotalUpCounter.ToString(), 0, High[0], TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }
    else
    {
    Draw.Text(this, "TotalDifference" + UpCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, High[0], TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.Gray, 50);
    Draw.Text(this, "TotalUpCounter" + UpCycleBar, true, TotalUpCounter.ToString(), 0, High[0], TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalDownCounter" + UpCycleBar, true, TotalDownCounter.ToString(), 0, High[0], TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }

    textValues[0] = 1;
    }

    if (Close[0] < Low[1] && Volume[0] > MinimumVolumeThreshold)
    {
    UpCounter = 0;
    DownCounter++;
    TotalDownCounter++;

    if (DownCounter == 1)
    DownCycleBar = CurrentBar;

    string downCounterText = DownCounter == 1 ? "D" : DownCounter.ToString();
    Draw.Text(this, "DownCounter" + DownCycleBar, true, downCounterText, 0, Low[0], -TextShift, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);

    if (TotalUpCounter - TotalDownCounter > 0)
    {
    Draw.Text(this, "TotalDifference" + DownCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, Low[0], -TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.LawnGreen, 50);
    Draw.Text(this, "TotalDownCounter" + DownCycleBar, true, TotalDownCounter.ToString(), 0, Low[0], -TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalUpCounter" + DownCycleBar, true, TotalUpCounter.ToString(), 0, Low[0], -TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }
    else if (TotalUpCounter - TotalDownCounter < 0)
    {
    Draw.Text(this, "TotalDifference" + DownCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, Low[0], -TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.PeachPuff, 50);
    Draw.Text(this, "TotalDownCounter" + DownCycleBar, true, TotalDownCounter.ToString(), 0, Low[0], -TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalUpCounter" + DownCycleBar, true, TotalUpCounter.ToString(), 0, Low[0], -TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }
    else
    {
    Draw.Text(this, "TotalDifference" + DownCycleBar, true, (TotalUpCounter - TotalDownCounter).ToString(), 0, Low[0], -TextShift * 2, FontColor, vFont, TextAlignment.Center, OutLineColor, Brushes.Gray, 50);
    Draw.Text(this, "TotalDownCounter" + DownCycleBar, true, TotalDownCounter.ToString(), 0, Low[0], -TextShift * 4, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    Draw.Text(this, "TotalUpCounter" + DownCycleBar, true, TotalUpCounter.ToString(), 0, Low[0], -TextShift * 6, FontColor, vFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 100);
    }

    textValues[0] = -1;
    }
    }
    }
    else
    {
    // Existing code...
    }
    }

    region Miscellaneous
    public override string ToString()
    {
    return Name;
    }
    public override string DisplayName
    {
    get
    {
    return Name;
    }
    }
    #endregion
    }

    region Misc

    public class DashStyleHelper
    {
    public static DashStyleHelper Solid = new DashStyleHelper("Solid");
    public static DashStyleHelper Dash = new DashStyleHelper("Dash");
    public static DashStyleHelper Dot = new DashStyleHelper("Dot");
    public static DashStyleHelper DashDot = new DashStyleHelper("DashDot");
    public static DashStyleHelper DashDotDot = new DashStyleHelper("DashDotDot");
    private readonly string dashStyle;

    private DashStyleHelper(string dashStyle)
    {
    this.dashStyle = dashStyle;
    }

    public override string ToString()
    {
    return dashStyle;
    }
    }

    public enum ResetType
    {
    Daily,
    Weekly,
    Monthly
    }

    #endregion
    }


    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private UDIndicator[] cacheUDIndicator;
    public UDIndicator UDIndicator()
    {
    return UDIndicator(Input);
    }

    public UDIndicator UDIndicator(ISeries<double> input)
    {
    if (cacheUDIndicator != null)
    for (int idx = 0; idx < cacheUDIndicator.Length; idx++)
    if (cacheUDIndicator[idx] != null && cacheUDIndicator[idx].EqualsInput(input))
    return cacheUDIndicator[idx];
    return CacheIndicator<UDIndicator>(new UDIndicator(), input, ref cacheUDIndicator);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.UDIndicator UDIndicator()
    {
    return indicator.UDIndicator(Input);
    }

    public Indicators.UDIndicator UDIndicator(ISeries<double> input )
    {
    return indicator.UDIndicator(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.UDIndicator UDIndicator()
    {
    return indicator.UDIndicator(Input);
    }

    public Indicators.UDIndicator UDIndicator(ISeries<double> input )
    {
    return indicator.UDIndicator(input);
    }
    }
    }

    #endregion
    ​​

    Comment


      #3
      Hello james79,

      Thanks for your notes.

      I see you are trying to create a user-defined enum parameter.

      The enum should be created in a custom namespace and you would need to use the fully qualified namespace when creating the user-defined parameter.

      Please see this reference sample demonstrating how to create a user-defined enum parameter: https://ninjatrader.com/support/help...ned_parame.htm

      You could compare this reference sample to your script to see where there are differences.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X