Exemplo n.º 1
0
    public override void Start()
    {
        if (BattleController.Instance.Turn == 1)
        {
            BattleUI.Instance.SetVisible(false);
            ConversationUI.Open(4001, false, () =>
            {
                BattleUI.Instance.SetVisible(true);
                BattleController.Instance.TurnStartHandler -= Start;
            });
        }

        Plot_5 plot_5 = new Plot_5();

        BattleController.Instance.ShowEndHandler += plot_5.Start;
    }
Exemplo n.º 2
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;
        }