예제 #1
0
        protected override void OnBarUpdate()/////////////////////////////////////////////////////////
        {
            switch (mAType1)
            {
            case DMAType.EMA:
                ma1Series.Set(EMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.HMA:
                ma1Series.Set(HMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.WMA:
                ma1Series.Set(WMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.SMA:
                ma1Series.Set(SMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.MIN:
                ma1Series.Set(MIN(Input, mAPeriod1)[0]);
                break;

            case DMAType.MAX:
                ma1Series.Set(MAX(Input, mAPeriod1)[0]);
                break;

            case DMAType.Wilder:
                ma1Series.Set(Wilder(Input, mAPeriod1)[0]);
                break;

            case DMAType.EhlersFilter:
                ma1Series.Set(EhlersFilter(Input, mAPeriod1)[0]);
                break;

            case DMAType.ADXVMA:
                ma1Series.Set(ADXVMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.ZeroLagEMA:
                ma1Series.Set(ZeroLagEMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.TMA:
                ma1Series.Set(TMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.VWMA:
                ma1Series.Set(VWMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.SMMA:
                ma1Series.Set(SMMA(Input, mAPeriod1)[0]);
                break;

            case DMAType.LLMA:
                ma1Series.Set(LLMA(Input, mAPeriod1, 0)[0]);
                break;

            case DMAType.None:
                ma1Series.Set(Input[0]);
                break;
            }

            switch (mAType2)
            {
            case DMAType.EMA:
                ma2Series.Set(EMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.HMA:
                ma2Series.Set(HMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.WMA:
                ma2Series.Set(WMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.SMA:
                ma2Series.Set(SMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.MIN:
                ma2Series.Set(MIN(Input, mAPeriod2)[0]);
                break;

            case DMAType.MAX:
                ma2Series.Set(MAX(Input, mAPeriod2)[0]);
                break;

            case DMAType.Wilder:
                ma2Series.Set(Wilder(Input, mAPeriod2)[0]);
                break;

            case DMAType.EhlersFilter:
                ma2Series.Set(EhlersFilter(Input, mAPeriod2)[0]);
                break;

            case DMAType.ADXVMA:
                ma2Series.Set(ADXVMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.ZeroLagEMA:
                ma2Series.Set(ZeroLagEMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.TMA:
                ma2Series.Set(TMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.VWMA:
                ma2Series.Set(VWMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.SMMA:
                ma2Series.Set(SMMA(Input, mAPeriod2)[0]);
                break;

            case DMAType.LLMA:
                ma2Series.Set(LLMA(Input, mAPeriod2, 0)[0]);
                break;

            case DMAType.None:
                ma2Series.Set(Input[0]);
                break;
            }



            switch (mAType3)
            {
            case DMAType.EMA:
                ma3Series.Set(EMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.HMA:
                ma3Series.Set(HMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.WMA:
                ma3Series.Set(WMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.SMA:
                ma3Series.Set(SMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.MIN:
                ma3Series.Set(MIN(Input, mAPeriod3)[0]);
                break;

            case DMAType.MAX:
                ma3Series.Set(MAX(Input, mAPeriod3)[0]);
                break;

            case DMAType.Wilder:
                ma3Series.Set(Wilder(Input, mAPeriod3)[0]);
                break;

            case DMAType.EhlersFilter:
                ma3Series.Set(EhlersFilter(Input, mAPeriod3)[0]);
                break;

            case DMAType.ADXVMA:
                ma3Series.Set(ADXVMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.ZeroLagEMA:
                ma3Series.Set(ZeroLagEMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.TMA:
                ma3Series.Set(TMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.VWMA:
                ma3Series.Set(VWMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.SMMA:
                ma3Series.Set(SMMA(Input, mAPeriod3)[0]);
                break;

            case DMAType.LLMA:
                ma3Series.Set(LLMA(Input, mAPeriod3, 0)[0]);
                break;

            case DMAType.None:
                ma3Series.Set(Input[0]);
                break;
            }



            if (Drawline)
            {
                BarColor           = Color.Transparent;
                CandleOutlineColor = Color.Transparent;
            }



            Fast.Set(ma1Series[0]);
            Slow.Set(ma2Series[0]);
            Trend.Set(ma3Series[0]);

            if (Drawdots)
            {
                Dot.Set(Close[0]);

                if (Input[0] > Fast[0] && Input[0] > Slow[0] && Input[0] > Trend[0])
                {
                    PlotColors[0][0] = UpColor;
                }

                else if (Input[0] < Fast[0] && Input[0] < Slow[0] && Input[0] < Trend[0])
                {
                    PlotColors[0][0] = DownColor;
                }

                else
                {
                    PlotColors[0][0] = FlatColor;
                }
            }

            if (Drawdots == false)
            {
                Dot.Set(Close[0]);

                if (Close[0] > Open[0])
                {
                    PlotColors[0][0] = UpColor;
                }

                else if (Close[0] < Open[0])
                {
                    PlotColors[0][0] = DownColor;
                }

                else
                {
                    PlotColors[0][0] = FlatColor;
                }
            }

            if (Drawline)
            {
                if (Input[0] > Fast[0] && Input[0] > Slow[0] && Input[0] > Trend[0])
                {
                    Line.Set(Close[0]);
                    PlotColors[1][0] = UpColor;
                }

                else if (Input[0] < Fast[0] && Input[0] < Slow[0] && Input[0] < Trend[0])
                {
                    Line.Set(Close[0]);
                    PlotColors[1][0] = DownColor;
                }

                else
                {
                    Line.Set(Close[0]);
                    PlotColors[1][0] = FlatColor;
                }
            }

            if (colorbackground)
            {
                if (colorbackgroundall)


                {
                    if (Input[0] > Fast[0] && Input[0] > Slow[0] && Input[0] > Trend[0])
                    {
                        BackColorAll = Color.FromArgb(Opacity, BgColorUp);
                    }

                    else if (Input[0] < Fast[0] && Input[0] < Slow[0] && Input[0] < Trend[0])
                    {
                        BackColorAll = Color.FromArgb(Opacity, BgColorDown);
                    }

                    else
                    {
                        BackColorAll = Color.Empty;
                    }
                }

                else
                {
                    if (Input[0] > Fast[0] && Input[0] > Slow[0] && Input[0] > Trend[0])
                    {
                        BackColor = Color.FromArgb(Opacity, BgColorUp);
                    }

                    else if (Input[0] < Fast[0] && Input[0] < Slow[0] && Input[0] < Trend[0])
                    {
                        BackColor = Color.FromArgb(Opacity, BgColorDown);
                    }

                    else
                    {
                        BackColor = Color.Empty;
                    }
                }
            }


            if (Values[2][0] > Values[3][0])
            {
                PlotColors[2][0] = UpColorMA1;
                PlotColors[3][0] = UpColorMA2;
            }
            else
            {
                PlotColors[2][0] = DownColorMA1;
                PlotColors[3][0] = DownColorMA2;
            }


            if (Values[2][0] > Values[4][0] && Values[3][0] > Values[4][0])
            {
                PlotColors[4][0] = UpColorMA3;
            }

            else if (Values[2][0] < Values[4][0] && Values[3][0] < Values[4][0])
            {
                PlotColors[4][0] = DownColorMA3;
            }

            else
            {
                PlotColors[4][0] = FlatColorMA3;
            }

            if (soundAlert)
            {
                if (CrossAbove(Fast, Slow, 1))
                {
                    Alert("UpAlert", NinjaTrader.Cbi.Priority.Medium, "UpAlert", upAlertFile, 60, Color.Navy, Color.Magenta);
                }


                if (CrossBelow(Fast, Slow, 1))
                {
                    Alert("DownAlert", NinjaTrader.Cbi.Priority.Medium, "DownAlert", downAlertFile, 60, Color.Navy, Color.Yellow);
                }
            }


            if (CurrentBar < 2)
            {
                return;
            }

            if (Colorzone)
            {
                if (Fast[0] > Slow[0])
                {
                    DrawRegion("MABands" + CurrentBar, 1, 0, ma1Series, ma2Series, Color.Transparent, UpColor, Zopacity);
                }
                else
                {
                    DrawRegion("MABands" + CurrentBar, 1, 0, ma1Series, ma2Series, Color.Transparent, DownColor, Zopacity);
                }
            }
        }