private List <Candle> HA_D_Candles(Instrument instrument)
        {
            Candle        haPreviounsCandle = null;
            Candle        haCurrentCandle   = null;
            List <Candle> haCandles         = new List <Candle>();

            List <Candle> candles = OANDA.Data.Prices.GetCandles(instrument.Name, new DateTime(2020, 01, 01).AddDays(-50), "D");


            for (int i = 0; i < candles.Count; i++)
            {
                if (i == 0)
                {
                    haPreviounsCandle = HeikinAshi.GeneratePrevious(candles[i]);
                    haCandles.Add(haPreviounsCandle);
                }

                else
                {
                    haCurrentCandle = HeikinAshi.Generate(haPreviounsCandle, candles[i]);

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


            return(haCandles);
        }
Пример #2
0
        public static Candle HA_M15_Candles(Instrument instrument)
        {
            Candle        haPreviounsCandle = null;
            Candle        haCurrentCandle   = null;
            List <Candle> haCandles         = new List <Candle>();
            List <Candle> candles           = OANDA.Data.Prices.GetCandles(instrument.Name, 10, "M15");

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

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


            return(haCandles.LastOrDefault());
        }
Пример #3
0
        public static List <Candle> HA_D_Candles(Instrument instrument, out InstrumentDetails instrumentDetails)
        {
            instrumentDetails = new InstrumentDetails();
            Candle        haPreviounsCandle = null;
            Candle        haCurrentCandle   = null;
            List <Candle> haCandles         = new List <Candle>();
            int           emaPeriod         = 21;
            List <Candle> candles           = OANDA.Data.Prices.GetCandles(instrument.Name, emaPeriod, "D");

            instrumentDetails.Current = candles.LastOrDefault().Close;
            EMA ema = new EMA(emaPeriod);
            List <MyTrade.Core.Model.Candle> wcandles = MyTrade.Core.SqliteDataAccess.WeekyCandles.LoadCandles(instrument.Name);
            PivotPoints pps  = new PivotPoints();
            PivotPoint  wpps = pps.Get(wcandles[wcandles.Count - 2], instrumentDetails.Current);

            instrumentDetails.W_PivotPoints = wpps;
            List <MyTrade.Core.Model.Candle> mcandles = MyTrade.Core.SqliteDataAccess.MonthlyCandles.LoadCandles(instrument.Name);
            PivotPoint mpps = pps.Get(mcandles[mcandles.Count - 2], instrumentDetails.Current);

            instrumentDetails.M_PivotPoints = mpps;
            instrumentDetails.TimeFrame     = Core.Constants.TimeFrame.DAILY;
            for (int i = 0; i < candles.Count; i++)
            {
                instrumentDetails.Max = Math.Max(instrumentDetails.Max, candles[i].High);

                if (i == 0)
                {
                    instrumentDetails.Min = candles[i].Low;
                    instrumentDetails.Min = Math.Min(candles[i].Low, instrumentDetails.Min);
                    haPreviounsCandle     = HeikinAshi.GeneratePrevious(candles[i]);
                    haCandles.Add(haPreviounsCandle);
                }

                else
                {
                    haCurrentCandle = HeikinAshi.Generate(haPreviounsCandle, candles[i]);

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


                if (i == (candles.Count - 1))
                {
                    instrumentDetails.EMAs = new List <Core.Model.Indicators.EMA>();
                    ema.AddDataPoint(candles[i].Close);
                    instrumentDetails.EMAs.Add(new Core.Model.Indicators.EMA()
                    {
                        Period = 21, Value = ema.Average
                    });
                }
                else
                {
                    ema.AddDataPoint(candles[i].Close);
                }
            }


            return(haCandles);
        }
Пример #4
0
        public static Candle HA_W_Candles(Instrument instrument)
        {
            Candle        haPreviounsCandle = null;
            Candle        haCurrentCandle   = null;
            List <Candle> haCandles         = new List <Candle>();
            List <Candle> candles           = MyTrade.Core.SqliteDataAccess.WeekyCandles.LoadCandles(instrument.Name);

            for (int i = 0; i < candles.Count; i++)
            {
                if (i == 0)
                {
                    haPreviounsCandle = HeikinAshi.GeneratePrevious(candles[i]);
                    haCandles.Add(haPreviounsCandle);
                }

                else
                {
                    haCurrentCandle = HeikinAshi.Generate(haPreviounsCandle, candles[i]);

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


            return(haCandles.LastOrDefault());
        }