Ejemplo n.º 1
0
        private async Task <char> GetCommodityChannelIndex(string symbol, ChartPeriod timeframe, int period, int appliedPrice, int shift)
        {
            var cciVal = await Execute(() => _apiClient.iCCI(symbol, (int)timeframe, period, appliedPrice, shift));

            if (cciVal <= -100)
            {
                return('1');
            }
            else if (cciVal >= 100)
            {
                return('0');
            }
            else
            {
                return('#');
            }
            // TODO: Calculate: So heuristics are applied in such a scenario that is if the current CCI is greater than past ten periods moving average of CCI then a bid signal is triggered and vice versa.
            //else if (CciVal > CcimaVal)
            //{
            //    return '1';
            //}
            //else
            //{
            //    return '0';
            //}
        }
Ejemplo n.º 2
0
        private async Task <char> GetWilliamsPercentR(string symbol, ChartPeriod timeframe, int period, int shift)
        {
            var wpr = await Execute(() => _apiClient.iWPR(symbol, (int)timeframe, period, shift));

            char result = '#';

            // Overbought
            if (wpr >= -20)
            {
                result = '0';
            }
            // Oversold
            else if (wpr <= -80)
            {
                result = '1';
            }
            else
            {
                result = '#';
            }



            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="symbol">Stock trading symbol. --> "EURUSD"</param>
        /// <param name="maShift">Indicators line offset relate to the chart by timeframe. --> </param>
        /// <param name="timeframe">It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.</param>
        /// <param name="shift">Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).</param>
        /// <returns></returns>
        private async Task <char> GetMovingAverage(string symbol, int maShift, ChartPeriod timeframe, int shift)
        {
            // Stocksymbol
            // Applyed to a 15 minute time frame
            // First 50 then 5 periods
            // MaShift ....?!
            // EMA method = 1
            // Closed price = 0
            // Shift ... ?!

            var ema50Val = await Execute(() => _apiClient.iMA(symbol, (int)timeframe, 50, maShift, 1, 0, shift));

            var ema5Val = await Execute(() => _apiClient.iMA(symbol, (int)timeframe, 5, maShift, 1, 0, shift));

            if (ema50Val <= ema5Val)
            {
                return('0');
            }
            else
            {
                return('1');
            }

            // TODO: Check parameters
            throw new NotImplementedException();
        }
Ejemplo n.º 4
0
 public ChartWindow(ChartPeriod periodType, string periodTitle)
 {
     InitializeComponent();
     InitializeTimer();
     PeriodType  = periodType;
     PeriodTitle = periodTitle;
 }
Ejemplo n.º 5
0
        public async Task <char[]> GetSituationAsync(string symbol, ChartPeriod timeframe, int maShift, int period, int appliedPrice, int shift)
        {
            // Moving Average (MA)
            _situation[0] = await GetMovingAverage(symbol, maShift, ChartPeriod.PERIOD_M15, shift);

            // Commodity Channel Index (CCI)
            _situation[1] = await GetCommodityChannelIndex(symbol, timeframe, period, appliedPrice, shift);

            // Chaikin Money Flow (CMF)
            _situation[2] = '#';

            // Moving average convergence divergence (MACD)
            _situation[3] = await GetMovingAverageConvergenceDivergence(null, ChartPeriod.ZERO, 0, 0, 0, 0, 0, 0);

            // Percentage Price Oscillator (PPO)
            _situation[4] = '#';

            // Relative Strength Index (RSI)
            _situation[5] = await GetRelativeStrengthIndex(null, ChartPeriod.ZERO, 0, 0, 0);

            // Rate of Change (ROC)
            _situation[6] = '#';

            // Williams Percent R (WPR)
            _situation[7] = await GetWilliamsPercentR(null, ChartPeriod.ZERO, 0, 0);

            throw  new NotImplementedException();
        }
Ejemplo n.º 6
0
        // Gets past 7 days of data for the given currency pair symbol and chart period (bar interval)
        public List <PublicChart> GetOHLC(string pair, ChartPeriod period = ChartPeriod.Minutes5)
        {
            var currency_pair = CurrencyPair.Parse(pair);
            var end_time      = DateTime.Now;
            var start_time    = end_time.Subtract(TimeSpan.FromDays(7));
            var res           = m_api.GetChartData(currency_pair, period, start_time, end_time).Result;

            return(res);
        }
        public CandleStick GetLastCandleStick(string strSymbol, string strPeriod)
        {
            ChartPeriod TimeFrame = ChartPeriod.PERIOD_D1;

            switch (strPeriod)
            {
            case "1M":
                TimeFrame = ChartPeriod.PERIOD_M1;
                break;

            case "5M":
                TimeFrame = ChartPeriod.PERIOD_M5;
                break;

            case "15M":
                TimeFrame = ChartPeriod.PERIOD_M15;
                break;

            case "30M":
                TimeFrame = ChartPeriod.PERIOD_M30;
                break;

            case "1H":
                TimeFrame = ChartPeriod.PERIOD_H1;
                break;

            case "4H":
                TimeFrame = ChartPeriod.PERIOD_H4;
                break;

            case "1D":
                TimeFrame = ChartPeriod.PERIOD_D1;
                break;

            case "1W":
                TimeFrame = ChartPeriod.PERIOD_W1;
                break;

            case "MN":
                TimeFrame = ChartPeriod.PERIOD_MN1;
                break;
            }

            CandleStick stick = new CandleStick();

            stick.Low   = _apiClient.iLow(strSymbol, TimeFrame, 1);
            stick.High  = _apiClient.iHigh(strSymbol, TimeFrame, 1);
            stick.Open  = _apiClient.iOpen(strSymbol, TimeFrame, 1);
            stick.Close = _apiClient.iClose(strSymbol, TimeFrame, 1);
            return(stick);
        }
Ejemplo n.º 8
0
        //iCustom (Parabolic)
        private async void button23_Click(object sender, EventArgs e)
        {
            const string      symbol    = "EURUSD";
            const ChartPeriod timeframe = ChartPeriod.PERIOD_H1;
            const string      name      = "Parabolic";

            double[]  parameters = { 0.02, 0.2 };
            const int mode       = 0;
            const int shift      = 1;

            var retVal = await Execute(() => _apiClient.iCustom(symbol, (int)timeframe, name, parameters, mode, shift));

            PrintLog($"ICustom result: {retVal}");
        }
Ejemplo n.º 9
0
        //iCustom (ZigZag)
        private async void iCustomBtn_Click(object sender, EventArgs e)
        {
            const string      symbol    = "EURUSD";
            const ChartPeriod timeframe = ChartPeriod.PERIOD_H1;
            const string      name      = "ZigZag";

            int[]     parameters = { 12, 5, 4 };
            const int mode       = 0;
            const int shift      = 0;

            var retVal = await Execute(() => _apiClient.iCustom(symbol, (int)timeframe, name, parameters, mode, shift));

            PrintLog($"ICustom result: {retVal}");
        }
Ejemplo n.º 10
0
        private DataRequest CreateChartRequest(string symbol, ChartPeriod period)
        {
            var chartRequest = new DataRequest
            {
                DateExecuted     = DateTime.Now,
                DateExecuteAt    = DateTime.Now,
                Status           = RequestStatus.Enqueued,
                Type             = RequestType.Chart,
                ExceptionMessage = String.Empty,
                JsonResult       = String.Empty
            };

            chartRequest.Parameter1 = symbol;
            chartRequest.Parameter2 = ((int)period).ToString();
            return(chartRequest);
        }
Ejemplo n.º 11
0
        private async Task <char> GetRelativeStrengthIndex(string symbol, ChartPeriod timeframe, int period, int appliedPrice, int shift)
        {
            var rsi = await Execute(() => _apiClient.iRSI(symbol, (int)timeframe, period, appliedPrice, shift));

            // Overbought
            if (rsi >= 80)
            {
                return('0');
            }
            // Oversold
            else if (rsi <= 20)
            {
                return('1');
            }
            else
            {
                return('#');
            }
        }
Ejemplo n.º 12
0
        private async Task <char> GetMovingAverageConvergenceDivergence(string symbol, ChartPeriod timeframe, int fastEmaPeriod, int slowEmaPeriod, int signalPeriod, int appliedPrice, int mode, int shift)
        {
            var macd = await Execute(() => _apiClient.iMACD(symbol, (int)timeframe, fastEmaPeriod, slowEmaPeriod, signalPeriod, appliedPrice, mode, shift));

            if (macd > 0)
            {
                return('1');
            }
            else
            {
                return('0');
            }
        }
Ejemplo n.º 13
0
 public static void ChartUpdate(this MT4Manager mt4, string symbol, ChartPeriod period, IEnumerable <RateInfo> rates)
 {
     mt4.ChartUpdate(symbol, period, rates.ToArray());
 }
		public static IFluentApi<T> WithPeriod<T>(this IFluentApi<T> api, ChartPeriod period) where T : HasChartParameter
		{
			api.WithParameter("period", period.ToString().ToLower());
			return api;
		}
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="currency_pair"></param>
        /// <param name="period"></param>
        /// <param name="start_time"></param>
        /// <param name="end_time"></param>
        /// <returns></returns>
        public async Task <List <PublicChart> > GetChartData(CurrencyPair currency_pair, ChartPeriod period, DateTime start_time, DateTime end_time)
        {
            var _params = new Dictionary <string, object>();

            {
                _params.Add("command", "returnChartData");
                _params.Add("currencyPair", currency_pair);
                _params.Add("start", start_time.DateTimeToUnixTimeStamp());
                _params.Add("end", end_time.DateTimeToUnixTimeStamp());
                _params.Add("period", (int)period);
            }

            return(await Api.CallApiGetAsync <List <PublicChart> >(__end_point, _params));
        }
Ejemplo n.º 16
0
 public async Task <Highcharts> GetOverallClientCount(ChartPeriod chartPeriod)
 {
     throw new NotImplementedException();
 }