Exemplo n.º 1
0
        /// <summary>
        /// Main function - robot Entry point
        /// </summary>
        protected override void Execute()
        {
            base.Execute();

            // Create sma
            smaPrice = new SMA(Bars.Close, priceMaPeriod.ValueInt, "Moving Average to smooth price volatility");
            PlotSeries(PricePane, smaPrice, Color.Green, LineStyle.Solid, 1);
            smaTrend = new SMA(Bars.Close, trendMaPeriod.ValueInt, "Trend Moving Average");
            PlotSeries(PricePane, smaTrend, Color.Brown, LineStyle.Solid, 1);

            for (int bar = 1; bar < Bars.Count; bar++)
            {
                // Calculate signal
                SignalType signal = GetSignal(bar);

                // Close opened
                if (IsLastPositionActive)
                {
                    // If isn't closed by stops
                    if (IsLastPositionActive)
                    {
                        //CheckStops(bar);

                        // Close long if go below low level
                        if (LastPosition.PositionType == PositionType.Long
                            && signal == SignalType.Sell)
                        {
                            ExitAtMarket(bar + 1, LastPosition, "Sell signal");
                            ShortAtMarket(bar + 1, "Sell signal");
                        }
                        // Close short if go upper high level
                        else if (LastPosition.PositionType == PositionType.Short
                            && signal == SignalType.Buy)
                        {
                            ExitAtMarket(bar + 1, LastPosition, "Buy signal");
                            BuyAtMarket(bar + 1, "Buy signal");
                        }
                    }
                }
                // Open new positions
                else //if(bar > 1)
                {
                    // Buy if go up more then deltaUp
                    if (signal == SignalType.Buy)
                    {
                        BuyAtMarket(bar + 1, "Buy signal");
                    }
                    else if (signal == SignalType.Sell)
                    {
                        ShortAtMarket(bar + 1, "Sell signal");
                    }
                }
            }

            if (IsLastPositionActive)
                ExitAtClose(Bars.Count - 1, LastActivePosition);
        }
Exemplo n.º 2
0
        public FractalGuruStrategy(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma = new SMA(barType, 30);

            Register(sma);
        }
Exemplo n.º 3
0
 public override void OnInitialize()
 {
     sma = new SMA(Bars.Close, slow);
     sma.IntervalDefault = IntervalDefault;
     percentR            = new IndicatorCommon();
     tema = new TEMA(Bars.Close, slow);
     AddIndicator(tema);
     AddIndicator(percentR);
     AddIndicator(sma);
 }
Exemplo n.º 4
0
        protected override void OnStrategyStart()
        {
            Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation");

            // Set up indicators.
            fastSMA = new SMA(Bars, FastSMALength);
            slowSMA = new SMA(Bars, SlowSMALength);

            AddGroups();
        }
Exemplo n.º 5
0
        public void SMA()
        {
            SMA sma = new SMA(5);

            sma.Load(Directory.GetCurrentDirectory() + "\\table.csv");
            SingleDoubleSerie serie = sma.Calculate();

            Assert.IsNotNull(serie);
            Assert.IsTrue(serie.Values.Count > 0);
        }
Exemplo n.º 6
0
        protected override void OnStrategyStart()
        {
            Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation");

            bbu = new BBU(Bars, Length, K);
            bbl = new BBL(Bars, Length, K);
            sma = new SMA(Bars, Length);

            AddGroups();
        }
Exemplo n.º 7
0
        public EMA63Breakout(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma = new SMA(barType, 30);

            Register(sma);
        }
Exemplo n.º 8
0
        public void SMA()
        {
            SMA sma = new SMA(5);

            sma.Load(csvPath);
            SingleDoubleSerie serie = sma.Calculate();

            Assert.NotNull(serie);
            Assert.True(serie.Values.Count > 0);
        }
Exemplo n.º 9
0
        public TrendLineTunnel(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma = new SMA(barType, 30);

            Register(sma);
        }
