// This indicator highlights candles that have less volume than the previous candle but are larger in size
// than a specified minimum threshold
region Using declarations
using System.ComponentModel;
using System.Windows.Media;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.Indicators;
#endregion
namespace NinjaTrader.NinjaScript.Indicators
{
[Description("Highlights candles with less volume than the previous candle but are larger in size than a specified threshold.")]
public class LessVolumeLargerCandle : Indicator
{
private int _threshold = 100;
private Brush _bullishBrush = Brushes.Cyan;
private Brush _bearishBrush = Brushes.Magenta;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Highlights candles with less volume than the previous candle but are larger in size than a specified threshold.";
Name = "LessVolumeLargerCandle";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
PaintPriceMarkers = true;
AddPlot(Brushes.Transparent, "LessVolumeLargerCandle");
AddDataSeries(Data.BarsPeriodType.Minute, 1);
}
else if (State == State.Configure)
{
BarsArray[1].LoadHistoricalBars = true;
ClearOutputWindow();
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0 || CurrentBars[0] < 2)
return;
int priorBar = CurrentBar - 1;
// Check for bullish setup
if (Close[priorBar] < Open[priorBar] &&
Open[0] < Close[0] &&
Volume[0] < Volume[priorBar] &&
(Close[0] - Open[0]) >= _threshold)
{
Draw.Dot(this, "BullishDot" + CurrentBar, true, 0, High[0] + TickSize, _bullishBrush);
}
// Check for bearish setup
if (Close[priorBar] > Open[priorBar] &&
Open[0] > Close[0] &&
Volume[0] < Volume[priorBar] &&
(Open[0] - Close[0]) >= _threshold)
{
Draw.Dot(this, "BearishDot" + CurrentBar, true, 0, Low[0] - TickSize, _bearishBrush);
}
}
region Properties
[Description("The minimum size of the candle that triggers the highlight.")]
[Category("Parameters")]
[DisplayName("Threshold")]
public int Threshold
{
get { return _threshold; }
set { _threshold = Math.Max(value, 0); }
}
[XmlIgnore]
[Browsable(false)]
public Brush BullishBrush
{
get { return _bullishBrush; }
set { _bullishBrush = value; }
}
[XmlIgnore]
[Browsable(false)]
public Brush BearishBrush
{
get { return _bearishBrush; }
set { _bearishBrush = value; }
}
#endregion
}
}
region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private LessVolumeLargerCandle[] cacheLessVolumeLargerCandle;
public LessVolumeLargerCandle LessVolumeLargerCandle()
{
return LessVolumeLargerCandle(Input);
}
public LessVolumeLargerCandle LessVolumeLargerCandle(ISeries<double> input)
{
if (cacheLessVolumeLargerCandle != null)
for (int idx = 0; idx < cacheLessVolumeLargerCandle.Length; idx++)
if (cacheLessVolumeLargerCandle[idx] != null && cacheLessVolumeLargerCandle[idx].EqualsInput(input))
return cacheLessVolumeLargerCandle[idx];
return CacheIndicator<LessVolumeLargerCandle>(new LessVolumeLargerCandle(), input, ref cacheLessVolumeLargerCandle);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.LessVolumeLargerCandle LessVolumeLargerCandle()
{
return indicator.LessVolumeLargerCandle(Input);
}
public Indicators.LessVolumeLargerCandle LessVolumeLargerCandle(ISeries<double> input )
{
return indicator.LessVolumeLargerCandle(input);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.LessVolumeLargerCandle LessVolumeLargerCandle()
{
return indicator.LessVolumeLargerCandle(Input);
}
public Indicators.LessVolumeLargerCandle LessVolumeLargerCandle(ISeries<double> input )
{
return indicator.LessVolumeLargerCandle(input);
}
}
}
#endregion
I am not too sure about Ninja Script so if anyones knows where I can get this reviewed and edited so i can compile it that would be greatly appreciated

Comment