コード例 #1
0
        public override void OnPaint(Graphics g, Rectangle r, double min, double max)
        {
            if (Bars == null || Chart == null)
            {
                return;
            }

            //Only draw button if parameters are available.
            if (this.Instrument != null && _list != null && _list.Count > 0)
            {
                using (Font font1 = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point))
                {
                    StringFormat stringFormat = new StringFormat();
                    stringFormat.Alignment     = StringAlignment.Center;
                    stringFormat.LineAlignment = StringAlignment.Center;

                    if (String.IsNullOrEmpty(Shortcut_list))
                    {
                        if (this.Name_of_list.Count() >= 5)
                        {
                            this.Shortcut_list = this.Name_of_list.Substring(0, 5);
                        }
                        else
                        {
                            this.Shortcut_list = this.Name_of_list;
                        }
                    }

                    this.Core.GetDataDirectory();

                    Brush tempbrush = new SolidBrush(GlobalUtilities.AdjustOpacity(((SolidBrush)_brush).Color, 0.5F));

                    _rect = new RectangleF(r.Width - 100, 10, 86, 27);
                    g.FillRectangle(tempbrush, _rect);
                    g.DrawString(Shortcut_list, font1, Brushes.White, _rect, stringFormat);
                    _rect2 = new RectangleF(r.Width - 100, 40, 86, 27);

                    //g.DrawRectangle(_pen, Rectangle.Round(_rect));
                }
            }
        }
コード例 #2
0
        public override void OnPaint(Graphics g, Rectangle r, double min, double max)
        {
            if (Bars == null || Chart == null)
            {
                return;
            }


            //Only draw button if parameters are available.
            if (this.Instrument != null)
            {
                string strtext = "open browser";
                //Only stocks are possible to lookup
                if (this.Instrument.InstrumentType == InstrumentType.Stock)
                {
                    _brush = Brushes.Green;
                }
                else
                {
                    _brush  = Brushes.Gray;
                    strtext = "not supported";
                }
                using (Font font1 = new Font("Arial", 8, FontStyle.Bold, GraphicsUnit.Point))
                {
                    StringFormat stringFormat = new StringFormat();
                    stringFormat.Alignment     = StringAlignment.Center;
                    stringFormat.LineAlignment = StringAlignment.Center;

                    this.Core.GetDataDirectory();

                    Brush tempbrush = new SolidBrush(GlobalUtilities.AdjustOpacity(((SolidBrush)_brush).Color, 0.5F));

                    _rect = new RectangleF(r.Width - 100, 10, 86, 27);
                    g.FillRectangle(tempbrush, _rect);
                    g.DrawString(strtext, font1, Brushes.White, _rect, stringFormat);
                    _rect2 = new RectangleF(r.Width - 100, 40, 86, 27);
                }
            }
        }
