Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error code CS0103: The name 'Draw' does not exist in the current context

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

    Error code CS0103: The name 'Draw' does not exist in the current context

    Hello team,

    I am trying to create my first indicator. During compilation I get the error below:
    CandlePatternDetector.cs The name 'Draw' does not exist in the current context CS0103 48 17
    Here is my code below. Would you please check and assist to fix it :

    region Using declarations

    using System;

    using NinjaTrader.NinjaScript.Strategies;

    using NinjaTrader.NinjaScript.Indicators;

    using System.Windows.Media; // Added for Brushes




    #endregion




    // Ensure the namespace matches your project's structure

    namespace NinjaTrader.NinjaScript.Indicators

    {

    public class CandlePatternDetector : Indicator

    {

    protected override void OnStateChange()

    {

    if (State == State.SetDefaults)

    {

    Description = @"Detects specified candle patterns in various time frames.";

    Name = "CandlePatternDetector";

    Calculate = Calculate.OnBarClose;

    IsOverlay = true;

    DisplayInDataBox = true;

    DrawOnPricePanel = true;

    DrawHorizontalGridLines = true;

    DrawVerticalGridLines = true;

    PaintPriceMarkers = true;

    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;

    IsSuspendedWhileInactive = true;

    }

    }




    protected override void OnBarUpdate()

    {

    // Ensure we have enough bars for the pattern detection

    if (CurrentBar < 1) return;




    // Example: Detecting a specific candle pattern

    double body = Math.Abs(Close[0] - Open[0]);

    double upperWick = High[0] - Math.Max(Open[0], Close[0]);

    double lowerWick = Math.Min(Open[0], Close[0]) - Low[0];




    double bodyThreshold = TickSize * 5;

    double wickThreshold = TickSize * 10;




    if (body <= bodyThreshold && upperWick >= wickThreshold && lowerWick <= bodyThreshold)

    {

    // Ensure to call the Draw method correctly

    Draw.Dot(this, "upperWickSignal" + CurrentBar, false, 0, High[0] + 2 * TickSize, Brushes.DodgerBlue);

    }

    }

    }

    }



    #endregion

    Thanks​

    #2
    Welcome to the forums!

    Try adding this,

    using NinjaTrader.NinjaScript.DrawingTools;

    to the top of your script.

    Comment


      #3
      Hello ma10trader,

      Thanks for your post and welcome to the Forums!

      You could be missing the using statement from your script which could cause this error.

      As bltdavid noted, please add using NinjaTrader.NinjaScript.DrawingTools; to the 'Using declarations' section of your script and then run a compile to check if the error persists.

      Please let us know if this does not resolve the error.

      <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


        #4
        Hola buenos días, estoy creando mi primera estrategia pero me sale Un error CS01013 Que dice lo siguiente el nombre UnrielizedProfit no existe en el contexto actual y en las declaraciones esta NinjaTrader.NinjaScript.DrawingTools; no se como resolver este problema es el único error que tiene, por favor pueden ayudarme a resolverlo

        Comment


          #5
          Disculpen el error es el CS0103

          Comment


            #6
            Originally posted by rosselyn View Post
            Disculpen el error es el CS0103
            Intente eliminar este "usando NinjaTrader.NinjaScript.Strategies;" en la sección superior del código (Usando).​

            Try removing this " using NinjaTrader.NinjaScript.Strategies;" in the top section of the code(Using).

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            602 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            559 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X