繁体   English   中英

TA-Lib仅返回1个周期的结果

[英]TA-Lib returns result just for 1 period

我想计算14个24小时周期的MFI。 我正在加载15个24小时时段。 在输出中,我只有1个MFI值,所有其他行的值均为0。Ta-Lib返回“成功”。 我究竟做错了什么? 例如,当我尝试计算其他内容(例如atr)时,也会发生相同的情况。

using System;
using System.IO;
using System.Linq;
using System.Net;
using Newtonsoft.Json.Linq;
using TicTacTec.TA.Library;


namespace MFITest
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://poloniex.com/public?command=returnChartData&currencyPair=XMR_DASH&start=1502020458&end=1503350000&period=86400"); // Get 15 periods
            request.Method = "GET";
            string reply; 
            using (var response = request.GetResponse())
            {
                using (StreamReader responseStream = new StreamReader(response.GetResponseStream()))
                {
                    reply = responseStream.ReadToEnd();
                }
            }
            dynamic chartDataDynamic = JArray.Parse(reply);
            var high = new double[chartDataDynamic.Count];
            for (int i = 0; i < chartDataDynamic.Count; i++)
            {
                high[i] = (double)chartDataDynamic[i]["high"];
            }
            var low = new double[chartDataDynamic.Count];
            for (int i = 0; i < chartDataDynamic.Count; i++)
            {
                low[i] = (double)chartDataDynamic[i]["low"];
            }
            var open = new double[chartDataDynamic.Count];
            for (int i = 0; i < chartDataDynamic.Count; i++)
            {
                open[i] = (double)chartDataDynamic[i]["open"];
            }
            var close = new double[chartDataDynamic.Count];
            for (int i = 0; i < chartDataDynamic.Count; i++)
            {
                close[i] = (double)chartDataDynamic[i]["close"];
            }
            var volume = new double[chartDataDynamic.Count];
            for (int i = 0; i < chartDataDynamic.Count; i++)
            {
                volume[i] = (double)chartDataDynamic[i]["volume"];
            }
            var startIdx = 0;
            var endIdx = high.Length - 1;
            var period = 14; 
            var outBegIdx = -1;
            var outNbElement = -1;
            var taLibOutDoubles = new double[endIdx];
            var retCode = Core.Mfi(startIdx, endIdx, high, low, close, volume, period, out outBegIdx, out outNbElement,
                taLibOutDoubles);
            Console.WriteLine(retCode);
            var tools = new Tools();
            foreach (var line in taLibOutDoubles)
            {
                Console.WriteLine(line);
            }

            Console.ReadLine();
        }
    }
}

taLibOutDoubles输出:>

  1. 51.2076586152978
  2. 0
  3. 0
  4. 0
  5. 0
  6. 0
  7. 0
  8. 0
  9. 0
  10. 0
  11. 0
  12. 0
  13. 0
  14. 0

如果我对MFI有误解,请纠正我,但请按照以下说明进行操作: http : //www.chart-formations.com/indicators/mfi.aspx? cat = momentum资金流量指数是一个汇总指数,如果您给出输入14个周期。

如果更改周期,例如2,则将填充阵列,但是,看起来14天是迄今为止最常见的。 所得的MFI 51表明,它在给定的时期内既没有超卖也没有超买。

看起来这是与C#远程链接的,可以放在https://quant.stackexchange.com/中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM