Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        public static void Get(Instrument instrument, string HA_M15_Color, string HA_H1_Color, string HA_H4_Color, List <Model.Candle> haDaily, Model.InstrumentDayPrice instrumentDayPrice)
        {
            string dCandleColor        = "";
            string originalCandleColor = "";

            int i = haDaily.Count() - 1;

            while (i > 0)
            {
                if (haDaily[i].Color == Constants.CandelColour.GREEN && haDaily[i - 1].Color == Constants.CandelColour.RED)
                {
                    if (haDaily.Count - i < 4)
                    {
                        originalCandleColor = haDaily[haDaily.Count() - 1].OriginalColor.ToString();
                        dCandleColor        = haDaily[haDaily.Count() - 1].Color.ToString();
                        string statusPrice = "";
                        if (instrumentDayPrice.Current > instrumentDayPrice.EMA)
                        {
                            statusPrice = "BUY";
                        }
                        else
                        {
                            statusPrice = "WAIT";
                        }

                        double sl    = haDaily[haDaily.Count - 2].Open;
                        string alert = instrument.DisplayName + Environment.NewLine;
                        alert += string.Format("{0,-15}{1,-10}{2,-5}{3,-10}{4,-10}{5,-10}{6,-10}{7,-10}{8,-10}{9,-10}", instrument.Name, instrument.Type, (haDaily.Count - i).ToString(), originalCandleColor, dCandleColor, HA_H4_Color, HA_H1_Color, HA_M15_Color, statusPrice, sl);


                        //if (statusPrice == "BUY")
                        //{
                        //    if (originalCandleColor == Constants.CandelColour.GREEN.ToString())
                        //    {
                        //        if (originalCandleColor == dCandleColor && HA_H1_Color == dCandleColor && HA_H4_Color == dCandleColor && HA_M15_Color == dCandleColor)
                        //        {
                        //            GreenAlerts.Add(alert);
                        //        }
                        //        else if (originalCandleColor == dCandleColor &&   originalCandleColor == HA_M15_Color)
                        //        {
                        //            YellowAlerts.Add(alert);
                        //        }

                        //        //else if (originalCandleColor == dCandleColor)
                        //        //{
                        //        //    BlueAlerts.Add(alert);
                        //        //}
                        //    }
                        //}
                        //else
                        //{

                        Console.WriteLine(alert);
                        Console.WriteLine();
                        //}

                        break;
                    }
                }

                else if (haDaily[i].Color == Constants.CandelColour.RED && haDaily[i - 1].Color == Constants.CandelColour.GREEN)
                {
                    if (haDaily.Count - i < 4)
                    {
                        originalCandleColor = haDaily[haDaily.Count() - 1].OriginalColor.ToString();
                        dCandleColor        = haDaily[haDaily.Count() - 1].Color.ToString();
                        string statusPrice = "";
                        if (instrumentDayPrice.Current < instrumentDayPrice.EMA)
                        {
                            statusPrice = "SELL";
                        }
                        else
                        {
                            statusPrice = "WAIT";
                        }

                        double sl    = haDaily[haDaily.Count - 2].Open;
                        string alert = instrument.DisplayName + Environment.NewLine;
                        alert += string.Format("{0,-15}{1,-10}{2,-5}{3,-10}{4,-10}{5,-10}{6,-10}{7,-10}{8,-10}{9,-10}", instrument.Name, instrument.Type, (haDaily.Count - i).ToString(), originalCandleColor, dCandleColor, HA_H4_Color, HA_H1_Color, HA_M15_Color, statusPrice, sl);



                        //if (statusPrice == "SELL")
                        //{
                        //    if (originalCandleColor == Constants.CandelColour.RED.ToString())
                        //    {
                        //        if (originalCandleColor == dCandleColor && HA_H1_Color == dCandleColor && HA_H4_Color == dCandleColor && HA_M15_Color == dCandleColor)
                        //        {
                        //            GreenAlerts.Add(alert);
                        //        }
                        //        else if (originalCandleColor == dCandleColor && originalCandleColor == HA_M15_Color)
                        //        {
                        //            YellowAlerts.Add(alert);
                        //        }

                        //        //else if (originalCandleColor == dCandleColor)
                        //        //{
                        //        //    BlueAlerts.Add(alert);
                        //        //}
                        //    }
                        //}
                        //else
                        //{

                        Console.WriteLine(alert);
                        Console.WriteLine();
                        //}

                        break;
                    }
                }

                i -= 1;
            }
        }