Esempio n. 1
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "HeikenAshiPullbacks";
                Calculate                    = Calculate.OnBarClose;
                EntriesPerDirection          = 1;
                EntryHandling                = EntryHandling.AllEntries;
                IsExitOnSessionCloseStrategy = true;
                ExitOnSessionCloseSeconds    = 30;
                IsFillLimitOnTouch           = false;
                MaximumBarsLookBack          = MaximumBarsLookBack.TwoHundredFiftySix;
                OrderFillResolution          = OrderFillResolution.Standard;
                Slippage                     = 0;
                StartBehavior                = StartBehavior.WaitUntilFlat;
                TimeInForce                  = TimeInForce.Gtc;
                TraceOrders                  = false;
                RealtimeErrorHandling        = RealtimeErrorHandling.StopCancelClose;
                StopTargetHandling           = StopTargetHandling.PerEntryExecution;
                BarsRequiredToTrade          = 20;
                ProfitTicks                  = 3;
                StopLossTicks                = 8;
                TrendStrength                = 5;
                InitialQuantity              = 2;
                LetItRideQuantity            = 1;
                TrailingBarsStop             = 3;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;
            }
            else if (State == State.Configure)
            {
                AddDataSeries(Data.BarsPeriodType.Second, 1);

                autoTrend = AutoTrendHNT8(false, this.TrendStrength, true, false, 60, Brushes.DarkRed, Brushes.Chartreuse, Brushes.DarkRed, Brushes.Chartreuse);
                AddChartIndicator(autoTrend);

                swing = Swing(this.TrendStrength);
                AddChartIndicator(swing);

                momentum = Momentum(14);
                AddChartIndicator(momentum);

                stochasticsFast_14_3 = EnhancedStochasticsFast(3, 14, Brushes.Chartreuse, Brushes.Transparent, true, 1);
                AddChartIndicator(stochasticsFast_14_3);

                greenBarStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.GreenBar, 0, 0);
                AddChartIndicator(greenBarStick);

                redBarStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.RedBar, 0, 0);
                AddChartIndicator(redBarStick);

                List <DisasbleTimeRange> disableTimeRanges = new List <DisasbleTimeRange>();
                disableTimeRanges.Add(new DisasbleTimeRange()
                {
                    Day = DayOfWeek.Monday, StartHour = 6, StartMinute = 0, EndHour = 18, EndMinute = 00
                });

                foreach (DisasbleTimeRange d in disableTimeRanges)
                {
                    disableManager.AddRange(DayOfWeek.Sunday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Monday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Tuesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Wednesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Thursday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Friday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                }
            }
        }
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "DayTradingRockStar";
                Calculate                    = Calculate.OnBarClose;
                EntriesPerDirection          = 1;
                EntryHandling                = EntryHandling.AllEntries;
                IsExitOnSessionCloseStrategy = true;
                ExitOnSessionCloseSeconds    = 30;
                IsFillLimitOnTouch           = false;
                MaximumBarsLookBack          = MaximumBarsLookBack.TwoHundredFiftySix;
                OrderFillResolution          = OrderFillResolution.Standard;
                Slippage                     = 0;
                StartBehavior                = StartBehavior.WaitUntilFlat;
                TimeInForce                  = TimeInForce.Gtc;
                TraceOrders                  = false;
                RealtimeErrorHandling        = RealtimeErrorHandling.StopCancelClose;
                StopTargetHandling           = StopTargetHandling.PerEntryExecution;
                BarsRequiredToTrade          = 20;
                ProfitTicks                  = 3;
                StopLossTicks                = 5;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;
            }
            else if (State == State.Configure)
            {
                AddDataSeries(Data.BarsPeriodType.Second, 5);
                //AddDataSeries(Data.BarsPeriodType.Minute, 5);

                autoTrend = AutoTrendHNT8(false, 5, true, false, 60, Brushes.DarkRed, Brushes.Chartreuse, Brushes.DarkRed, Brushes.Chartreuse);
                AddChartIndicator(autoTrend);

                stochasticsFast_14_3 = EnhancedStochasticsFast(3, 14, Brushes.Chartreuse, Brushes.Transparent, true, 1);
                AddChartIndicator(stochasticsFast_14_3);

                //stochasticsFast_14_3_5min = StochasticsFast(BarsArray[2], 3, 14);
                //AddChartIndicator(stochasticsFast_14_3_5min);

                stochastics_60_10_1 = EnhancedStochastics(1, 60, 10, Brushes.Transparent, Brushes.DodgerBlue);
                AddChartIndicator(stochastics_60_10_1);

                stochasticsFast_40_4 = EnhancedStochasticsFast(4, 40, Brushes.Violet, Brushes.Transparent, false, 1);
                AddChartIndicator(stochasticsFast_40_4);

                stochasticsFast_9_3 = EnhancedStochasticsFast(3, 9, Brushes.DarkRed, Brushes.Transparent, false, 1);
                AddChartIndicator(stochasticsFast_9_3);

                ema20 = EMA(20);
                ema20.Plots[0].Brush = Brushes.Green;
                AddChartIndicator(ema20);

                ema50 = EMA(50);
                ema50.Plots[0].Brush = Brushes.DodgerBlue;
                AddChartIndicator(ema50);

                ema200 = EMA(200);
                ema200.Plots[0].Brush = Brushes.Red;
                AddChartIndicator(ema200);

                greenBarStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.GreenBar, 0, 0);
                AddChartIndicator(greenBarStick);

                redBarStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.RedBar, 0, 0);
                AddChartIndicator(redBarStick);

                fiftyHammerStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.FiftyHammer, 0, 0);
                AddChartIndicator(fiftyHammerStick);

                fiftyManStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.FiftyMan, 0, 0);
                AddChartIndicator(fiftyManStick);

                bigBarStick = GuerillaStickSimple(Brushes.Transparent, Brushes.Transparent, GuerillaChartPattern.BigBar, 0, 0);
                AddChartIndicator(bigBarStick);

                List <DisasbleTimeRange> disableTimeRanges = new List <DisasbleTimeRange>();
                disableTimeRanges.Add(new DisasbleTimeRange()
                {
                    Day = DayOfWeek.Monday, StartHour = 0, StartMinute = 0, EndHour = 9, EndMinute = 59
                });
                disableTimeRanges.Add(new DisasbleTimeRange()
                {
                    Day = DayOfWeek.Monday, StartHour = 12, StartMinute = 30, EndHour = 24, EndMinute = 59
                });

                foreach (DisasbleTimeRange d in disableTimeRanges)
                {
                    disableManager.AddRange(DayOfWeek.Sunday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Monday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Tuesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Wednesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Thursday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Friday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                }
            }
        }