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

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.

      Brandon H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,404 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      95 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      8 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      159 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X