Esempio n. 1
0
        override protected void StrategyExecute()
        {
            HybridTestRules rule              = new HybridTestRules(data.Bars, parameters[0], parameters[1], parameters[2]);
            int             cutlosslevel      = (int)parameters[3];
            int             trailingstoplevel = (int)parameters[4];
            int             takeprofitlevel   = (int)parameters[5];

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

            Indicators.Fibonnanci fibo = Indicators.Fibonnanci.Series(data.Bars, parameters[1], "fibo");


            //    public double Short_Resistance;
            //public double Short_Support;
            //public double Short_Target;
            //public AppTypes.MarketTrend ShortTermTrend;
            //public double Stop_Loss;
            for (int idx = 1; idx < data.Close.Count; idx++)
            {
                if (rule.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 (rule.isValid_forSell(idx))
                {
                    BusinessInfo info = new BusinessInfo();
                    info.SetTrend(AppTypes.MarketTrend.Downward, 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);
                }
                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                {
                    SellCutLoss(idx);
                }

                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                {
                    SellTakeProfit(idx);
                }

                if (trailingstoplevel > 0)
                {
                    TrailingStopWithBuyBack(rule, data.Close[idx], trailingstoplevel, idx);
                }
            }
        }
Esempio n. 2
0
        protected override void StrategyExecute()
        {
            HybridTestRules rule              = new HybridTestRules(data.Bars, parameters[0], parameters[1], parameters[2]);
            int             cutlosslevel      = (int)parameters[3];
            int             trailingstoplevel = (int)parameters[4];
            int             takeprofitlevel   = (int)parameters[5];
            int             Bar = data.Close.Count - 1;

            if (rule.isValid_forBuy(Bar))
            {
                BusinessInfo info = new BusinessInfo();
                info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
                info.Weight = data.Close[Bar];
                SelectStock(Bar, info);
            }
        }
Esempio n. 3
0
 protected override void StrategyExecute()
 {
     HybridTestRules rule = new HybridTestRules(data.Bars, parameters[0], parameters[1], parameters[2]);
     int cutlosslevel = (int)parameters[3];
     int trailingstoplevel = (int)parameters[4];
     int takeprofitlevel = (int)parameters[5];
     int Bar = data.Close.Count - 1;
     if (rule.isValid_forBuy(Bar))
     {
         BusinessInfo info = new BusinessInfo();
         info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified);
         info.Weight = data.Close[Bar];
         SelectStock(Bar, info);
     }
 }
Esempio n. 4
0
        override protected void StrategyExecute()
        {
            HybridTestRules rule = new HybridTestRules(data.Bars, parameters[0], parameters[1], parameters[2]);
            int cutlosslevel = (int)parameters[3];
            int trailingstoplevel = (int)parameters[4];
            int takeprofitlevel = (int)parameters[5];

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

            Indicators.Fibonnanci fibo = Indicators.Fibonnanci.Series(data.Bars, parameters[1], "fibo");


        //    public double Short_Resistance;
        //public double Short_Support;
        //public double Short_Target;
        //public AppTypes.MarketTrend ShortTermTrend;
        //public double Stop_Loss;
            for (int idx = 1; idx < data.Close.Count; idx++)
            {
                if (rule.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 (rule.isValid_forSell(idx))
                    {
                        BusinessInfo info = new BusinessInfo();
                        info.SetTrend(AppTypes.MarketTrend.Downward, 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);
                    }
                if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel))
                    SellCutLoss(idx);

                if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel))
                    SellTakeProfit(idx);

                if (trailingstoplevel > 0)
                    TrailingStopWithBuyBack(rule, data.Close[idx], trailingstoplevel, idx);
            }
        }