protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"ThaAdxRideTheTrend";
                Name                         = "ThaAdxRideTheTrend";
                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;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;

                TradingAccountId           = 0;
                ExitPeriod                 = 3;
                AdxPeriod                  = 14;
                MinAdx                     = 25;
                ExitSlopeThreshold         = -15;
                UseBoundaryHours           = true;
                StartHour                  = 7;
                StartMinute                = 30;
                EndHour                    = 12;
                EndMinute                  = 30;
                LossExitTicks              = 8;
                EnterPeriod                = 3;
                EnterSlopeThreshold        = 20;
                RecordHistoricalTrades     = false;
                EnterBarsLength            = 2;
                ExitBarsLength             = 2;
                EnterViaLimit              = true;
                EnterViaStop               = true;
                ExitStopBuffer             = 2;
                ExitLimitBuffer            = 2;
                Quantity                   = 2;
                MinTickRange               = 8;
                FireSns                    = false;
                MinTrendLength             = 1;
                TargetDollars              = 0;
                TrailingStopMinDollars     = 0;
                TrailingStopDivisorDollars = 0;
                TrailingStopCushionDollars = 0;
                OverrideRealTimeOnly       = false;
            }
            else if (State == State.Configure)
            {
                //SetOrderQuantity = SetOrderQuantity.DefaultQuantity;

                trailingStopEnabled = TrailingStopMinDollars > 0;

                if (trailingStopEnabled)
                {
                    AddDataSeries(BarsPeriodType.Tick, 300);
                }

                tickCounter = TickCounter(true, false);
                AddChartIndicator(tickCounter);

                rangeIndicator = MyRange(14, MinTickRange);
                //AddChartIndicator(rangeIndicator);

                adxIndicator = EnhancedADX(AdxPeriod, MinAdx);
                AddChartIndicator(adxIndicator);

                if (EnterPeriod > 1)
                {
                    enterAdxSlopeIndicator = AdxSlope(AdxPeriod, EnterPeriod, EnterSlopeThreshold);
                    AddChartIndicator(enterAdxSlopeIndicator);
                }

                if (ExitPeriod > 1)
                {
                    exitAdxSlopeIndicator = AdxSlope(AdxPeriod, ExitPeriod, ExitSlopeThreshold);
                    //AddChartIndicator(exitAdxSlopeIndicator);
                }

                disableManager.AddRange(DayOfWeek.Monday, 6, 25, 6, 50);
                disableManager.AddRange(DayOfWeek.Tuesday, 6, 25, 6, 50);
                disableManager.AddRange(DayOfWeek.Wednesday, 6, 25, 6, 50);
                disableManager.AddRange(DayOfWeek.Thursday, 6, 25, 6, 50);
                disableManager.AddRange(DayOfWeek.Friday, 6, 25, 6, 50);

                //                disableManager.AddRange(DayOfWeek.Sunday, 15, 45, 24, 0);
                //                disableManager.AddRange(DayOfWeek.Monday, 15, 45, 24, 0);
                //                disableManager.AddRange(DayOfWeek.Tuesday, 15, 45, 24, 0);
                //                disableManager.AddRange(DayOfWeek.Wednesday, 15, 45, 24, 0);
                //                disableManager.AddRange(DayOfWeek.Thursday, 15, 45, 24, 0);
                //                disableManager.AddRange(DayOfWeek.Friday, 15, 45, 24, 0);
            }
            else if (State == State.DataLoaded)
            {
            }
        }
