コード例 #1
0
        override protected void StrategyExecute()
        {
            int fast_macd = (int)parameters[0];
            int slow_macd = (int)parameters[1];
            int signal_macd = (int)parameters[2];

            int rsi_period = (int)parameters[3];
            int RSI_LOWER_LEVEL = (int)parameters[4];
            int RSI_UPPER_LEVEL = (int)parameters[5];
            int cutlosslevel = (int)parameters[6];
            int takeprofitlevel = (int)parameters[7];

            MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd);
            BasicRSI_Rule rsirule = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL);
            
            TwoSMARule rule = new TwoSMARule(rsirule.rsi, 5,10);

            for (int idx = 1; idx < data.Close.Count; idx++)
            {
                //if (rsirule.isValid_forBuy(idx) && macdrule.isValid_forBuy(idx))
                //    BuyAtClose(idx);
                //if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx))
                //    SellAtClose(idx);
                if (rule.isValid_forBuy(idx)&&
                    macdrule.isValid_forBuy(idx))
                        BuyAtClose(idx);
                if (rule.isValid_forSell(idx) || macdrule.isValid_forSell(idx))
                    SellAtClose(idx);
                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                    SellCutLoss(idx);
                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                    SellTakeProfit(idx);
            }            
        }
コード例 #2
0
 public HybridTestRules(DataBars db, double atrperiod, double shortperiod, double longperiod)
 {
     rules    = new Rule[2];
     rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod);
     rules[1] = new BasicATRRule(db, atrperiod, "atr");
     adxTrend = new ADXMarketTrend(db, 14);
     //Kiem tra volume
     volumeRule    = new PriceTwoSMARule(db.Volume, 10, 30);
     data          = db;
     Volume_Filter = 50000;
 }
コード例 #3
0
ファイル: TwoMA.cs プロジェクト: oghenez/trade-software
        override protected void StrategyExecute()
        {
            TwoSMARule rule = new TwoSMARule(data.Close, parameters[0], parameters[1]);

            if (rule.isValid())
            {
                int          Bar  = data.Close.Count - 1;
                BusinessInfo info = new BusinessInfo();
                info.Weight = rule.short_indicator[Bar];
                SelectStock(Bar, info);
            }
        }
コード例 #4
0
ファイル: HybridTest.cs プロジェクト: oghenez/trade-software
        public HybridTestRules(DataBars db, double atrperiod, double shortperiod, double longperiod)
        {
            rules = new Rule[3];
            rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod);
            rules[1] = new BasicATRRule(db, atrperiod, "atr");
            rules[2] = new BasicMACDRule(db.Close, 12, 26, 9);

            adxTrend = new ADXMarketTrend(db, 14);
            //Kiem tra volume
            volumeRule = new PriceTwoSMARule(db.Volume, 10, 30);
            data = db;
            Volume_Filter = 50000;
        }
コード例 #5
0
ファイル: TwoMA.cs プロジェクト: oghenez/trade-software
        override protected void StrategyExecute()
        {
            TwoSMARule rule = new TwoSMARule(data.Close, parameters[0], parameters[1]);

            for (int idx = 0; idx < data.Close.Count; idx++)
            {
                if (rule.isValid_forBuy(idx))
                    BuyAtClose(idx);
                else
                    if (rule.isValid_forSell(idx))
                        SellAtClose(idx);
            }
        }
コード例 #6
0
ファイル: HybridSAR.cs プロジェクト: oghenez/trade-software
        override protected void StrategyExecute()
        {
            BasicSARRule sarRule = new BasicSARRule(data.Bars, parameters[0], parameters[1]);
            TwoSMARule   smarule = new TwoSMARule(data.Close, parameters[2], parameters[3]);

            //BasicDMIRule dmiRule = new BasicDMIRule(data.Bars, 14, 14);
            Indicators.ADX adx = new Indicators.ADX(data.Bars, 14, "");

            int cutlosslevel    = (int)parameters[4];
            int takeprofitlevel = (int)parameters[5];

            Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[3], "min");
            Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[3], "max");

            for (int idx = 0; idx < data.Close.Count - 1; idx++)
            {
                if (adx[idx] > 25)
                {
                    if ((!is_bought) && ((sarRule.isValid_forBuy(idx) && smarule.UpTrend(idx))))
                    //if (dmiRule.isValid_forBuy(idx)&&sarRule.isValid_forBuy(idx))
                    {
                        BusinessInfo info = new BusinessInfo();
                        info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                        info.Short_Target = max[idx];
                        info.Stop_Loss    = min[idx];
                        BuyAtClose(idx, info);
                    }
                }
                if (is_bought && (sarRule.isValid_forSell(idx) || smarule.isValid_forSell(idx)))
                //if (dmiRule.isValid_forSell(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Downward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                    info.Short_Target = min[idx];
                    info.Stop_Loss    = max[idx];
                    SellAtClose(idx, info);
                }

                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                {
                    SellCutLoss(idx);
                }

                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                {
                    SellTakeProfit(idx);
                }
            }
        }
