Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CS0103 error

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

    CS0103 error

    Hello,

    I'm trying to draw a rectangle around a 5 minute bar if it meets certain criteria; however, I keep getting a CS0103 error around the term "Brushes".

    Code:
    using System;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Data;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Gui;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class DNDrawRectangle : Indicator
        {
            private double range;
            private double level40;
            private double level60;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description = @"Draws a yellow box around bars on a 5-minute chart if certain conditions are met.";
                    Name = "DNDrawRectangle";
                    Calculate = Calculate.OnEachTick;
                    IsOverlay = true;
                }
            }
    
            protected override void OnBarUpdate()
            {
                // Only execute on a 5-minute chart
                if (BarsPeriod.BarsPeriodType != BarsPeriodType.Minute || BarsPeriod.Value != 5)
                    return;
    
                // Calculate the range of the current bar
                range = High[0] - Low[0];
    
                // Calculate 40% and 60% levels
                level40 = Low[0] + (range * 0.4);
                level60 = Low[0] + (range * 0.6);
    
                // Check the condition for "Bull Close 1"
                if (Open[0] < level40 && Close[0] > Open[0] && Close[0] <= level60)
                {
                    // Draw a yellow box around the bar
                    Draw.Rectangle(this, "BullClose1", false, 0, High[0], 1, Low[0], Brushes.Yellow, Brushes.Transparent, 2);
                }
            }
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private DNDrawRectangle[] cacheDNDrawRectangle;
            public DNDrawRectangle DNDrawRectangle()
            {
                return DNDrawRectangle(Input);
            }
    
            public DNDrawRectangle DNDrawRectangle(ISeries<double> input)
            {
                if (cacheDNDrawRectangle != null)
                    for (int idx = 0; idx < cacheDNDrawRectangle.Length; idx++)
                        if (cacheDNDrawRectangle[idx] != null &&  cacheDNDrawRectangle[idx].EqualsInput(input))
                            return cacheDNDrawRectangle[idx];
                return CacheIndicator<DNDrawRectangle>(new DNDrawRectangle(), input, ref cacheDNDrawRectangle);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.DNDrawRectangle DNDrawRectangle()
            {
                return indicator.DNDrawRectangle(Input);
            }
    
            public Indicators.DNDrawRectangle DNDrawRectangle(ISeries<double> input )
            {
                return indicator.DNDrawRectangle(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.DNDrawRectangle DNDrawRectangle()
            {
                return indicator.DNDrawRectangle(Input);
            }
    
            public Indicators.DNDrawRectangle DNDrawRectangle(ISeries<double> input )
            {
                return indicator.DNDrawRectangle(input);
            }
        }
    }
    
    #endregion
    ​
    thanks in advance for the help.,

    #2
    Hello DooberXL,

    It appears the using statements have been modified.

    Please try creating a new script, then copy the using statements at the top of the new script over to your script so these are replaced by the default using statements.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    116 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    61 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    40 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    43 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    82 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X