Exemplo n.º 10
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "LongTermAcd";
                Calculate                    = Calculate.OnBarClose;
                EntriesPerDirection          = 1;
                EntryHandling                = EntryHandling.AllEntries;
                IsExitOnSessionCloseStrategy = false;
                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          = 51;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;

                ShortTermPeriod        = 14;
                IntermediateTermPeriod = 30;
                LongTermPeriod         = 50;
            }
            else if (State == State.Configure)
            {
                AddDataSeries(BarsPeriodType.Minute, 1);
            }
            else if (State == State.DataLoaded)
            {
                todayPivotPriceSeries = new Series <double>(BarsArray[1]);

                pivotPrice = AcdDailyPivotPrice();
                AddChartIndicator(pivotPrice);

                shortTermMA = SMA(14);
                shortTermMA.Plots[0].Brush = shortTermBrush;
                AddChartIndicator(shortTermMA);

                intermediateTermMA = SMA(30);
                intermediateTermMA.Plots[0].Brush = intermediateTermBrush;
                AddChartIndicator(intermediateTermMA);

                longTermMA = SMA(50);
                longTermMA.Plots[0].Brush = longTermBrush;
                AddChartIndicator(longTermMA);

                sessionIterator = new Data.SessionIterator(BarsArray[1]);
            }
        }
Exemplo n.º 11
0
        private int _sdPeriod = 25;                                    // トライリングストップ用
        #endregion
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Cascade Trend Entry.";
                Name                         = "CascadeTrend";
                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;

                // パラメータの初期値をセット
                StepSize = 0.8;
                // インジケーターの出力設定
                AddPlot(Brushes.LightSteelBlue, "Cascade Line H"); // ライン
                AddPlot(Brushes.LightSteelBlue, "Cascade Line L"); // ライン
            }
            else if (State == State.Configure)
            {
                // Series
                _price = new Series <double>(this);
                _ma    = SMA(_price, 3);
                _atr   = new Series <double>(this);
                // Series<T>タイプのリスト
                _lines  = new List <Series <double> >();
                _trends = new List <Series <int> >();
                _trend  = new Series <int>(this);
                // Series<T>を 好きなだけ追加出来る。
                for (int i = 0; i < 6; i++)
                {
                    _lines.Add(new Series <double>(this));
                }
                for (int i = 0; i < 6; i++)
                {
                    _trends.Add(new Series <int>(this));
                }

                _atrAlpha = 2.0 / (_atrPeriod + 1.0);
            }
        }