コード例 #3
0
        protected override void OnCalculate()
        {
            if (this.MA_1 != 0 && this.MA_1 > this.RequiredBarsCount ||
                this.MA_2 != 0 && this.MA_2 > this.RequiredBarsCount ||
                this.MA_3 != 0 && this.MA_3 > this.RequiredBarsCount ||
                this.MA_4 != 0 && this.MA_4 > this.RequiredBarsCount ||
                this.MA_5 != 0 && this.MA_5 > this.RequiredBarsCount ||
                this.MA_6 != 0 && this.MA_6 > this.RequiredBarsCount)
            {
                AddChartTextFixed("AlertText", "Required bars must be at least as high as the largest moving average period.", TextPosition.Center, Color.Red, new Font("Arial", 30), Color.Red, Color.Red, 20);
            }

            int _signal_value = 0;
            int _enabled_ifs  = 0;

            if (this.MA_1 != 0)
            {
                Plot_1.Set(this.GetValue(this.MA_1_Selected, this.MA_1));
            }
            if (this.MA_2 != 0)
            {
                Plot_2.Set(this.GetValue(this.MA_2_Selected, this.MA_2));
            }
            if (this.MA_3 != 0)
            {
                Plot_3.Set(this.GetValue(this.MA_3_Selected, this.MA_3));
            }
            if (this.MA_4 != 0)
            {
                Plot_4.Set(this.GetValue(this.MA_4_Selected, this.MA_4));
            }
            if (this.MA_5 != 0)
            {
                Plot_5.Set(this.GetValue(this.MA_5_Selected, this.MA_5));
            }
            if (this.MA_6 != 0)
            {
                Plot_6.Set(this.GetValue(this.MA_6_Selected, this.MA_6));
            }

            //Signals
            if (this.If_1_over_2)
            {
                _enabled_ifs++;
                if (this.MA_1 != 0 && this.MA_2 != 0 && Plot_1.Last() > Plot_2.Last())
                {
                    _signal_value++;
                }
                else if (this.MA_1 != 0 && this.MA_2 != 0 && Plot_1.Last() < Plot_2.Last())
                {
                    _signal_value--;
                }
            }

            if (this.If_2_over_3)
            {
                _enabled_ifs++;
                if (this.MA_2 != 0 && this.MA_3 != 0 && Plot_2.Last() > Plot_3.Last())
                {
                    _signal_value++;
                }
                else if (this.MA_2 != 0 && this.MA_3 != 0 && Plot_2.Last() < Plot_3.Last())
                {
                    _signal_value--;
                }
            }

            if (this.If_3_over_4)
            {
                _enabled_ifs++;
                if (this.MA_3 != 0 && this.MA_4 != 0 && Plot_3.Last() > Plot_4.Last())
                {
                    _signal_value++;
                }
                else if (this.MA_3 != 0 && this.MA_4 != 0 && Plot_3.Last() < Plot_4.Last())
                {
                    _signal_value--;
                }
            }

            if (this.If_4_over_5)
            {
                _enabled_ifs++;
                if (this.MA_4 != 0 && this.MA_5 != 0 && Plot_4.Last() > Plot_5.Last())
                {
                    _signal_value++;
                }
                else if (this.MA_4 != 0 && this.MA_5 != 0 && Plot_4.Last() < Plot_5.Last())
                {
                    _signal_value--;
                }
            }

            if (this.If_5_over_6)
            {
                _enabled_ifs++;
                if (this.MA_5 != 0 && this.MA_6 != 0 && Plot_5.Last() > Plot_6.Last())
                {
                    _signal_value++;
                }
                else if (this.MA_5 != 0 && this.MA_6 != 0 && Plot_5.Last() < Plot_6.Last())
                {
                    _signal_value--;
                }
            }


            //signal
            if (_signal_value == _enabled_ifs)
            {
                _signals.Set(1);
            }
            else if (_signal_value == _enabled_ifs * -1)
            {
                _signals.Set(-1);
            }
            else
            {
                _signals.Set(0);
            }

            //days
            if (_signals[0] == 0)
            {
                _days.Set(0);
            }
            else
            {
                if (_signals[0] == 1 && _signals[1] == 1)
                {
                    _days.Set(_days[1] + 1);
                }
                else if (_signals[0] == -1 && _signals[1] == -1)
                {
                    _days.Set(_days[1] - 1);
                }
                else
                {
                    if (_signals[0] == 1 && _signals[1] == 0 ||
                        _signals[0] == 1 && _signals[1] == -1)
                    {
                        _days.Set(1);
                    }
                    else
                    {
                        _days.Set(-1);
                    }
                }
            }


            if (ShowSignalOnChartBackground)
            {
                //color an background
                if (_signals[0] == 1)
                {
                    this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorLongSignalBackground, this.OpacityLongSignal / 100.0);
                }
                else if (_signals[0] == -1)
                {
                    this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorShortSignalBackground, this.OpacityShortSignal / 100.0);
                }
            }

            //if (this.ShowSignalOnChartPercent)
            //{
            //    //percent on all signals with more _enabled_ifs
            //    if (_signals[0] == 0 && _signals[1] != 0)
            //    {
            //        this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
            //    }
            //    else if (_signals[0] == 1 && _signals[1] == -1)
            //    {
            //        this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
            //    }
            //    else if (_signals[0] == -1 && _signals[1] == 1)
            //    {
            //        this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
            //    }

            //    //percent on last candle
            //    if (_signals[0] != 0 && IsProcessingBarIndexLast)
            //    {
            //        this.drawpercentlines(0, this.DashStyleLineLast, this.PlotWidthLineLast);
            //    }
            //}

            //percent
            //percent on all signals with more _enabled_ifs
            if (_signals[0] == 0 && _signals[1] != 0)
            {
                _percent.Set(this.getpercent(1));
                if (this.ShowSignalOnChartPercent)
                {
                    this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
                }
            }
            else if (_signals[0] == 1 && _signals[1] == -1)
            {
                _percent.Set(this.getpercent(1));
                if (this.ShowSignalOnChartPercent)
                {
                    this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
                }
            }
            else if (_signals[0] == -1 && _signals[1] == 1)
            {
                _percent.Set(this.getpercent(1));
                if (this.ShowSignalOnChartPercent)
                {
                    this.drawpercentlines(1, this.DashStyleLine, this.PlotWidthLine);
                }
            }

            //percent on last candle
            if (_signals[0] != 0 && IsProcessingBarIndexLast)
            {
                _percent.Set(this.getpercent(0));
                if (this.ShowSignalOnChartPercent)
                {
                    this.drawpercentlines(0, this.DashStyleLineLast, this.PlotWidthLineLast);
                }
            }


            if (this.ShowSignalOnChartArrow)
            {
                if (_signals[0] == 1 && _signals[1] != 1)
                {
                    AddChartArrowUp("ArrowLong_MA" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, this.ColorLongSignalArrow);
                }
                else if (_signals[0] == -1 && _signals[1] != -1)
                {
                    AddChartArrowDown("ArrowShort_MA" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].High, this.ColorShortSignalArrow);
                }
            }


            //Set the color
            PlotColors[0][0] = this.Color_1;
            OutputDescriptors[0].PenStyle  = this.DashStyle_1;
            OutputDescriptors[0].Pen.Width = this.LineWidth_1;
            PlotColors[1][0] = this.Color_2;
            OutputDescriptors[1].PenStyle  = this.DashStyle_2;
            OutputDescriptors[1].Pen.Width = this.LineWidth_2;
            PlotColors[2][0] = this.Color_3;
            OutputDescriptors[2].PenStyle  = this.DashStyle_3;
            OutputDescriptors[2].Pen.Width = this.LineWidth_3;
            PlotColors[3][0] = this.Color_4;
            OutputDescriptors[3].PenStyle  = this.DashStyle_4;
            OutputDescriptors[3].Pen.Width = this.LineWidth_4;
            PlotColors[4][0] = this.Color_5;
            OutputDescriptors[4].PenStyle  = this.DashStyle_5;
            OutputDescriptors[4].Pen.Width = this.LineWidth_5;
            PlotColors[5][0] = this.Color_6;
            OutputDescriptors[5].PenStyle  = this.DashStyle_6;
            OutputDescriptors[5].Pen.Width = this.LineWidth_6;
        }
