示例#1
0
        protected override void OnCalculate()
        {
            this.MyPlot1.Set(SMA(50)[0]);
            this.MyPlot2.Set(SMA(150)[0]);
            this.MyPlot3.Set(SMA(200)[0]);

            //Lets call the calculate method and save the result with the trade action
            ResultValue returnvalue = this.calculate(Close);

            //If the calculate method was not finished we need to stop and show an alert message to the user.
            if (returnvalue.ErrorOccured)
            {
                //Display error just one time
                if (!this.ErrorOccured)
                {
                    GlobalUtilities.DrawAlertTextOnChart(this, Const.DefaultStringErrorDuringCalculation);
                    this.ErrorOccured = true;
                }
                return;
            }


            //Entry
            if (returnvalue.Entry.HasValue)
            {
                switch (returnvalue.Entry)
                {
                case OrderDirection.Buy:
                    //AddChartDot("ArrowLong_Entry" + Bars[0].Time.Ticks, true, Bars[0].Time, Bars[0].Open, Color.LightGreen);
                    //this.MyPlot1.Set(1);
                    AddChartArrowUp("ArrowLong_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.LightGreen);
                    break;
                }
            }
            else
            {
                //Value was null so nothing to do.
                //this.MyPlot1.Set(0);
            }
        }
示例#2
0
        protected override void OnCalculate()
        {
            ////we need more contrast
            //this.BarColor = Color.White;

            //calculate data
            ResultValue returnvalue = this.calculate(InSeries, Open, High, null, null, this.Bollinger_Period, this.Bollinger_Standard_Deviation, this.Momentum_Period, this.RSI_Period, this.RSI_Smooth, this.RSI_Level_Low, this.RSI_Level_High, this.Momentum_Level_Low, this.Momentum_Level_High);

            //If the calculate method was not finished we need to stop and show an alert message to the user.
            if (returnvalue.ErrorOccured)
            {
                //Display error just one time
                if (!this.ErrorOccured)
                {
                    GlobalUtilities.DrawAlertTextOnChart(this, Const.DefaultStringErrorDuringCalculation);
                    this.ErrorOccured = true;
                }
                return;
            }

            Plot_1.Set(bb_upper);
            Plot_2.Set(bb_middle);
            Plot_3.Set(bb_lower);

            //Entry
            if (returnvalue.Entry.HasValue)
            {
                switch (returnvalue.Entry)
                {
                case OrderDirection.Buy:
                    AddChartDot("ArrowLong_Entry" + Bars[0].Time.Ticks, true, Bars[0].Time, Bars[0].Open, Color.LightGreen);
                    //this.Indicator_Curve_Entry.Set(1);
                    break;

                case OrderDirection.Sell:
                    AddChartDiamond("ArrowShort_Entry" + Bars[0].Time.Ticks, true, Bars[0].Time, Bars[0].Open, Color.LightGreen);
                    //this.Indicator_Curve_Entry.Set(-1);
                    break;
                }
            }
            //else
            //{
            //    //Value was null so nothing to do.
            //    this.Indicator_Curve_Entry.Set(0);
            //}

            //Exit
            if (returnvalue.Exit.HasValue)
            {
                switch (returnvalue.Exit)
                {
                case OrderDirection.Buy:
                    AddChartDiamond("ArrowShort_Exit" + Bars[0].Time.Ticks, true, Bars[0].Time, Bars[0].Open, Color.Red);
                    //this.Indicator_Curve_Exit.Set(0.5);
                    break;

                case OrderDirection.Sell:
                    AddChartDot("ArrowLong_Exit" + Bars[0].Time.Ticks, true, Bars[0].Time, Bars[0].Open, Color.Red);
                    //this.Indicator_Curve_Exit.Set(-0.5);
                    break;
                }
            }
            //else
            //{
            //    //Value was null so nothing to do.
            //    this.Indicator_Curve_Exit.Set(0);
            //}
        }