示例#1
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionDoubleStochastics;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameDoubleStochastics;
                IsSuspendedWhileInactive = true;
                Period = 10;

                AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.StochasticsK);
                AddLine(new Gui.Stroke(Brushes.DodgerBlue, Gui.DashStyleHelper.Dash, 1), 90, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
                AddLine(new Gui.Stroke(Brushes.DodgerBlue, Gui.DashStyleHelper.Dash, 1), 10, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
            }
            else if (State == State.DataLoaded)
            {
                p1      = new Series <double>(this);
                p2      = new Series <double>(this);
                p3      = new Series <double>(this);
                emaP1   = EMA(p1, 3);
                emaP3   = EMA(p3, 3);
                maxHigh = MAX(High, Period);
                maxP2   = MAX(p2, Period);
                minLow  = MIN(Low, Period);
                minP2   = MIN(p2, Period);
            }
        }
示例#2
0
 protected override void OnStateChange()
 {
     if (State == State.SetDefaults)
     {
         Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionStochastics;
         Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameStochastics;
         IsSuspendedWhileInactive = true;
         PeriodD = 7;
         PeriodK = 14;
         Smooth  = 3;
         DColor  = Brushes.DodgerBlue;
         KColor  = Brushes.Goldenrod;
     }
     else if (State == State.Configure)
     {
         AddPlot(DColor, NinjaTrader.Custom.Resource.StochasticsD);
         AddPlot(KColor, NinjaTrader.Custom.Resource.StochasticsK);
         AddLine(Brushes.PaleGoldenrod, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
         AddLine(Brushes.PaleGoldenrod, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
     }
     else if (State == State.DataLoaded)
     {
         den      = new Series <double>(this);
         nom      = new Series <double>(this);
         fastK    = new Series <double>(this);
         min      = MIN(Low, PeriodK);
         max      = MAX(High, PeriodK);
         smaFastK = SMA(fastK, Smooth);
         smaK     = SMA(K, PeriodD);
     }
 }
示例#3
0
 protected override void OnStateChange()
 {
     if (State == State.SetDefaults)
     {
         Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionKeyReversalUp;
         Name        = "Key Reversals";
         IsSuspendedWhileInactive = true;
         Period = 3;
     }
     else if (State == State.DataLoaded)
     {
         min = MIN(Low, Period);
     }
     max = MAX(High, Period);
 }
示例#4
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionKeyReversalUp;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameKeyReversalUp;
                IsSuspendedWhileInactive = true;
                Period = 1;

                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.KeyReversalPlot0);
            }
            else if (State == State.DataLoaded)
            {
                min = MIN(Low, Period);
            }
        }
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description              = @"Quality divergence finder using FisherTransform indicator";
                Name                     = "CenTexFishTDiv";
                Calculate                = Calculate.OnBarClose;
                IsOverlay                = false;
                DisplayInDataBox         = true;
                DrawOnPricePanel         = false;
                DrawHorizontalGridLines  = true;
                DrawVerticalGridLines    = true;
                PaintPriceMarkers        = true;
                ScaleJustification       = NinjaTrader.Gui.Chart.ScaleJustification.Left; //Changed from right to left
                IsSuspendedWhileInactive = false;                                         // set to false because of alerts
                AddPlot(new Stroke(Brushes.Chartreuse, 1), PlotStyle.Bar, "IndicPlot0");  /// the number is = barwidth of histogram
                AddPlot(Brushes.White, "IndicPlot1");
                AddPlot(Brushes.Yellow, "IndicPlot2");
                AddPlot(new Stroke(Brushes.Yellow, 2), PlotStyle.Bar, "IndicPlot3");                /// the number is = barwidth of histogram
                //	AddLine(Brushes.Yellow, fromZero, "IndicLine0");
                //	AddLine(Brushes.Chartreuse, - fromZero, "IndicLine1");

                max        = MAX(Input, period);
                min        = MIN(Input, period);
                tmpSeries  = new Series <double>(this);
                counter    = 0;
                isCounting = false;
            }

            else if (State == State.Configure)
            {
                HighBarsAgo = new int[QueueLength];
                LowBarsAgo  = new int[QueueLength];

                for (int i = 0; i < QueueLength; i++)
                {
                    HighBarsAgo[i] = 0;
                    LowBarsAgo[i]  = 0;
                }
            }

            else if (State == State.DataLoaded)
            {
                Name      = "";
                Indicator = new Series <double>(this, MaximumBarsLookBack.Infinite);
            }
        }