Esempio n. 2
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"ThaAdxFixed";
                Name                         = "ThaAdxFixed";
                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;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;

                TradingAccountId       = 0;
                AdxPeriod              = 14;
                MinAdx                 = 25;
                UseBoundaryHours       = true;
                StartHour              = 7;
                StartMinute            = 30;
                EndHour                = 12;
                EndMinute              = 30;
                EnterPeriod            = 3;
                EnterSlopeThreshold    = 20;
                RecordHistoricalTrades = false;
                EnterBarsLength        = 2;
                ExitStopBuffer         = 2;
                ExitLimitBuffer        = 2;
                Quantity               = 1;
                UseDynamicQuantity     = false;
                MaxDynamicQuantity     = 5;
                Contrarian             = false;
            }
            else if (State == State.Configure)
            {
                SetProfitTarget(CalculationMode.Ticks, this.ExitLimitBuffer);
                SetStopLoss(CalculationMode.Ticks, this.ExitStopBuffer);
                //SetOrderQuantity = SetOrderQuantity.DefaultQuantity;

                adxIndicator = EnhancedADX(AdxPeriod, MinAdx);
                AddChartIndicator(adxIndicator);

                if (EnterPeriod > 1)
                {
                    enterAdxSlopeIndicator = AdxSlope(AdxPeriod, EnterPeriod, EnterSlopeThreshold);
                    //AddChartIndicator(enterAdxSlopeIndicator);
                }

                rangeIndicator = MyRange(EnterBarsLength, 3);
                //AddChartIndicator(rangeIndicator);

                disableManager.AddRange(DayOfWeek.Sunday, 13, 30, 24, 0);
                disableManager.AddRange(DayOfWeek.Monday, 13, 30, 24, 0);
                disableManager.AddRange(DayOfWeek.Tuesday, 13, 30, 24, 0);
                disableManager.AddRange(DayOfWeek.Wednesday, 13, 30, 24, 0);
                disableManager.AddRange(DayOfWeek.Thursday, 13, 30, 24, 0);
                disableManager.AddRange(DayOfWeek.Friday, 13, 30, 24, 0);


                disableManager.AddRange(DayOfWeek.Monday, 0, 0, 5, 0);
                disableManager.AddRange(DayOfWeek.Tuesday, 0, 0, 5, 0);
                disableManager.AddRange(DayOfWeek.Wednesday, 0, 0, 5, 0);
                disableManager.AddRange(DayOfWeek.Thursday, 0, 0, 5, 0);
                disableManager.AddRange(DayOfWeek.Friday, 0, 0, 5, 0);
            }
            else if (State == State.DataLoaded)
            {
            }
        }
Esempio n. 3
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "ThaAdxOneBar";
                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;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;

                TradingAccountId       = 0;
                ExitPeriod             = 3;
                AdxPeriod              = 14;
                MinAdx                 = 25;
                ExitSlopeThreshold     = -15;
                UseBoundaryHours       = true;
                StartHour              = 7;
                StartMinute            = 30;
                EndHour                = 12;
                EndMinute              = 30;
                LossExitTicks          = 8;
                EnterPeriod            = 3;
                EnterSlopeThreshold    = 20;
                RecordHistoricalTrades = false;
                EnterBarsLength        = 2;
                ExitBarsLength         = 2;
                EnterViaLimit          = true;
                EnterViaStop           = true;
                ExitStopBuffer         = 2;
                ExitLimitBuffer        = 2;
                Quantity               = 2;
                MinTickRange           = 8;