コード例 #4
0
        protected override void OnCalculate()
        {
            Bollinger bb = Bollinger(this.StandardDeviation, this.Period);

            if (Close[0] > bb.Upper[0])
            {
                if (ShowSignalOnChartBackground)
                {
                    this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorLongSignalBackground, this.OpacityLongSignal / 100.0);
                }
                _signals.Set(1);
            }
            else if (Close[0] < bb.Lower[0])
            {
                if (ShowSignalOnChartBackground)
                {
                    this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorShortSignalBackground, this.OpacityShortSignal / 100.0);
                }
                _signals.Set(-1);
            }
            else
            {
                _signals.Set(_signals[1]);
                if (_signals[1] == 1)
                {
                    if (ShowSignalOnChartBackground)
                    {
                        this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorLongSignalBackground, this.OpacityLongSignal / 100.0);
                    }
                }
                else
                {
                    if (ShowSignalOnChartBackground)
                    {
                        this.BackColor = GlobalUtilities.AdjustOpacity(this.ColorShortSignalBackground, this.OpacityShortSignal / 100.0);
                    }
                }
            }

            if (this.ShowSignalOnChartArrow)
            {
                if (_signals[0] == 1 && _signals[1] != 1)
                {
                    AddChartArrowUp("ArrowLong_MA" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, this.ColorLongSignalArrow);
                }
                else if (_signals[0] == -1 && _signals[1] != -1)
                {
                    AddChartArrowDown("ArrowShort_MA" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].High, this.ColorShortSignalArrow);
                }
            }

            //set bb
            this.Plot_Middle.Set(bb.Middle[0]);
            this.Plot_High.Set(bb.Upper[0]);
            this.Plot_Low.Set(bb.Lower[0]);


            //Set the color
            PlotColors[0][0] = this.Color_1;
            OutputDescriptors[0].PenStyle  = this.DashStyle_1;
            OutputDescriptors[0].Pen.Width = this.LineWidth_1;
            PlotColors[1][0] = this.Color_2;
            OutputDescriptors[1].PenStyle  = this.DashStyle_2;
            OutputDescriptors[1].Pen.Width = this.LineWidth_2;
            PlotColors[2][0] = this.Color_3;
            OutputDescriptors[2].PenStyle  = this.DashStyle_3;
            OutputDescriptors[2].Pen.Width = this.LineWidth_3;
        }