Example #1
0
        override protected void StrategyExecute()
        {
            PriceTwoSMARule smarule = new PriceTwoSMARule(data.Close, parameters[0], parameters[1]);

            int cutlosslevel = 5;
            Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[0], "min");
            Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[1], "max");
            Indicators.Fibonnanci fibo = Indicators.Fibonnanci.Series(data.Bars, parameters[1], "fibo");


            for (int idx = smarule.long_indicator.FirstValidValue; idx < smarule.long_indicator.Count; idx++)
            {
                if (smarule.isValid_forBuy(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                    info.Short_Resistance = max[idx];
                    info.Short_Support = min[idx];
                    info.Short_Target = fibo.Fibo23pc[idx];
                    info.Stop_Loss = data.Close[idx] * (1 - cutlosslevel / 100);
                    BuyAtClose(idx,info);
                }
                else
                    if (smarule.isValid_forSell(idx))
                    {
                        BusinessInfo info = new BusinessInfo();
                        info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                        info.Short_Resistance = max[idx];
                        info.Short_Support = min[idx];
                        info.Short_Target = fibo.Fibo23pc[idx];
                        info.Stop_Loss = data.Close[idx] * (1 - cutlosslevel / 100);
                        SellAtClose(idx,info);
                    }
            }
        }
Example #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;
 }
Example #3
0
 override protected void StrategyExecute()
 {
     PriceTwoSMARule smarule = new PriceTwoSMARule(data.Close, parameters[0], parameters[1]);
     for (int idx = smarule.long_indicator.FirstValidValue; idx < smarule.long_indicator.Count; idx++)
     {
         if (smarule.isValid_forBuy(idx))
             BuyAtClose(idx);
         else
         if (smarule.isValid_forSell(idx))
             SellAtClose(idx);
     }
 }
Example #4
0
        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;
        }
Example #5
0
        override protected void StrategyExecute()
        {
            PriceTwoSMARule smarule = new PriceTwoSMARule(data.Close, parameters[0], parameters[1]);

            for (int idx = smarule.long_indicator.FirstValidValue; idx < smarule.long_indicator.Count; idx++)
            {
                if (smarule.isValid_forBuy(idx))
                {
                    BuyAtClose(idx);
                }
                else
                if (smarule.isValid_forSell(idx))
                {
                    SellAtClose(idx);
                }
            }
        }
Example #6
0
        override protected void StrategyExecute()
        {
            PriceTwoSMARule smarule = new PriceTwoSMARule(data.Close, parameters[0], parameters[1]);

            int cutlosslevel = 5;

            Indicators.MIN        min  = Indicators.MIN.Series(data.Close, parameters[0], "min");
            Indicators.MAX        max  = Indicators.MAX.Series(data.Close, parameters[1], "max");
            Indicators.Fibonnanci fibo = Indicators.Fibonnanci.Series(data.Bars, parameters[1], "fibo");


            for (int idx = smarule.long_indicator.FirstValidValue; idx < smarule.long_indicator.Count; idx++)
            {
                if (smarule.isValid_forBuy(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                    info.Short_Resistance = max[idx];
                    info.Short_Support    = min[idx];
                    info.Short_Target     = fibo.Fibo23pc[idx];
                    info.Stop_Loss        = data.Close[idx] * (1 - cutlosslevel / 100);
                    BuyAtClose(idx, info);
                }
                else
                if (smarule.isValid_forSell(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                    info.Short_Resistance = max[idx];
                    info.Short_Support    = min[idx];
                    info.Short_Target     = fibo.Fibo23pc[idx];
                    info.Stop_Loss        = data.Close[idx] * (1 - cutlosslevel / 100);
                    SellAtClose(idx, info);
                }
            }
        }