Exemple #1
0
        public static bool BearichEngulfing(Model.Candle lastcandle, Model.Candle previouscandle)
        {
            if (lastcandle.Color == Constants.CandelColour.RED && previouscandle.Color == Constants.CandelColour.GREEN)
            {
                double P_H = previouscandle.Hight;
                double P_L = previouscandle.Low;
                double P_O = previouscandle.Open;
                double P_C = previouscandle.Close;

                double L_H = lastcandle.Hight;
                double L_L = lastcandle.Low;
                double L_O = lastcandle.Open;
                double L_C = lastcandle.Close;


                return(true); /*((C1 > O1) AND(O > C) AND(O >= C1) AND(O1 >= C) AND((O - C) > (C1 - O1)))*/
            }
            else
            {
                return(false);
            }



            return(true); /*(((H - L) > 4 * (O - C)) && ((H - C) / (.001 + H - L) >= 0.75) && ((H - O) / (.001 + H - L) >= 0.75));*/
        }
Exemple #2
0
        public static Model.Candle HA_W_Candles(Instrument instrument)
        {
            Model.Candle        haPreviounsCandle = null;
            Model.Candle        haCurrentCandle   = null;
            List <Model.Candle> haCandles         = new List <Candle>();
            List <Model.Candle> candles           = Data.Prices.GetCandles(instrument.Name, 10, "W");

            for (int i = 0; i < candles.Count; i++)
            {
                if (i == 0)
                {
                    haPreviounsCandle = Data.Candle.GeneratePrevious(candles[i]);
                    haCandles.Add(haPreviounsCandle);
                    //Console.WriteLine(haPreviounsCandle.Color);
                }
                else
                {
                    haCurrentCandle = Data.Candle.Generate(haPreviounsCandle, candles[i]);
                    //Console.WriteLine(haCurrentCandle.Color);
                    haCandles.Add(haCurrentCandle);
                    haPreviounsCandle = haCurrentCandle;
                }
            }


            return(haCandles.LastOrDefault());
        }
Exemple #3
0
        public static Model.Candle HA_H4_LastCandle(List <Model.Candle> H4)
        {
            Model.Candle        haPreviounsCandle = null;
            Model.Candle        haCurrentCandle   = null;
            List <Model.Candle> haCandles         = new List <Candle>();

            for (int i = 0; i < H4.Count; i++)
            {
                if (i == 0)
                {
                    haPreviounsCandle = Data.Candle.GeneratePrevious(H4[i]);
                    haCandles.Add(haPreviounsCandle);
                }
                else
                {
                    haCurrentCandle = Data.Candle.Generate(haPreviounsCandle, H4[i]);

                    haCandles.Add(haCurrentCandle);
                    haPreviounsCandle = haCurrentCandle;
                }
            }


            return(haCandles.LastOrDefault());
        }
Exemple #4
0
        public static bool WhiteSpinningTop(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;

            return((C > O && ((H - L) > (3 * (C - O))) && (((H - C) / (0.001 + H - L)) < 0.4) && (((O - L) / (0.001 + H - L)) < 0.4)));
        }
Exemple #5
0
        public static bool BlackSpinningTop(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;

            return((O > C) && ((H - L) > (3 * (O - C)) && (((H - O) / (0.001 + H - L)) < 0.4) && (((C - L) / (0.001 + H - L)) < 0.4)));
        }
Exemple #6
0
        public static bool BullishDragonflyDoji(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;

            return(((H - L) > 3 * Math.Abs(O - C)) && ((C - L) > 0.8 * (H - L)) && ((O - L) > 0.8 * (H - L)));
        }
Exemple #7
0
        public static bool HangingMan(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;

            return(((H - L) > 4 * (O - C)) && ((C - L) / (0.001 + H - L) >= 0.75) && ((O - L) / (0.001 + H - L) >= 0.75));
        }
Exemple #8
0
        public static bool BullishEngulfing(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;



            return(((H - L) > 4 * (O - C)) && ((H - C) / (.001 + H - L) >= 0.75) && ((H - O) / (.001 + H - L) >= 0.75));
        }
Exemple #9
0
        public static bool Hammer(Model.Candle candle)
        {
            double H = candle.Hight;
            double L = candle.Low;
            double O = candle.Open;
            double C = candle.Close;



            return(((H - L) > 3 * (O - C)) && ((C - L) / (0.001 + H - L) > 0.6) && ((O - L) / (.001 + H - L) > 0.6));
        }