Exemplo n.º 12
0
        public ChartColorManagerForm()
        {
            this.InitializeComponent();
            this.colorEditor.Init();
            this.AddProperty("ChartBackColor", "Back Color", this.chart.ChartBackColor);
            this.AddProperty("CanvasColor", "Fore Color", this.chart.CanvasColor);
            this.AddProperty("BorderColor", "Border", this.chart.BorderColor);
            this.AddProperty("SplitterColor", "Splitter", this.chart.SplitterColor);
            this.AddProperty("CandleUpColor", "Candle Up", this.chart.CandleUpColor);
            this.AddProperty("CandleDownColor", "Candle Down", this.chart.CandleDownColor);
            this.AddProperty("DefaultLineColor", "Line", this.chart.DefaultLineColor);
            this.AddProperty("VolumeColor", "Volume", this.chart.VolumeColor);
            this.AddProperty("DateTipRectangleColor", "DateTime Tip Area", this.chart.DateTipRectangleColor);
            this.AddProperty("DateTipTextColor", "DateTime Tip Text", this.chart.DateTipTextColor);
            this.AddProperty("ValTipRectangleColor", "Value Tip Area", this.chart.ValTipRectangleColor);
            this.AddProperty("ValTipTextColor", "Value Text Area", this.chart.ValTipTextColor);
            this.AddProperty("CrossColor", "Cross Color", this.chart.CrossColor);
            this.AddProperty("BottomAxisLabelColor", "Bottom Axis Label", this.chart.BottomAxisLabelColor);
            this.AddProperty("BottomAxisGridColor", "Bottom Axis Grid", this.chart.BottomAxisGridColor);
            this.AddProperty("RightAxisGridColor", "Right Axis Grid", this.chart.RightAxisGridColor);
            this.AddProperty("RightAxisTextColor", "Right Axis Text", this.chart.RightAxisTextColor);
            this.AddProperty("RightAxisMajorTicksColor", "Right Axis Major Ticks", this.chart.RightAxisMajorTicksColor);
            this.AddProperty("RightAxisMinorTicksColor", "Right Axis Minor Ticks", this.chart.RightAxisMinorTicksColor);
            this.AddProperty("ItemTextColor", "Transaction Text", this.chart.ItemTextColor);
            this.AddProperty("SelectedItemTextColor", "Selected Transaction Text", this.chart.SelectedItemTextColor);
            this.AddProperty("SelectedTransactionHighlightColor", "Selected Transaction Highlight", this.chart.SelectedTransactionHighlightColor);
            this.ltvColorProperties.Items[0].Selected = true;
            BarSeries barSeries = this.GenerateSeries();

            this.chart.Reset();
            this.chart.SetMainSeries((DoubleSeries)barSeries, true);
            this.chart.AddPad();
            SMA sma = new SMA((TimeSeries)barSeries, 14);

            sma.Name = "Line";
            this.chart.DrawDefaultColoredSeries((DoubleSeries)sma, 2, (SimpleDSStyle)0, SmoothingMode.AntiAlias);
            Instrument instrument = Activator.CreateInstance(typeof(Instrument), true) as Instrument;

            instrument.Symbol = "Symbol";
            Transaction transaction1 = new Transaction(((TimeSeries)barSeries).GetDateTime(barSeries.Count - 5), Side.Buy, 100.0, instrument, barSeries[barSeries.Count - 5].Low);
            Transaction transaction2 = new Transaction(((TimeSeries)barSeries).GetDateTime(barSeries.Count - 20), Side.Sell, 100.0, instrument, barSeries[barSeries.Count - 20].High);

            this.chart.DrawTransaction(transaction1, 0);
            this.chart.DrawTransaction(transaction2, 0);
            this.chart.EnsureVisible(transaction1);
            foreach (ChartColorTemplate template in Global.ChartManager.ColorTemplates.All.Values)
            {
                this.ltvTemplates.Items.Add((ListViewItem) new ChartColorTemplateViewItem(template));
            }
            if (this.ltvTemplates.Items.Count <= 0)
            {
                return;
            }
            this.ltvTemplates.Items[0].Selected = true;
        }
Exemplo n.º 13
0
        public MA28And100Trading(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            ema100 = new EMA(barType, 100);
            sma28  = new SMA(barType, 28);

            Register(ema100, sma28);
        }
Exemplo n.º 14
0
 public override void OnStrategyStart()
 {
     // set up the moving averages
     sma       = new SMA(Bars, SMALength);
     sma.Color = Color.Yellow;
     Draw(sma, 0);
     // set up bollinger bands
     bbl       = new BBL(Bars, SMALength, BBLOrder);
     bbl.Color = Color.Pink;
     Draw(bbl, 0);
 }
Exemplo n.º 15
0
        protected override void OnStrategyStart()
        {
            // Add money for current trading instrument's portfolio.
            Portfolio.Account.Deposit(Clock.DateTime, MoneyForInstrument, CurrencyId.USD, "Initial allocation");

            // Set up indicators.
            sma1 = new SMA(Bars, Length1);
            sma2 = new SMA(Bars, Length2);

            AddGroups();
        }
Exemplo n.º 16
0
        //===========================================================================================================
        // Monthly  Chart
        //-----------------------------------------------------------------------------------------------------------
        protected void monthlyChart(BarHistory bars)
        {
            // Simple Moving Averages
            PlotTimeSeriesLine(SMA.Series(bars.Close, 12), "SMA12", "Price", Color.Red, 1);
            PlotTimeSeriesLine(SMA.Series(bars.Close, 60), "SMA60", "Price", Color.Black, 1);

            //PricePane.LogScale = true;
            //VolumePane.LogScale = true;

            //show52WeeksHigh(12);
        }