示例#6
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionFisherTransform;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameFisherTransform;
                IsSuspendedWhileInactive = true;
                Period = 10;

                AddPlot(new Stroke(Brushes.DodgerBlue, 2), PlotStyle.Bar, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameFisherTransform);
            }
            else if (State == State.DataLoaded)
            {
                max       = MAX(Input, Period);
                min       = MIN(Input, Period);
                tmpSeries = new Series <double>(this);
            }
        }
示例#7
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionWilliamsR;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameWilliamsR;
                IsSuspendedWhileInactive = true;
                Period = 14;

                AddLine(Brushes.DarkGray, -25, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
                AddLine(Brushes.DarkGray, -75, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.WilliamsPercentR);
            }
            else if (State == State.DataLoaded)
            {
                max = MAX(High, Period);
                min = MIN(Low, Period);
            }
        }
示例#8
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionDonchianChannel;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameDonchianChannel;
                IsOverlay   = true;
                IsSuspendedWhileInactive = true;
                Period = 14;

                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.DonchianChannelMean);
                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
            }
            else if (State == State.DataLoaded)
            {
                max = MAX(High, Period);
                min = MIN(Low, Period);
            }
        }
示例#9
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionDonchianChannel;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameDonchianChannel;
                IsOverlay   = true;
                IsSuspendedWhileInactive = true;
                Period = 14;

                AddPlot(Brushes.Orange, "Mean");
                AddPlot(Brushes.Blue, "Upper");
                AddPlot(Brushes.Blue, "Lower");
            }
            else if (State == State.Configure)
            {
                max = MAX(High, Period);
                min = MIN(Low, Period);
            }
        }
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionStochasticsFast;
                Name        = String.Format("Enhanced{0}", NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameStochasticsFast);
                IsSuspendedWhileInactive = true;
                PeriodD      = 3;
                PeriodK      = 14;
                DColor       = Brushes.DodgerBlue;
                KColor       = Brushes.Goldenrod;
                DetectTrends = false;
                Strength     = 1;
            }
            else if (State == State.Configure)
            {
                AddPlot(DColor, NinjaTrader.Custom.Resource.StochasticsD);
                AddPlot(KColor, NinjaTrader.Custom.Resource.StochasticsK);
                AddPlot(new Stroke(Brushes.LightBlue, DashStyleHelper.Solid, 1), PlotStyle.Square, "TrendInfo");
                AddLine(Brushes.PaleGoldenrod, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
                AddLine(Brushes.PaleGoldenrod, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
            }
            else if (State == State.DataLoaded)
            {
                den  = new Series <double>(this);
                nom  = new Series <double>(this);
                min  = MIN(Low, PeriodK);
                max  = MAX(High, PeriodK);
                smaK = SMA(K, PeriodD);

                unique = Guid.NewGuid().ToString();

                signal                   = new Series <int>(this);
                direction                = new Series <int>(this);
                trendPrice               = new Series <double>(this);
                trendStartPrice          = new Series <double>(this);
                trendEndPrice            = new Series <double>(this);
                crossBelowUpperThreshold = new Series <bool>(this);
                crossAboveLowerThreshold = new Series <bool>(this);
            }
        }
示例#11
0
文件: RIND.cs 项目: phixlr/Indicators
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionRIND;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameRIND;
                IsOverlay   = false;
                IsSuspendedWhileInactive = true;
                PeriodQ = 3;
                Smooth  = 10;

                AddPlot(Brushes.DarkCyan, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameRIND);
            }

            else if (State == State.DataLoaded)
            {
                stochRange = new Series <double>(this);
                val1       = new Series <double>(this);
                ema        = EMA(stochRange, Smooth);
                min        = MIN(val1, PeriodQ);
                max        = MAX(val1, PeriodQ);
            }
        }