Exemple #10
0
        public static List <Model.Candle> HA_D_Candles(Instrument instrument, out InstrumentDayPrice instrumentDayPrice)
        {
            instrumentDayPrice = new InstrumentDayPrice();
            Model.Candle        haPreviounsCandle = null;
            Model.Candle        haCurrentCandle   = null;
            List <Model.Candle> haCandles         = new List <Candle>();
            List <Model.Candle> candles           = Data.Prices.GetCandles(instrument.Name, 22, "D");
            EMA ema = new EMA(22);

            for (int i = 0; i < candles.Count; i++)
            {
                instrumentDayPrice.Max     = Math.Max(instrumentDayPrice.Max, candles[i].Hight);
                instrumentDayPrice.Current = candles.LastOrDefault().Close;
                if (i == 0)
                {
                    instrumentDayPrice.Min = candles[i].Low;
                    instrumentDayPrice.Min = Math.Min(candles[i].Low, instrumentDayPrice.Min);
                    haPreviounsCandle      = Data.Candle.GeneratePrevious(candles[i]);
                    haCandles.Add(haPreviounsCandle);
                    //Console.WriteLine(haPreviounsCandle.OriginalColor);
                }

                else
                {
                    haCurrentCandle = Data.Candle.Generate(haPreviounsCandle, candles[i]);
                    //Console.WriteLine(haCurrentCandle.OriginalColor);
                    haCandles.Add(haCurrentCandle);
                    haPreviounsCandle = haCurrentCandle;
                }

                if (i < 5)
                {
                    ema.AddDataPoint(candles[i].Close);
                }
                else
                {
                    instrumentDayPrice.EMA = ema.Average;
                }
            }


            return(haCandles);
        }
Exemple #11
0
        public static void Run()
        {
            Console.ForegroundColor = ConsoleColor.White;

            instruments = Data.Instrument.AllFromFile().OrderBy(x => x.Type).OrderBy(x => x.DisplayName).ToList();
            //Timer t = new Timer(TimerCallback, null, 0, 60000);
            foreach (Instrument instrument in instruments)
            {
                if (instrument.DisplayName == "US Nas 100")
                {
                    Model.InstrumentDayPrice instrumentDayPrice = null;
                    List <Model.Candle>      ha_D_Candles       = HA_D_Candles(instrument, out instrumentDayPrice);
                    Model.Candle             ha_H4_LastCandle   = HA_IndicesAndCurrency.HA_H4_Candles(instrument);
                    Model.Candle             ha_H1_LastCandle   = HA_IndicesAndCurrency.HA_H1_Candles(instrument);
                    Model.Candle             ha_M15_LastCandle  = HA_IndicesAndCurrency.HA_M15_Candles(instrument);;

                    OANDA.Results.Get(instrument, ha_M15_LastCandle.Color.ToString(), ha_H1_LastCandle.Color.ToString(), ha_H4_LastCandle.Color.ToString(), ha_D_Candles, instrumentDayPrice);
                }
            }
            Console.ForegroundColor = ConsoleColor.Green;
            foreach (string item in OANDA.Results.GreenAlerts)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Yellow;
            foreach (string item in OANDA.Results.YellowAlerts)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }

            Console.ForegroundColor = ConsoleColor.Blue;
            foreach (string item in OANDA.Results.BlueAlerts)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }
        }
Exemple #12
0
        public static List <Model.Candle> HA_D_Candles(List <Model.Candle> D, out InstrumentDayPrice instrumentDayPrice)
        {
            instrumentDayPrice = new InstrumentDayPrice();
            Model.Candle        haPreviounsCandle = null;
            Model.Candle        haCurrentCandle   = null;
            List <Model.Candle> haCandles         = new List <Candle>();
            EMA ema = new EMA(5);

            for (int i = 0; i < D.Count; i++)
            {
                if (i == 0)
                {
                    instrumentDayPrice.Max     = Math.Max(instrumentDayPrice.Max, D[i].Hight);
                    instrumentDayPrice.Current = D.LastOrDefault().Close;
                    haPreviounsCandle          = Data.Candle.GeneratePrevious(D[i]);
                    haCandles.Add(haPreviounsCandle);
                }
                else
                {
                    haCurrentCandle = Data.Candle.Generate(haPreviounsCandle, D[i]);

                    haCandles.Add(haCurrentCandle);
                    haPreviounsCandle = haCurrentCandle;
                }

                if (i < 5)
                {
                    ema.AddDataPoint(D[i].Close);
                }
                else
                {
                    instrumentDayPrice.EMA = ema.Average;
                }
            }


            return(haCandles);
        }