Exemplo n.º 17
0
        public void TestMethod1()
        {
            //Входные данные
            //Создать 2 условия
            int index1 = 0, index2 = 0;
            int curIndex                 = 60;
            ParameterCondition par1      = ParameterCondition.PriceClose;
            ParameterCondition par2      = ParameterCondition.PriceOpen;
            Predicate          predicate = Predicate.Less;

            Condition cond = new Condition(index1, index2, par1, par2, null, null, 0.0, 0.0, predicate);

            int index1_ = 1, index2_ = 1;
            ParameterCondition par1_      = ParameterCondition.Indicator;
            ParameterCondition par2_      = ParameterCondition.Indicator;
            Predicate          predicate_ = Predicate.MoreEqual;
            Indicator          ind1       = new SMA(14);
            Indicator          ind2       = new SMA(28);

            Condition cond2 = new Condition(index1_, index2_, par1_, par2_, ind1, ind2, 0.0, 0.0, predicate_);


            //Накопить данные для индикаторов
            for (int i = 0; i < curIndex; i++)
            {
                ind1.update_value(i, instrument);
                ind2.update_value(i, instrument);
            }


            //Создать правило
            TradingRule rule = new TradingRule();

            rule.add_condition(cond);
            rule.add_condition(cond2);

            string          name     = "TestStrategy1";
            DateTime        dateTime = DateTime.Now;
            TradingStrategy strat    = new TradingStrategy(name);

            strat.add_rule(rule);
            strat.save_to_xml();

            controller.add_strategy(new CaretakerStrategy(strat));

            TradingStrategy strat1 = controller.get_strategy(name).Originator;

            File.Delete("Strategies\\TestStrategy1.xml");

            Assert.AreEqual(strat.Loaded &&
                            strat.Name == name &&
                            strat.DateOfChange == dateTime &&
                            strat.DateOfCreation == dateTime, true);
        }
Exemplo n.º 18
0
 public override void OnInitialize()
 {
     if (price == null)
     {
         price = Bars.Close;
     }
     sma = new SMA(price, period);
     sma.IntervalDefault   = IntervalDefault;
     sma.Drawing.IsVisible = false;
     AddIndicator(sma);
 }
Exemplo n.º 19
0
        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            sma = SMA(SMAPeriod);
            Add(sma);
            marketSma = SMA(Typical, MarketPeriod);
            Add(marketSma);

            AccountSize         = 20000;
            BarsRequired        = marketPeriod;
            CalculateOnBarClose = true;
        }
Exemplo n.º 20
0
        protected override void OnStrategyStart()
#endif
        {
            Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation");

            bbu = new BBU(Bars, Length, K);
            bbl = new BBL(Bars, Length, K);
            sma = new SMA(Bars, Length);

            AddGroups();
        }
Exemplo n.º 21
0
        public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
        {
            if (index >= (length - 1))
            {
                double num1 = input[index, barData];
                double num2 = SMA.Value(input, index, length, barData);
                return((num1 - num2) * 100.0 / num2);
            }

            return(double.NaN);
        }
Exemplo n.º 22
0
        public Simple5x5System(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma = new SMA(barType, 5);
            rsi = new RSI(barType, 5);

            Register(sma, rsi);
        }
Exemplo n.º 23
0
    //===========================================================================================================
    // Monthly Chart
    //-----------------------------------------------------------------------------------------------------------
    protected void monthlyChart()
    {
        // Simple Moving Averages
        PlotSeries(PricePane, SMA.Series(Close, 12), Color.Red, LineStyle.Solid, 1);
        PlotSeries(PricePane, SMA.Series(Close, 60), Color.Black, LineStyle.Solid, 1);

        PricePane.LogScale  = true;
        VolumePane.LogScale = true;

        //show52WeeksHigh(12);
    }
Exemplo n.º 24
0
        public override void OnStrategyStart()
        {
            LoadHistoricalBars(Clock.Now);

            BarSeries bars1min = GetBars(BarType.Time, BarSize);

            fastSMA = new SMA(bars1min, fastLength, Color.Red);
            slowSMA = new SMA(bars1min, slowLength, Color.Green);

            Draw(fastSMA, 0);
            Draw(slowSMA, 0);
        }
