Ejemplo n.º 1
0
 /// <summary>
 /// user change params
 /// пользователь изменил параметр
 /// </summary>
 void ArbitrageIndex_ParametrsChangeByUser()
 {
     _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
     _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
     _envelop.Save();
     _envelop.Reload();
 }
Ejemplo n.º 2
0
        public ArbitrageIndex(string name, StartProgram startProgram)
            : base(name, startProgram)
        {
            TabCreate(BotTabType.Index);
            _tabIndex = TabsIndex[0];
            _tabIndex.SpreadChangeEvent += _tabIndex_SpreadChangeEvent;
            _tabIndex.UserFormula        = "A0/A1";

            _envelop = new Envelops(name + "Envelop", false);
            _envelop = (Envelops)_tabIndex.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Save();

            TabCreate(BotTabType.Simple);
            _tab1 = TabsSimple[0];
            TabCreate(BotTabType.Simple);
            _tab2 = TabsSimple[1];

            _tab1.PositionOpeningSuccesEvent += _PositionOpeningSuccesEvent;
            _tab2.PositionOpeningSuccesEvent += _PositionOpeningSuccesEvent;


            Regime       = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyLong", "OnlyShort", "OnlyClosePosition" });
            DepoCurrency = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });

            minSpread = CreateParameter("minSpread", 0.4m, 0.1m, 3, 0.05m);
            minProfit = CreateParameter("minProfit", 0.3m, 0.1m, 3, 0.05m);

            Slippage = CreateParameter("Slipage", 0, 0, 20, 1);
            ParametrsChangeByUser += ArbitrageIndex_ParametrsChangeByUser;

            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 5m, 10, 0.3m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 5, 200, 5);

            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;

            VolumeDecimals1 = CreateParameter("Volume1 Decimals", 0, 0, 20, 1);
            VolumeDecimals2 = CreateParameter("Volume2 Decimals", 0, 0, 20, 1);

            MaDay1 = IndicatorsFactory.CreateIndicatorByName("Sma", name + "MaDay1", false);
            MaDay1 = (Aindicator)_tab1.CreateCandleIndicator(MaDay1, "Prime");
            MaDay1.ParametersDigit[0].Value = 24;
            MaDay1.Save();

            MaDay2 = IndicatorsFactory.CreateIndicatorByName("Sma", name + "MaDay2", false);
            MaDay2 = (Aindicator)_tab2.CreateCandleIndicator(MaDay2, "Prime");
            MaDay2.ParametersDigit[0].Value = 24;
            MaDay2.Save();
        }
Ejemplo n.º 3
0
        public EnvelopFlatBitmex(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;
            _tab.PositionClosingSuccesEvent += _tab_PositionClosingSuccesEvent;
            _envelop = new Envelops(name + "Envelop", false);
            _envelop = (Envelops)_tab.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Save();

            this.ParametrsChangeByUser += EnvelopTrendBitmex_ParametrsChangeByUser;
            Regime              = CreateParameter("Regime", "Off", new[] { "Off", "On" });
            Slippage            = CreateParameter("Slippage", 0, 0, 20, 1);
            Volume              = CreateParameter("Volume", 0.1m, 0.1m, 50, 0.1m);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 0.3m, 4, 0.1m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 10, 200, 5);
            TrailStop           = CreateParameter("Trail Stop", 0.1m, 0m, 5, 0.1m);
            MinProfitTraling    = CreateParameter("Минимальный профит для трэйлинга", 0.2m, 0.2m, 2, 0.1m);
            leverage            = CreateParameter("Маржинальное плечо", 0.1m, 0.1m, 10, 0.1m);
            MaxStop             = CreateParameter("MaxStop", 1, 1, 10, 0.1m);
            isContract          = CreateParameter("Торгуем контрактами", false);
            DepoCurrency        = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });

            VolMaFast = new MovingAverage(name + "VolMaFast", false)
            {
                ColorBase = System.Drawing.Color.Yellow, Lenght = 10, TypePointsToSearch = PriceTypePoints.Volume
            };
            VolMaFast        = (MovingAverage)_tab.CreateCandleIndicator(VolMaFast, "New1");
            VolMaFast.Lenght = (int)(EnvelopMovingLength.ValueInt);
            VolMaFast.Save();

            VolMaSlow = new MovingAverage(name + "VolMaSlow", false)
            {
                ColorBase = System.Drawing.Color.Green, TypePointsToSearch = PriceTypePoints.Volume
            };
            VolMaSlow        = (MovingAverage)_tab.CreateCandleIndicator(VolMaSlow, "New1");
            VolMaSlow.Lenght = (int)(VolMaFast.Lenght * 10);
            VolMaSlow.Save();

            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;

            CanTrade = false;
        }