示例#12
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionStochRSI;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameStochRSI;
                IsSuspendedWhileInactive = true;
                IsOverlay = false;
                Period    = 14;

                AddPlot(Brushes.DarkCyan, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameStochRSI);

                AddLine(Brushes.Crimson, 0.8, NinjaTrader.Custom.Resource.NinjaScriptIndicatorOverbought);
                AddLine(Brushes.DodgerBlue, 0.5, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNeutral);
                AddLine(Brushes.Crimson, 0.2, NinjaTrader.Custom.Resource.NinjaScriptIndicatorOversold);
            }
            else if (State == State.DataLoaded)
            {
                rsi = RSI(Inputs[0], Period, 1);
                min = MIN(rsi, Period);
                max = MAX(rsi, Period);
            }
        }
示例#13
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionStochasticsFast;
                Name        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameStochasticsFast;
                IsSuspendedWhileInactive = true;
                PeriodD = 3;
                PeriodK = 14;

                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.StochasticsD);
                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.StochasticsK);
                AddLine(Brushes.DarkCyan, 20, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLower);
                AddLine(Brushes.DarkCyan, 80, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUpper);
            }
            else if (State == State.DataLoaded)
            {
                den  = new Series <double>(this);
                nom  = new Series <double>(this);
                min  = MIN(Low, PeriodK);
                max  = MAX(High, PeriodK);
                smaK = SMA(K, PeriodD);
            }
        }
示例#14
0
        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);
        }
示例#15
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description              = @"DOP Trading levels displayed on a price chart";
                Name                     = "DOP Buttons Lines";
                Calculate                = Calculate.OnBarClose;
                IsOverlay                = true;
                DisplayInDataBox         = true;
                DrawOnPricePanel         = true;
                DrawHorizontalGridLines  = true;
                DrawVerticalGridLines    = true;
                PaintPriceMarkers        = false;
                ScaleJustification       = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                IsSuspendedWhileInactive = true;
                Text                     = string.Empty;
                KPColor                  = Brushes.Orange;
                CPAColor                 = Brushes.CornflowerBlue;
                KPAoff                   = false;
                AudioAlertsOn            = false;
                KPALertSound             = "Alert1.wav";
                CPAALertSound            = "Alert2.wav";
                ImportantAreaALertSound  = "Alert3.wav";
                SendSMS                  = false;
                SMSAddress               = "*****@*****.**";
                HostEmailAddress         = "*****@*****.**";
                HostAddress              = "smtp.gmail.com";
                HostPort                 = 587;
                HostUserName             = "******";
                HostPassword             = "******";
                WatchArea1               = 2856.00;
                WatchArea2               = 2875.00;
                WatchArea3               = 2900.00;

                CPALineWidth = 3;
                KPALineWidth = 1;

                SimpleColsol  = true;
                ComplexConsol = true;

                Period = 3;
            }
            else if (State == State.Configure)
            {
                ClearOutputWindow();
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    chart = Window.GetWindow(ChartControl) as Chart;
                }));

                s.TargetType = typeof(System.Windows.Controls.Button);
                s.Setters.Add(new Setter(System.Windows.Controls.Button.FontSizeProperty, 11.0));
                s.Setters.Add(new Setter(System.Windows.Controls.Button.BackgroundProperty, Brushes.DimGray));
                s.Setters.Add(new Setter(System.Windows.Controls.Button.ForegroundProperty, Brushes.WhiteSmoke));
                s.Setters.Add(new Setter(System.Windows.Controls.Button.FontFamilyProperty, new FontFamily("Arial")));
                s.Setters.Add(new Setter(System.Windows.Controls.Button.FontWeightProperty, FontWeights.Bold));
            }
            else if (State == State.Historical)
            {
                if (!IsToolBarButtonAdded)
                {
                    AddFirstButton();
                    AddSecondButton();
                    AddThirdButton();
                }
            }
            else if (State == State.Terminated)
            {
                DisposeCleanUp();
            }
            else if (State == State.DataLoaded)
            {
                min = MIN(Low, Period);
                max = MAX(High, Period);
            }
        }