Exemplo n.º 25
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Lazy River Strategy based on TradingView strategy.";
                Name                         = "TfsLazyRiverV3";
                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;
                MaFastPeriod = 20;
                MaSlowPeriod = 50;
                MaLongPeriod = 200;
                DcPeriod     = 14;
                RiskFactor   = 1;
                TradeLong    = true;
                TradeShort   = false;
            }
            else if (State == State.Configure)
            {
            }
            else if (State == State.DataLoaded)
            {
                maFast = EMA(MaFastPeriod);
                maSlow = EMA(MaSlowPeriod);
                maLong = SMA(MaLongPeriod);
                dc     = DonchianChannel(DcPeriod);

                maFast.Plots[0].Brush = Brushes.SkyBlue;
                maSlow.Plots[0].Brush = Brushes.DodgerBlue;
                maLong.Plots[0].Brush = Brushes.Blue;
                dc.Plots[0].Brush     = Brushes.Beige;

                AddChartIndicator(maFast);
                AddChartIndicator(maSlow);
                AddChartIndicator(maLong);
                AddChartIndicator(dc);
            }
        }
Exemplo n.º 26
0
 private void CurrentDomain_UnhandledException(object sender,
                                               UnhandledExceptionEventArgs e)
 {
     try
     {
         SMA.OnException((Exception)e.ExceptionObject);
     }
     catch
     {
         // ignored
     }
 }
Exemplo n.º 27
0
        public void Indicators_MakeSma_For_Last_Five_Close()
        {
            IEnumerable <double> lastFiveClose = SMA.Close(MakeBars(), 5);

            Assert.AreEqual(6, lastFiveClose.Count());
            Assert.AreEqual(139605, lastFiveClose.ElementAt(0));
            Assert.AreEqual(139806, lastFiveClose.ElementAt(1));
            Assert.AreEqual(139915, lastFiveClose.ElementAt(2));
            Assert.AreEqual(139874, lastFiveClose.ElementAt(3));
            Assert.AreEqual(139941, lastFiveClose.ElementAt(4));
            Assert.AreEqual(140138, lastFiveClose.ElementAt(5));
        }
Exemplo n.º 28
0
        public BestOfMACD(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma10 = new SMA(barType, 10);
            sma50 = new SMA(barType, 50);
            macd  = new MACD(barType, 12, 16, 9);

            Register(sma10, sma50, macd);
        }
Exemplo n.º 29
0
        public SlowMovingMACrossover(BarItemType barType)
        {
            this.barType = barType;

            this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code);

            sma7  = new SMA(barType, 10);
            sma14 = new SMA(barType, 25);
            sma21 = new SMA(barType, 50);

            Register(sma7, sma14, sma21);
        }
Exemplo n.º 30
0
        public KST(int p1 = 10, int p2 = 15, int p3 = 20, int p4 = 30, int n = 10) : base(n)
        {
            ROC1 = new ROC(p1);
            ROC2 = new ROC(p2);
            ROC3 = new ROC(p3);
            ROC4 = new ROC(p4);

            SMA1 = new SMA(p1);
            SMA2 = new SMA(p2);
            SMA3 = new SMA(p3);
            SMA4 = new SMA(p4);
        }
Exemplo n.º 31
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "CesarSalad";
                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;
                RangeHighLow   = 7;
                RangeMA        = 100;
                RSIEntryLevel  = 15;
                RSIExitLevel   = 30;
                RSIPeriod      = 5;
                ATRPeriod      = 10;
                ATRMultiple    = 0.5;
                InitialCapital = 100000;
            }
            else if (State == State.Configure)
            {
                _rsi = RSI(this.RSIPeriod, 3);
                _rsi.Plots[1].Brush = Brushes.Brown;
                _rsi.Lines[0].Value = this.RSIEntryLevel;
                _rsi.Lines[1].Value = this.RSIExitLevel;
                base.AddChartIndicator(_rsi);

                _regime = SMA(this.RangeMA);
                _regime.Plots[0].Width = 3;
                _regime.Plots[0].Brush = Brushes.AliceBlue;
                base.AddChartIndicator(_regime);

                _atr = ATR(this.ATRPeriod);
                base.AddChartIndicator(_atr);

                base.ClearOutputWindow();
            }
        }
Exemplo n.º 32
0
        protected override void OnStrategyInit()
        {
            Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation");

            bars60    = new BarSeries("Bars60");
            bars86400 = new BarSeries("Bars86400");

            // Set up indicators.
            fastSMA = new SMA(bars60, FastSMALength);
            slowSMA = new SMA(bars60, SlowSMALength);

            AddGroups();
        }