#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion namespace NinjaTrader.NinjaScript.Indicators { public class AresPriceBreakout : Indicator { private double volumeMultiplier = 1.500; // Default setting for VolumeMultiplier private string upwardBreakout = "YES"; // Default setting for Upward Price Breakout private EMA EMA1; // Trend designer protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Identify stocks which breakout of rectangular base with volume"; Name = "AresPriceBreakOut"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; IsSuspendedWhileInactive = true; AddPlot(new Stroke(Brushes.OrangeRed, 2), PlotStyle.Bar, "Plot0"); EMA1 = EMA(Close, 200); } } protected override void OnBarUpdate() { Plot0[0] = Close[0]; if (upwardBreakout.ToUpper() == "YES") { if (CurrentBar > 45) { if ((High[0] > MAX(High, 9)[1]) && (Low[0] > MIN(Low, 9)[1]) && (Close[0] > MAX(High, 50)[1]) && ((MIN(Low, 20)[1] < (MIN(Low, 40)[1] * 1.05)) || (MIN(Low, 20)[1] <= (MIN(Low, 40)[1] + 1))) && ((MAX(High, 20)[1] > (MAX(High, 40)[1] * 0.95)) || (MAX(High, 20)[1] >= (MAX(High, 40)[1] - 1))) && (Volume[0] > VOLMA(40)[1] * volumeMultiplier) ) { Plot0[0] = 1; } else { Plot0[0] = 0; } } else { Plot0[0] = 0; } } else { if (CurrentBar > 45) { if ((High[0] < MAX(High, 9)[1]) && (Low[0] < MIN(Low, 9)[1]) && (Close[0] < MIN(Low, 50)[1]) && ((MIN(Low, 20)[1] > (MIN(Low, 40)[1] * 0.95)) || (MIN(Low, 20)[1] >= (MIN(Low, 40)[1] - 1))) && ((MAX(High, 20)[1] < (MAX(High, 40)[1] * 1.05)) || (MAX(High, 20)[1] <= (MAX(High, 40)[1] + 1))) && (Volume[0] > VOLMA(40)[1] * volumeMultiplier) ) { Plot0[0] = -1; } else { Plot0[0] = 0; } } else { Plot0[0] = 0; } } } #region Properties [NinjaScriptProperty] [Display(Name="UpwardBreakout", Description="Enter 'YES' for upward breakout & 'NO' for downward breakout", Order=1, GroupName="Parameters")] public string UpwardBreakout { get { return upwardBreakout; } set { upwardBreakout = value; } } [Range(1, double.MaxValue)] [NinjaScriptProperty] [Display(Name="VolumeMultiplier", Description="Volume multiplier for high volume daily breakout", Order=2, GroupName="Parameters")] public double VolumeMultiplier { get { return volumeMultiplier; } set { volumeMultiplier = Math.Max(1, value); } } [Browsable(false)] [XmlIgnore] public Series Plot0 { get { return Values[0]; } } #endregion } }