Beispiel #1
0
        protected override void OnCalculate()
        {
            //double m = Median(Data, TimePeriod);
            //int i, nh = 0, nl = 0;
            //for (i = 1; i < TimePeriod; i++)
            //{
            //    if (Data[i] > m && Data[i] > Data[i - 1])
            //        nl++;
            //    else if (Data[i] < m && Data[i] < Data[i - 1])
            //        nh++;
            //}
            //return 100.* (nl + nh) / (TimePeriod - 1);

            double m = Median[this.MMI_Period];
            int    i, nh = 0, nl = 0;

            for (i = 1; i < this.MMI_Period; i++)
            {
                if (this.InSeries[i] > m && this.InSeries[i] > this.InSeries[i - 1])
                {
                    nl++;
                }
                else if (this.InSeries[i] < m && this.InSeries[i] < this.InSeries[i - 1])
                {
                    nh++;
                }
            }
            double resulti = 100.0 * (nl + nh) / (this.MMI_Period - 1);

            MyPlot1.Set(resulti);
        }
        protected override void OnCalculate()
        {
            EMA    ema        = EMA(this.Period);
            double bull_power = High[0] - ema[0];
            double bear_power = Low[0] - ema[0];

            ds_bull_power.Set(bull_power);
            ds_bear_power.Set(bear_power);

            if (_ElderRayTyp == ElderRayTyp.BullPower)
            {
                MyPlot1.Set(bull_power);
            }
            else
            {
                MyPlot2.Set(bear_power);
            }


            //Set the color
            if (ema[0] > ema[1])
            {
                PlotColors[0][0] = Color.Green;
                OutputDescriptors[0].Pen.Width = 2;
            }
            else
            {
                PlotColors[0][0] = Color.Red;
                OutputDescriptors[0].Pen.Width = 1;
            }
            OutputDescriptors[0].PenStyle             = DashStyle.Solid;
            OutputDescriptors[0].OutputSerieDrawStyle = OutputSerieDrawStyle.Bar;

            if (ema[0] < ema[1])
            {
                PlotColors[1][0] = Color.Red;
                OutputDescriptors[1].Pen.Width = 2;
            }
            else
            {
                PlotColors[1][0] = Color.Green;
                OutputDescriptors[1].Pen.Width = 1;
            }
            OutputDescriptors[1].PenStyle             = DashStyle.Solid;
            OutputDescriptors[1].OutputSerieDrawStyle = OutputSerieDrawStyle.Bar;

            if (ema[0] > ema[1] && bear_power <0 && bear_power> ds_bear_power.Get(1))
            {
                AddChartArrowUp("ArrowLong" + Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.LightGreen);
            }

            if (ema[0] < ema[1] && bull_power > 0 && bull_power < ds_bull_power.Get(1))
            {
                AddChartArrowDown("ArrowShort" + Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].High, Color.Red);
            }
        }
        protected override void OnCalculate()
        {
            if (this.MA_1 != 0 && this.MA_1 > this.RequiredBarsCount)
            {
                AddChartTextFixed("AlertText", "Required bars must be at least as high as the moving average period.", TextPosition.Center, Color.Red, new Font("Arial", 30), Color.Red, Color.Red, 20);
            }

            double resulti = (this.GetValue(this.MA_1_Selected, this.MA_1, 0) - this.GetValue(this.MA_1_Selected, this.MA_1, 1)) / StdDev(this.MA_1)[0] * 100;

            MyPlot1.Set(resulti);
            MyPlot2.Set(0);
        }
        protected override void OnCalculate()
        {
            if (this.Period > this.RequiredBarsCount)
            {
                AddChartTextFixed("AlertText", "Required bars must be at least as high as the period.", TextPosition.Center, Color.Red, new Font("Arial", 30), Color.Red, Color.Red, 20);
            }

            int myres = 0;

            for (int i = 0; i < Period; i++)
            {
                if (Close[i] > Open[i])
                {
                    myres = myres + 1;
                }
            }
            //MyPlot1.Set(Bars.Reverse().Take(10).Where(x => x.IsGrowing).Count());
            MyPlot1.Set(myres * 10);
        }
        protected override void OnCalculate()
        {
            //Print("OnCalculate");
            int result_s = 0;
            int result_v = 0;

            //List<KeyValuePair<string, double>> sorted = (from kv in rank orderby kv.Value descending select kv).ToList();

            foreach (KeyValuePair <string, double> r in rank_s.OrderByDescending(key => key.Value))
            {
                //Print("Key: {0}, Value: {1}", author.Key, author.Value);
                result_s = result_s + 1;
                if (this.Instrument.Symbol == r.Key.ToString())
                {
                    break;
                }
            }

            foreach (KeyValuePair <string, double> r in rank_v.OrderByDescending(key => key.Value))
            {
                //Print("Key: {0}, Value: {1}", author.Key, author.Value);
                result_v = result_v + 1;
                if (this.Instrument.Symbol == r.Key.ToString())
                {
                    break;
                }
            }


            //foreach (var key in sorted)
            //{
            //    //Console.WriteLine("{0}: {1}", key, list[key]);
            //    result = result + 1;
            //    if (this.Instrument.Symbol == key.ToString())
            //    {
            //        break;
            //    }
            //}

            MyPlot1.Set((result_s + result_v) / 2);
        }
