示例#1
0
        public static StackTrend Evaluate(Candle[] candles)
        {
            var bearish = 0;
            var bullish = 0;

            var stockTrend = StackTrend.Stable;

            /*
             * if (CandleAnalyzer.IsBullish(candles)) bullish++;
             * if (CandleAnalyzer.IsMorningStar(candles)) bullish++;
             *
             * if (CandleAnalyzer.IsBearish(candles)) bearish++;
             * if (CandleAnalyzer.IsEveningStar(candles)) bearish++;
             */
            /*
             *
             * stockTrend = CandleAnalyzer.IsEngulfing(candles);
             * if (stockTrend == StackTrend.Bearish)
             * {
             *  bearish++;
             * }
             * else if (stockTrend == StackTrend.Bullish)
             * {
             *  bullish++;
             * }
             */

            stockTrend = CandleAnalyzer.IsDoji(candles);
            if (stockTrend == StackTrend.Bearish)
            {
                bearish++;
            }
            else if (stockTrend == StackTrend.Bullish)
            {
                bullish++;
            }

            /*
             * stockTrend = CandleAnalyzer.IsMarubozu(candles);
             * if (stockTrend == StackTrend.Bearish)
             * {
             *  bearish++;
             * }
             * else if (stockTrend == StackTrend.Bullish)
             * {
             *  bullish++;
             * }
             */

            if (((double)bearish / (double)(bearish + bullish)) > 0.75)
            {
                return(StackTrend.Bearish);
            }
            if (((double)bullish / (double)(bearish + bullish)) > 0.75)
            {
                return(StackTrend.Bullish);
            }
            return(StackTrend.Stable);
        }
        protected TradeAction EvalCandles(CMarket market)
        {
            var bullish = 0;
            var bearish = 0;
            var candles = market.CandleMaker.GetLastCandles();

            //var candles = market.CandleMakerHourly.GetLastCandles();
            for (var i = 0; i < 1; i++)
            {
                var c     = new[] { candles[i], candles[i + 1], candles[i + 2] };
                var trend = CandleAnalyzer.Evaluate(c);
                if (trend == StackTrend.Bullish)
                {
                    // AnalyticsTools.Call("candle bull");
                    bullish++;
                }
                else
                if (trend == StackTrend.Bearish)
                {
                    // AnalyticsTools.Call("candle bear");
                    bearish++;
                }
            }
            //var candleSuggestion = TradeAction.Hold;
            var bearbullishratio = 0.6M;

            if (bullish > bearish * bearbullishratio)
            {
                //LogTrade.Note += " BULL ";
                return(TradeAction.Buy);
            }
            else if (bearish < bullish * bearbullishratio)
            {
                //LogTrade.Note += " BEAR ";
                return(TradeAction.Sell);
            }
            return(TradeAction.Hold);
        }