protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "MooreTechStops"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; } else if (State == State.Configure) { } else if (State == State.DataLoaded) { Swing1 = Swing(5); // for piv stops } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionTrendLines; Name = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameTrendLines; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = false; DrawOnPricePanel = false; PaintPriceMarkers = false; Strength = 5; NumberOfTrendLines = 1; OldTrendsOpacity = 25; AlertOnBreak = false; AlertOnBreakSound = System.IO.Path.Combine(NinjaTrader.Core.Globals.InstallDir, "sounds", "Alert2.wav"); TrendLineHighStroke = new Stroke(Brushes.DarkCyan, 1f); TrendLineLowStroke = new Stroke(Brushes.Goldenrod, 1f); } else if (State == State.Configure) { AddPlot(Brushes.White, NinjaTrader.Custom.Resource.TrendLinesCurrentTrendLine); } else if (State == State.DataLoaded) { swing = Swing(Input, Strength); trendLines = new TrendQueue(this, NumberOfTrendLines); } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Detects n-legs pullbacks either on the long or short side and visualizes the leg counts and wires them together"; Name = "NLegPullback"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; Strict = true; } else if (State == State.DataLoaded) { this.ema20 = EMA(20); this.ema50 = EMA(50); this.swing = Swing(5); } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "DailyPivots"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; Strength = 5; AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Dot, "PivotLow"); AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Dot, "PivotHigh"); } else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Day, 1); } else if (State == State.DataLoaded) { Swing1 = Swing(Strength); ClearOutputWindow(); } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "_MooreTech Swing 3"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; IsSuspendedWhileInactive = true; /// inputs shares = 100; swingPct = 0.005; minBarsToLastSwing = 70; enableHardStop = true; pctHardStop = 3; enablePivotStop = true; pivotStopSwingSize = 5; pivotStopPivotRange = 0.2; /// swow plots showUpCount = false; showHardStops = false; printTradesOnChart = false; printTradesSimple = false; printTradesTolog = true; sendOnlyCurrentBarToFirebase = true; } else if (State == State.Configure) { upColor = Brushes.LimeGreen; downColor = Brushes.Crimson; textColor = Brushes.Crimson; } else if (State == State.DataLoaded) { ClearOutputWindow(); Swing1 = Swing(5); // for piv stops FastPivotFinder1 = FastPivotFinder(false, false, 70, 0.005, 1); signals = new Series <int>(this, MaximumBarsLookBack.Infinite); // for starategy integration } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "Cycle Counter Harmonic"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = false; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; SwingStrength = 5; SmallCycleMin = 12; LargeCycleMin = 90; NoteLocation = TextPosition.TopLeft; BackgroundColor = Brushes.DimGray; BackgroundOpacity = 90; FontColor = Brushes.WhiteSmoke; OutlineColor = Brushes.DimGray; NoteFont = new SimpleFont("Arial", 12); } else if (State == State.Configure) { } else if (State == State.DataLoaded) { Swing1 = Swing(Close, SwingStrength); ClearOutputWindow(); WTTcRSI21 = WTTcRSI2(Close, 20, 10, true, 3, 20, Brushes.DodgerBlue, Brushes.Red); WTTcRSI21.Plots[0].Brush = Brushes.Red; WTTcRSI21.Plots[1].Brush = Brushes.DodgerBlue; WTTcRSI21.Plots[2].Brush = Brushes.DimGray; WTTcRSI21.Plots[3].Brush = Brushes.DodgerBlue; //AddChartIndicator(WTTcRSI21); } }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "UltimateDivergence"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; } else if (State == State.Configure) { } else if (State == State.DataLoaded) { UltimateOscillator1 = UltimateOscillator(7, 14, 28); Swing1 = Swing(UltimateOscillator1, 3); Swing2 = Swing(3); lowSwingOsc = new Series <double>(this, MaximumBarsLookBack.Infinite); // for starategy integration /* * private Series<bool> higherLowOscFound; * private Series<bool> lowerLowPriceFound; */ higherLowOscFound = new Series <bool>(this, MaximumBarsLookBack.Infinite); lowerLowPriceFound = new Series <bool>(this, MaximumBarsLookBack.Infinite); } }
public bool Evaluate(ChartPattern pattern) { if (ninjaScript.CurrentBar < trendStrength || ninjaScript.CurrentBar < 2) { return(false); } if (max == null && trendStrength > 0 && (pattern == ChartPattern.HangingMan || pattern == ChartPattern.InvertedHammer)) { max = new Indicators.MAX(); max.Period = trendStrength; try { max.SetState(State.Configure); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { max.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); max.SetState(State.Finalized); } max.Parent = ninjaScript; max.SetInput(ninjaScript.High); lock (ninjaScript.NinjaScripts) ninjaScript.NinjaScripts.Add(max); try { max.SetState(ninjaScript.State); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { max.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); max.SetState(State.Finalized); return(false); } } if (min == null && trendStrength > 0 && pattern == ChartPattern.Hammer) { min = new MIN(); min.Period = trendStrength; try { min.SetState(State.Configure); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { min.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); min.SetState(State.Finalized); } min.Parent = ninjaScript; min.SetInput(ninjaScript.Low); lock (ninjaScript.NinjaScripts) ninjaScript.NinjaScripts.Add(min); try { min.SetState(ninjaScript.State); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { min.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); min.SetState(State.Finalized); return(false); } } if (pattern != ChartPattern.Doji && pattern != ChartPattern.DownsideTasukiGap && pattern != ChartPattern.EveningStar && pattern != ChartPattern.FallingThreeMethods && pattern != ChartPattern.MorningStar && pattern != ChartPattern.RisingThreeMethods && pattern != ChartPattern.StickSandwich && pattern != ChartPattern.UpsideTasukiGap) { if (trendStrength == 0) { isInDownTrend = true; isInUpTrend = true; } else { if (swing == null) { swing = new Swing(); swing.Strength = trendStrength; try { swing.SetState(State.Configure); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { swing.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); swing.SetState(State.Finalized); } swing.Parent = ninjaScript; swing.SetInput(ninjaScript.Input); lock (ninjaScript.NinjaScripts) ninjaScript.NinjaScripts.Add(swing); try { swing.SetState(ninjaScript.State); } catch (Exception exp) { Cbi.Log.Process(typeof(Resource), "CbiUnableToCreateInstance2", new object[] { swing.Name, exp.InnerException != null ? exp.InnerException.ToString() : exp.ToString() }, Cbi.LogLevel.Error, Cbi.LogCategories.Default); swing.SetState(State.Finalized); return(false); } } // Calculate up trend line int upTrendStartBarsAgo = 0; int upTrendEndBarsAgo = 0; int upTrendOccurence = 1; while (ninjaScript.Low[upTrendEndBarsAgo] <= ninjaScript.Low[upTrendStartBarsAgo]) { upTrendStartBarsAgo = swing.SwingLowBar(0, upTrendOccurence + 1, ninjaScript.CurrentBar); upTrendEndBarsAgo = swing.SwingLowBar(0, upTrendOccurence, ninjaScript.CurrentBar); if (upTrendStartBarsAgo < 0 || upTrendEndBarsAgo < 0) { break; } upTrendOccurence++; } // Calculate down trend line int downTrendStartBarsAgo = 0; int downTrendEndBarsAgo = 0; int downTrendOccurence = 1; while (ninjaScript.High[downTrendEndBarsAgo] >= ninjaScript.High[downTrendStartBarsAgo]) { downTrendStartBarsAgo = swing.SwingHighBar(0, downTrendOccurence + 1, ninjaScript.CurrentBar); downTrendEndBarsAgo = swing.SwingHighBar(0, downTrendOccurence, ninjaScript.CurrentBar); if (downTrendStartBarsAgo < 0 || downTrendEndBarsAgo < 0) { break; } downTrendOccurence++; } if (upTrendStartBarsAgo > 0 && upTrendEndBarsAgo > 0 && upTrendStartBarsAgo < downTrendStartBarsAgo) { isInDownTrend = false; isInUpTrend = true; } else if (downTrendStartBarsAgo > 0 && downTrendEndBarsAgo > 0 && upTrendStartBarsAgo > downTrendStartBarsAgo) { isInDownTrend = true; isInUpTrend = false; } else { isInDownTrend = false; isInUpTrend = false; } } } bool found = false; NinjaScriptBase n = ninjaScript; if (!prior[0] && !prior[1]) // no pattern found on the last 2 bars { switch (pattern) { case ChartPattern.BearishBeltHold: found = isInUpTrend && n.Close[1] > n.Open[1] && n.Open[0] > n.Close[1] + 5 * n.TickSize && n.Open[0] == n.High[0] && n.Close[0] < n.Open[0]; break; case ChartPattern.BearishEngulfing: found = isInUpTrend && n.Close[1] > n.Open[1] && n.Close[0] < n.Open[0] && n.Open[0] > n.Close[1] && n.Close[0] < n.Open[1]; break; case ChartPattern.BearishHarami: found = isInUpTrend && n.Close[0] < n.Open[0] && n.Close[1] > n.Open[1] && n.Low[0] >= n.Open[1] && n.High[0] <= n.Close[1]; break; case ChartPattern.BearishHaramiCross: found = isInUpTrend && (n.High[0] <= n.Close[1]) && (n.Low[0] >= n.Open[1]) && n.Open[0] <= n.Close[1] && n.Close[0] >= n.Open[1] && ((n.Close[0] >= n.Open[0] && n.Close[0] <= n.Open[0] + n.TickSize) || (n.Close[0] <= n.Open[0] && n.Close[0] >= n.Open[0] - n.TickSize)); break; case ChartPattern.BullishBeltHold: found = isInDownTrend && n.Close[1] < n.Open[1] && n.Open[0] < n.Close[1] - 5 * n.TickSize && n.Open[0] == n.Low[0] && n.Close[0] > n.Open[0]; break; case ChartPattern.BullishEngulfing: found = isInDownTrend && n.Close[1] < n.Open[1] && n.Close[0] > n.Open[0] && n.Close[0] > n.Open[1] && n.Open[0] < n.Close[1]; break; case ChartPattern.BullishHarami: found = isInDownTrend && n.Close[0] > n.Open[0] && n.Close[1] < n.Open[1] && n.Low[0] >= n.Close[1] && n.High[0] <= n.Open[1]; break; case ChartPattern.BullishHaramiCross: found = isInDownTrend && (n.High[0] <= n.Open[1]) && (n.Low[0] >= n.Close[1]) && n.Open[0] >= n.Close[1] && n.Close[0] <= n.Open[1] && ((n.Close[0] >= n.Open[0] && n.Close[0] <= n.Open[0] + n.TickSize) || (n.Close[0] <= n.Open[0] && n.Close[0] >= n.Open[0] - n.TickSize)); break; case ChartPattern.DarkCloudCover: found = isInUpTrend && n.Open[0] > n.High[1] && n.Close[1] > n.Open[1] && n.Close[0] < n.Open[0] && n.Close[0] <= n.Close[1] - (n.Close[1] - n.Open[1]) / 2 && n.Close[0] >= n.Open[1]; break; case ChartPattern.Doji: found = Math.Abs(n.Close[0] - n.Open[0]) <= (n.High[0] - n.Low[0]) * 0.07; break; case ChartPattern.DownsideTasukiGap: found = n.Close[2] < n.Open[2] && n.Close[1] < n.Open[1] && n.Close[0] > n.Open[0] && n.High[1] < n.Low[2] && n.Open[0] > n.Close[1] && n.Open[0] < n.Open[1] && n.Close[0] > n.Open[1] && n.Close[0] < n.Close[2]; break; case ChartPattern.EveningStar: found = n.Close[2] > n.Open[2] && n.Close[1] > n.Close[2] && n.Open[0] < (Math.Abs((n.Close[1] - n.Open[1]) / 2) + n.Open[1]) && n.Close[0] < n.Open[0]; break; case ChartPattern.FallingThreeMethods: found = n.CurrentBar > 5 && n.Close[4] < n.Open[4] && n.Close[0] < n.Open[0] && n.Close[0] < n.Low[4] && n.High[3] < n.High[4] && n.Low[3] > n.Low[4] && n.High[2] < n.High[4] && n.Low[2] > n.Low[4] && n.High[1] < n.High[4] && n.Low[1] > n.Low[4]; break; case ChartPattern.Hammer: found = isInDownTrend && (min == null ? true : min[0] == n.Low[0]) && n.Low[0] < n.Open[0] - 5 * n.TickSize && Math.Abs(n.Open[0] - n.Close[0]) < (0.10 * (n.High[0] - n.Low[0])) && (n.High[0] - n.Close[0]) < (0.25 * (n.High[0] - n.Low[0])); break; case ChartPattern.HangingMan: found = isInUpTrend && (max == null ? true : max[0] == n.High[0]) && n.Low[0] < n.Open[0] - 5 * n.TickSize && Math.Abs(n.Open[0] - n.Close[0]) < (0.10 * (n.High[0] - n.Low[0])) && (n.High[0] - n.Close[0]) < (0.25 * (n.High[0] - n.Low[0])); break; case ChartPattern.InvertedHammer: found = isInUpTrend && (max == null ? true : max[0] == n.High[0]) && n.High[0] > n.Open[0] + 5 * n.TickSize && Math.Abs(n.Open[0] - n.Close[0]) < (0.10 * (n.High[0] - n.Low[0])) && (n.Close[0] - n.Low[0]) < (0.25 * (n.High[0] - n.Low[0])); break; case ChartPattern.MorningStar: found = n.Close[2] < n.Open[2] && n.Close[1] < n.Close[2] && n.Open[0] > (Math.Abs((n.Close[1] - n.Open[1]) / 2) + n.Open[1]) && n.Close[0] > n.Open[0]; break; case ChartPattern.PiercingLine: found = isInDownTrend && n.Open[0] < n.Low[1] && n.Close[1] < n.Open[1] && n.Close[0] > n.Open[0] && n.Close[0] >= n.Close[1] + (n.Open[1] - n.Close[1]) / 2 && n.Close[0] <= n.Open[1]; break; case ChartPattern.RisingThreeMethods: found = n.CurrentBar > 5 && n.Close[4] > n.Open[4] && n.Close[0] > n.Open[0] && n.Close[0] > n.High[4] && n.High[3] < n.High[4] && n.Low[3] > n.Low[4] && n.High[2] < n.High[4] && n.Low[2] > n.Low[4] && n.High[1] < n.High[4] && n.Low[1] > n.Low[4]; break; case ChartPattern.ShootingStar: found = isInUpTrend && n.High[0] > n.Open[0] && (n.High[0] - n.Open[0]) >= 2 * (n.Open[0] - n.Close[0]) && n.Close[0] < n.Open[0] && (n.Close[0] - n.Low[0]) <= 2 * n.TickSize; break; case ChartPattern.StickSandwich: found = n.Close[2] == n.Close[0] && n.Close[2] < n.Open[2] && n.Close[1] > n.Open[1] && n.Close[0] < n.Open[0]; break; case ChartPattern.ThreeBlackCrows: found = isInUpTrend && n.Close[0] < n.Open[0] && n.Close[1] < n.Open[1] && n.Close[2] < n.Open[2] && n.Close[0] < n.Close[1] && n.Close[1] < n.Close[2] && n.Open[0] < n.Open[1] && n.Open[0] > n.Close[1] && n.Open[1] < n.Open[2] && n.Open[1] > n.Close[2]; break; case ChartPattern.ThreeWhiteSoldiers: found = isInDownTrend && n.Close[0] > n.Open[0] && n.Close[1] > n.Open[1] && n.Close[2] > n.Open[2] && n.Close[0] > n.Close[1] && n.Close[1] > n.Close[2] && n.Open[0] < n.Close[1] && n.Open[0] > n.Open[1] && n.Open[1] < n.Close[2] && n.Open[1] > n.Open[2]; break; case ChartPattern.UpsideGapTwoCrows: found = isInUpTrend && n.Close[2] > n.Open[2] && n.Close[1] < n.Open[1] && n.Close[0] < n.Open[0] && n.Low[1] > n.High[2] && n.Close[0] > n.High[2] && n.Close[0] < n.Close[1] && n.Open[0] > n.Open[1]; break; case ChartPattern.UpsideTasukiGap: found = n.Close[2] > n.Open[2] && n.Close[1] > n.Open[1] && n.Close[0] < n.Open[0] && n.Low[1] > n.High[2] && n.Open[0] < n.Close[1] && n.Open[0] > n.Open[1] && n.Close[0] < n.Open[1] && n.Close[0] > n.Close[2]; break; } } prior[n.CurrentBars[0] % 2] = found; return(found); }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "Cycle Counter DX Auto"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = false; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; SwingStrength = 5; SmallCycleMin = 12; LargeCycleMin = 90; // NoteLocation = TextPosition.TopLeft; BackgroundColor = Brushes.DimGray; // BackgroundOpacity = 90; // FontColor = Brushes.WhiteSmoke; // OutlineColor = Brushes.DimGray; // NoteFont = new SimpleFont("Arial", 12); AreaOpacity = 80; AreaBrush = System.Windows.Media.Brushes.DodgerBlue; textSize = 18; TextBrush = System.Windows.Media.Brushes.WhiteSmoke; CycleLength = 20; Vibration = 10; ShowZones = true; LineThickness = 3; Opacity = 20; UpColor = Brushes.DodgerBlue; DnColor = Brushes.Red; AddPlot(Brushes.Red, "CRSI"); AddPlot(Brushes.DodgerBlue, "CRISUpper"); AddPlot(Brushes.DimGray, "CRSINetral"); AddPlot(Brushes.DodgerBlue, "CRSILower"); } else if (State == State.Configure) { cycleConstant = (CycleLength - 1); torque = 2.0 / (Vibration + 1); phasingLag = (int)Math.Ceiling((Vibration - 1) / 2.0); CyclicMemory = CycleLength * 2; } else if (State == State.DataLoaded) { Swing1 = Swing(Close, SwingStrength); ClearOutputWindow(); avgUp = new Series <double>(this); avgDown = new Series <double>(this); down = new Series <double>(this); up = new Series <double>(this); raw = new Series <double>(this); } }