Beispiel #6
0
        protected override void OnCalculate()
        {
            if (this.IsProcessingBarIndexLast && this.Instrument != null)
            {
                if (!String.IsNullOrEmpty(Instrumentlist))
                {
                    this.Root.Core.InstrumentManager.GetInstrumentLists();
                    _list = this.Root.Core.InstrumentManager.GetInstrumentsListStatic(this.Instrumentlist);

                    //if (_list == null)
                    //{
                    //    _list = this.Root.Core.InstrumentManager.GetInstrumentsListDynamic(this.Name_of_list);
                    //}
                    if (_list == null)
                    {
                        Log(this.DisplayName + ": The list " + this.Instrumentlist + " does not exist.", InfoLogLevel.Warning);
                        MyPlot1.Set(-1);
                    }

                    //We have found a list
                    if (_list.Contains((Instrument)this.Instrument))
                    {
                        MyPlot1.Set(1);
                    }
                    else
                    {
                        MyPlot1.Set(0);
                    }
                }
                else
                {
                    Log(this.DisplayName + ": You need to specify a name for the list.", InfoLogLevel.Warning);
                    MyPlot1.Set(-1);
                }
            }


            //MyPlot1.Set(InSeries[0]);
        }
Beispiel #7
0
        /// <summary>
        /// Recalculate all data on each each bar update.
        /// </summary>
        protected override void OnBarUpdate()
        {
            double currentvalue = 0.0;

            switch (_indicatorenum)
            {
            case IndicatorEnum.SMA:
                currentvalue = SMA(IndicatorSMAPeriod)[0];
                break;

            case IndicatorEnum.EMA:
                currentvalue = EMA(IndicatorEMAPeriod)[0];
                break;

            default:
                break;
            }

            double lasthighvalue = _DATA_List.Reverse().Take(this.ComparisonPeriod).Max();

            if (lasthighvalue < currentvalue)
            {
                MyPlot1.Set(1);
            }
            else
            {
                MyPlot1.Set(0);
            }

            this._DATA_List.Set(currentvalue);

            //set the color
            PlotColors[0][0]   = this.Plot1Color;
            Plots[0].PenStyle  = this.Dash0Style;
            Plots[0].Pen.Width = this.Plot0Width;
        }
        protected override void OnCalculate()
        {
            Bollinger bol = Bollinger(this.Bollinger_stddev, this.Bollinger_Period);

            if (Close[0] < bol.Lower[0])
            {
                longsignalbb = true;
            }
            else if (Close[0] > bol.Upper[0])
            {
                shortsignalbb = true;
            }
            else
            {
                //nothing
            }

            MACD macd = MACD(this.MACD_Fast, this.MACD_Slow, this.MACD_Smooth);

            if (longsignalbb && CrossAbove(macd.Default, macd.Avg, 0))
            {
                AddChartArrowUp(Time[0].ToString() + "long", 0, Low[0], this.ColorLongSignal);
                MyPlot1.Set(1);
                longsignalbb = false;
            }
            else if (shortsignalbb && CrossBelow(macd.Default, macd.Avg, 0))
            {
                AddChartArrowDown(Time[0].ToString() + "short", 0, High[0], this.ColorShortSignal);
                MyPlot1.Set(-1);
                shortsignalbb = false;
            }
            else
            {
                MyPlot1.Set(0);
            }
        }
        protected override void OnCalculate()
        {
            if (this.TypeOfSignal == Enum_Type_of_Signal.ShowPercent)
            {
                switch (this.MA_1_Selected)
                {
                case Enum_Distance_Indicator_MA.SMA:
                    SMA    _sma     = SMA(this.Period);
                    double result_s = (InSeries[0] / (_sma[0] / 100)) - 100;
                    MyPlot1.Set(result_s);
                    //MyPlot2.Set(0);
                    break;

                case Enum_Distance_Indicator_MA.EMA:
                    EMA    _ema     = EMA(this.Period);
                    double result_e = (InSeries[0] / (_ema[0] / 100)) - 100;
                    MyPlot1.Set(result_e);
                    //MyPlot2.Set(0);
                    break;

                default:
                    break;
                }
            }
            else if (this.TypeOfSignal == Enum_Type_of_Signal.ShowDiscreteSignal)
            {
                switch (this.MA_1_Selected)
                {
                case Enum_Distance_Indicator_MA.SMA:
                    SMA    _sma     = SMA(this.Period);
                    double result_s = (InSeries[0] / (_sma[0] / 100)) - 100;
                    if (result_s < this.PercentThreshold && result_s >= 0)
                    {
                        MyPlot1.Set(1);
                    }
                    else if (result_s > (this.PercentThreshold * (-1)) && result_s < 0)
                    {
                        MyPlot1.Set(-1);
                    }
                    else
                    {
                        MyPlot1.Set(0);
                    }
                    //MyPlot2.Set(0);
                    break;

                case Enum_Distance_Indicator_MA.EMA:
                    EMA    _ema     = EMA(this.Period);
                    double result_e = (InSeries[0] / (_ema[0] / 100)) - 100;
                    if (result_e < this.PercentThreshold && result_e >= 0)
                    {
                        MyPlot1.Set(1);
                    }
                    else if (result_e > (this.PercentThreshold * (-1)) && result_e < 0)
                    {
                        MyPlot1.Set(-1);
                    }
                    else
                    {
                        MyPlot1.Set(0);
                    }
                    //MyPlot2.Set(0);
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #10
0
 protected override void OnCalculate()
 {
     MyPlot1.Set(Normalize(Closes[i1].ToList(), Closes[i1][0]));
     MyPlot2.Set(Normalize(Closes[i2].ToList(), Closes[i2][0]));
 }
Beispiel #11
0
 protected override void OnCalculate()
 {
     MyPlot1.Set(InSeries[0]);
 }
 protected override void OnCalculate()
 {
     MyPlot1.Set(StdDev(this.Period)[0] / SMA(this.Period)[0]);
 }
 protected override void OnBarUpdate()
 {
     MyPlot1.Set(Input[0]);
 }