Ejemplo n.º 4
0
        public EnvelopCountertrend(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;
            _tab.PositionClosingSuccesEvent += _tab_PositionClosingSuccesEvent;
            this.ParametrsChangeByUser      += EnvelopCountertrend_ParametrsChangeByUser;


            Regime              = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyClosePosition", "OnlyShort", "OnlyLong" });
            Slippage            = CreateParameter("Slippage", 0, 0, 20, 1);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 5m, 10, 0.3m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 5, 200, 5);


            leverage       = CreateParameter("Маржинальное плечо", 1m, 1m, 10, 0.1m);
            DepoCurrency   = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });
            isContract     = CreateParameter("Торгуем контрактами", false);
            MaxStop        = CreateParameter("MaxStop", 1, 25, 30, 0.1m);
            SmaLength      = CreateParameter("SmaLength", 10, 5, 150, 2);
            VolumeDecimals = CreateParameter("Volume Decimals", 0, 0, 20, 1);

            MinVolume   = CreateParameter("MinVolume", 1, 1, 10000, 0.0001m);
            MaxPosition = CreateParameter("Макс. открытых позиций", 1, 1, 10, 1);

            _sma        = new MovingAverage(name + "_sma", false);
            _sma        = (MovingAverage)_tab.CreateCandleIndicator(_sma, "Prime");
            _sma.Lenght = SmaLength.ValueInt;
            _sma.Save();

            _envelop                      = new Envelops(name + "Envelop", false);
            _envelop                      = (Envelops)_tab.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
            _envelop.Save();

            DeleteEvent += Strategy_DeleteEvent;

            Thread worker = new Thread(Logic);

            worker.IsBackground = true;
            worker.Start();
        }
Ejemplo n.º 5
0
        public MyTest(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;

            Regime              = CreateParameter("Regime", "Off", new[] { "Off", "On" });
            Slippage            = CreateParameter("Slippage %", 0, 0, 100, 0.1m);
            Volume              = CreateParameter("Volume", 0.1m, 0.1m, 50, 0.1m);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 0.2m, 10, 0.1m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 40, 10, 200, 5);
            TrailStop           = CreateParameter("Trail Stop %", 1, 0.1m, 100, 0.1m);

            _sma        = new LinearRegressionCurve(name + "LRC1", false);
            _sma        = (LinearRegressionCurve)_tab.CreateCandleIndicator(_sma, "Prime");
            _sma.Lenght = 8;
            _sma.Save();

            _envelop1 = new Envelops(name + "Envelop1", false);
            _envelop1 = (Envelops)_tab.CreateCandleIndicator(_envelop1, "Prime");
            _envelop1.Save();

            _envelop2 = new Envelops(name + "Envelop2", false);
            _envelop2 = (Envelops)_tab.CreateCandleIndicator(_envelop2, "Prime");
            _envelop2.Save();

            _envelop3 = new Envelops(name + "Envelop3", false);
            _envelop3 = (Envelops)_tab.CreateCandleIndicator(_envelop3, "Prime");
            _envelop3.Save();

            _envelop1.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop1.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
            //_envelop1.ColorUp = Color.Red;

            _envelop2.Deviation            = EnvelopDeviation.ValueDecimal * 2m;
            _envelop2.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;

            _envelop3.Deviation            = EnvelopDeviation.ValueDecimal * 3m;
            _envelop3.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;

            ParametrsChangeByUser += MyTest_ParametrsChangeByUser;
        }