//                FastMaPeriod = 5;
//                SlowMaPeriod = 10;
//                MinMaDiff = 0.4;
            }
            else if (State == State.Configure)
            {
                //SetOrderQuantity = SetOrderQuantity.DefaultQuantity;

                adxIndicator = EnhancedADX(AdxPeriod, MinAdx);
                AddChartIndicator(adxIndicator);

                if (EnterPeriod > 1)
                {
                    enterAdxSlopeIndicator = AdxSlope(AdxPeriod, EnterPeriod, EnterSlopeThreshold);
                    //AddChartIndicator(enterAdxSlopeIndicator);
                }

                if (ExitPeriod > 1)
                {
                    exitAdxSlopeIndicator = AdxSlope(AdxPeriod, ExitPeriod, ExitSlopeThreshold);
                    //AddChartIndicator(exitAdxSlopeIndicator);
                }

                rangeIndicator = MyRange(EnterBarsLength, MinTickRange);
                //AddChartIndicator(rangeIndicator);

                disableManager.AddRange(DayOfWeek.Sunday, 12, 45, 24, 0);
                disableManager.AddRange(DayOfWeek.Monday, 12, 45, 24, 0);
                disableManager.AddRange(DayOfWeek.Tuesday, 12, 45, 24, 0);
                disableManager.AddRange(DayOfWeek.Wednesday, 12, 45, 24, 0);
                disableManager.AddRange(DayOfWeek.Thursday, 12, 45, 24, 0);
                disableManager.AddRange(DayOfWeek.Friday, 12, 45, 24, 0);


//                disableManager.AddRange(DayOfWeek.Monday, 0, 0, 5, 0);
//                disableManager.AddRange(DayOfWeek.Tuesday, 0, 0, 5, 0);
//                disableManager.AddRange(DayOfWeek.Wednesday, 0, 0, 5, 0);
//                disableManager.AddRange(DayOfWeek.Thursday, 0, 0, 5, 0);
//                disableManager.AddRange(DayOfWeek.Friday, 0, 0, 5, 0);


                //disableManager.AddRange(DayOfWeek.Monday, 6, 30, 6, 45);
                //disableManager.AddRange(DayOfWeek.Tuesday, 6, 30, 6, 45);
                //disableManager.AddRange(DayOfWeek.Wednesday, 6, 30, 6, 45);
                //disableManager.AddRange(DayOfWeek.Thursday, 6, 30, 6, 45);
                //disableManager.AddRange(DayOfWeek.Friday, 6, 30, 6, 45);

                //				fastMaIndicator = EMA(FastMaPeriod);
                //                slowMaIndicator = EMA(SlowMaPeriod);

                //                slowMaIndicator.Plots[0].Brush = Brushes.White;
                //                slowMaIndicator.Plots[0].Width = 2;

                //                fastMaIndicator.Plots[0].Width = 2;

                //                AddChartIndicator(fastMaIndicator);
                //                AddChartIndicator(slowMaIndicator);
            }
            else if (State == State.DataLoaded)
            {
            }
        }
Esempio n. 4
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "ThaStrategy";
                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;
                DefaultQuantity              = 2;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = false;

                FastMaPeriod     = 10;
                SlowMaPeriod     = 20;
                TickRangePeriod  = 15;
                MinMaDiff        = 0.4;
                MaxMaDiff        = 10;
                MinTickRange     = 0;
                MaxTickRange     = 30;
                GoLong           = true;
                GoShort          = true;
                FireAlerts       = false;
                DiffXX           = 5;
                ProfitTarget     = 5;
                StopLoss         = 4;
                TradingAccountId = 0;
                Contrarian       = false;
                StartHour        = 6;
                StartMinute      = 45;
                EndHour          = 12;
                EndMinute        = 45;
            }
            else if (State == State.Configure)
            {
                SetProfitTarget(CalculationMode.Ticks, this.Contrarian ? this.StopLoss : this.ProfitTarget);
                SetStopLoss(CalculationMode.Ticks, this.Contrarian ? this.ProfitTarget : this.StopLoss);
                SetOrderQuantity = SetOrderQuantity.DefaultQuantity;

                fastMaIndicator = EMA(FastMaPeriod);
                slowMaIndicator = EMA(SlowMaPeriod);

                slowMaIndicator.Plots[0].Brush = Brushes.White;

                AddChartIndicator(fastMaIndicator);
                AddChartIndicator(slowMaIndicator);

                adxIndicator = EnhancedADX(14, 25);
                AddChartIndicator(adxIndicator);
            }
            else if (State == State.DataLoaded)
            {
                diffSeries    = new Series <double>(this);
                highLowSeries = new Series <double>(this);

                this.ResetOt();
            }
        }