コード例 #7
0
ファイル: TwoMA.cs プロジェクト: oghenez/trade-software
        override protected void StrategyExecute()
        {
            TwoSMARule rule = new TwoSMARule(data.Close, parameters[0], parameters[1]);

            for (int idx = 0; idx < data.Close.Count; idx++)
            {
                if (rule.isValid_forBuy(idx))
                {
                    BuyAtClose(idx);
                }
                else
                if (rule.isValid_forSell(idx))
                {
                    SellAtClose(idx);
                }
            }
        }
コード例 #8
0
ファイル: HybridSAR.cs プロジェクト: oghenez/trade-software
        override protected void StrategyExecute()
        {
            BasicSARRule sarRule = new BasicSARRule(data.Bars, parameters[0], parameters[1]);
            TwoSMARule smarule = new TwoSMARule(data.Close, parameters[2], parameters[3]);
            //BasicDMIRule dmiRule = new BasicDMIRule(data.Bars, 14, 14);
            Indicators.ADX adx = new Indicators.ADX(data.Bars, 14, "");

            int cutlosslevel = (int)parameters[4];
            int takeprofitlevel = (int)parameters[5];

            Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[3], "min");
            Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[3], "max");

            for (int idx = 0; idx < data.Close.Count - 1; idx++)
            {
                if (adx[idx] > 25)
                {
                    if ((!is_bought) && ((sarRule.isValid_forBuy(idx) && smarule.UpTrend(idx))))
                    //if (dmiRule.isValid_forBuy(idx)&&sarRule.isValid_forBuy(idx))
                    {
                        BusinessInfo info = new BusinessInfo();
                        info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                        info.Short_Target = max[idx];
                        info.Stop_Loss = min[idx];
                        BuyAtClose(idx, info);
                    }
                }
                if (is_bought && (sarRule.isValid_forSell(idx) || smarule.isValid_forSell(idx)))
                //if (dmiRule.isValid_forSell(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Downward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                    info.Short_Target = min[idx];
                    info.Stop_Loss = max[idx];
                    SellAtClose(idx, info);
                }

                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                    SellCutLoss(idx);

                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                    SellTakeProfit(idx);
            }
        }
コード例 #9
0
        override protected void StrategyExecute()
        {
            int fast_macd   = (int)parameters[0];
            int slow_macd   = (int)parameters[1];
            int signal_macd = (int)parameters[2];

            int rsi_period      = (int)parameters[3];
            int RSI_LOWER_LEVEL = (int)parameters[4];
            int RSI_UPPER_LEVEL = (int)parameters[5];
            int cutlosslevel    = (int)parameters[6];
            int takeprofitlevel = (int)parameters[7];

            MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd);
            BasicRSI_Rule      rsirule  = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL);

            TwoSMARule rule = new TwoSMARule(rsirule.rsi, 5, 10);

            for (int idx = 1; idx < data.Close.Count; idx++)
            {
                //if (rsirule.isValid_forBuy(idx) && macdrule.isValid_forBuy(idx))
                //    BuyAtClose(idx);
                //if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx))
                //    SellAtClose(idx);
                if (rule.isValid_forBuy(idx) &&
                    macdrule.isValid_forBuy(idx))
                {
                    BuyAtClose(idx);
                }
                if (rule.isValid_forSell(idx) || macdrule.isValid_forSell(idx))
                {
                    SellAtClose(idx);
                }
                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                {
                    SellCutLoss(idx);
                }
                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                {
                    SellTakeProfit(idx);
                }
            }
        }
コード例 #10
0
ファイル: HybridATR.cs プロジェクト: oghenez/trade-software
 public SMAATRRules(DataBars db, double atrperiod, double shortperiod, double longperiod)
 {
     rules = new Rule[2];
     rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod);
     rules[1] = new BasicATRRule(db, atrperiod, "atr");
 }
コード例 #11
0
ファイル: MACD_Hybrid.cs プロジェクト: oghenez/trade-software
 public TwoSMABasicMACDRule(DataSeries ds, double fast, double slow, double signal, double shortperiod, double longperiod)
 {
     rules    = new Rule[2];
     rules[0] = new BasicMACDRule(ds, (int)fast, (int)slow, (int)signal);
     rules[1] = new TwoSMARule(ds, shortperiod, longperiod);
 }
コード例 #12
0
ファイル: MACD_Hybrid.cs プロジェクト: oghenez/trade-software
 public TwoSMABasicMACDRule(DataSeries ds, double fast, double slow, double signal, double shortperiod, double longperiod)
 {
     rules = new Rule[2];
     rules[0] = new BasicMACDRule(ds, (int)fast,(int)slow,(int)signal);
     rules[1] = new TwoSMARule(ds, shortperiod, longperiod);
 }
コード例 #13
0
ファイル: TwoMA.cs プロジェクト: oghenez/trade-software
 override protected void StrategyExecute()
 {
     TwoSMARule rule = new TwoSMARule(data.Close, parameters[0], parameters[1]);
     if (rule.isValid())
     {
         int Bar = data.Close.Count - 1;
         BusinessInfo info = new BusinessInfo();
         info.Weight = rule.short_indicator[Bar];
         SelectStock(Bar, info);
     }
 }
コード例 #14
0
 public SMAATRRules(DataBars db, double atrperiod, double shortperiod, double longperiod)
 {
     rules    = new Rule[2];
     rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod);
     rules[1] = new BasicATRRule(db, atrperiod, "atr");
 }