Ejemplo n.º 6
0
        public EnvelopTrend(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;

            _envelop = new Envelops(name + "Envelop", false);
            _envelop = (Envelops)_tab.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Save();

            Regime              = CreateParameter("Regime", "Off", new[] { "Off", "On" });
            Slippage            = CreateParameter("Slippage", 0, 0, 20, 1);
            Volume              = CreateParameter("Volume", 0.1m, 0.1m, 50, 0.1m);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 0.3m, 4, 0.3m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 10, 200, 5);
            TrailStop           = CreateParameter("Trail Stop", 0.1m, 0.1m, 5, 0.1m);

            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
        }
Ejemplo n.º 7
0
        public EnvelopTrendBitmex(string name, StartProgram startProgram) : base(name, startProgram)
        {
            TabCreate(BotTabType.Simple);
            _tab = TabsSimple[0];

            _tab.CandleFinishedEvent        += _tab_CandleFinishedEvent;
            _tab.PositionOpeningSuccesEvent += _tab_PositionOpeningSuccesEvent;
            _tab.PositionClosingSuccesEvent += _tab_PositionClosingSuccesEvent;
            _envelop = new Envelops(name + "Envelop", false);
            _envelop = (Envelops)_tab.CreateCandleIndicator(_envelop, "Prime");
            _envelop.Save();

            _atr = new Atr(name + "ATR", false)
            {
                Lenght = 14, ColorBase = Color.DodgerBlue,
            };
            _atr.Save();

            this.ParametrsChangeByUser += EnvelopTrendBitmex_ParametrsChangeByUser;
            this.DeleteEvent           += Strategy_DeleteEvent;

            Regime   = CreateParameter("Regime", "Off", new[] { "Off", "On", "OnlyClosePosition", "OnlyShort", "OnlyLong" });
            RegimeML = CreateParameter("RegimeML", "Off", new[] { "Off", "Parser", "Client" });

            Slippage            = CreateParameter("Slippage", 0, 0, 20, 1);
            EnvelopDeviation    = CreateParameter("Envelop Deviation", 0.3m, 0.3m, 4, 0.1m);
            EnvelopMovingLength = CreateParameter("Envelop Moving Length", 10, 10, 200, 5);
            TrailStop           = CreateParameter("Trail Stop", 0.1m, 0m, 5, 0.1m);
            MinProfitTraling    = CreateParameter("Минимальный профит для трэйлинга", 0.2m, 0.2m, 2, 0.1m);
            leverage            = CreateParameter("Маржинальное плечо", 0.1m, 0.1m, 10, 0.1m);
            MaxStop             = CreateParameter("MaxStop", 1, 1, 10, 0.1m);
            isContract          = CreateParameter("Торгуем контрактами", false);
            DepoCurrency        = CreateParameter("DepoCurrency", "Currency2", new[] { "Currency1", "Currency2" });
            VolumeDecimals      = CreateParameter("Volume Decimals", 0, 0, 20, 1);

            FastMA = new MovingAverage(name + "FastMA", false)
            {
                ColorBase = System.Drawing.Color.Yellow, Lenght = 15, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            FastMA        = (MovingAverage)_tab.CreateCandleIndicator(FastMA, "Prime");
            FastMA.Lenght = 15;
            FastMA.Save();

            SlowMA = new MovingAverage(name + "SlowMA", false)
            {
                ColorBase = System.Drawing.Color.Blue, Lenght = 30, TypePointsToSearch = PriceTypePoints.Close, TypeCalculationAverage = MovingAverageTypeCalculation.Simple
            };
            SlowMA        = (MovingAverage)_tab.CreateCandleIndicator(SlowMA, "Prime");
            SlowMA.Lenght = 30;
            SlowMA.Save();

            _envelop.Deviation            = EnvelopDeviation.ValueDecimal;
            _envelop.MovingAverage.Lenght = EnvelopMovingLength.ValueInt;
            _name = name;

            #region ML Region
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            Load();
            if (RegimeML.ValueString != "Off") // создаем файл(ы) если несуществуют и очищаем если существуют
            {
                initML();
            }
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            #endregion
        }