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 |
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
Comment