繁体   English   中英

ta-lib计算的数据顺序是什么

[英]What is the data order for ta-lib calculations

我有以下蜡烛

+----------------+-------+----------+---------+----------+
|date            |curency|high_price|low_price|last_price|
+----------------+-------+----------+---------+----------+
|2014-01-16 16:07|2      |24.98     |23.9     |24.2      |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:06|2      |24.98     |23.9     |24.12202  |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:05|2      |24.98     |23.9     |24.12202  |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:04|2      |24.98     |23.9     |24.21626  |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:03|2      |24.98     |23.9     |24.11102  |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:02|2      |24.98     |23.9     |24.21628  |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:01|2      |24.98     |23.9     |24.2      |
+----------------+-------+----------+---------+----------+
|2014-01-16 16:00|2      |24.98     |23.9     |24.2      |
+----------------+-------+----------+---------+----------+

我使用TA-lib来计算Ema,如下所示

public MovingAverage CalculateEMA(List<OHLC> candles, int periodsAverage)
{
    double[] closePrice = candles.Select(x => (double)x.last_price).ToArray();
    double[] output = new double[closePrice.Length];
    int begin;
    int length;

    TicTacTec.TA.Library.Core.RetCode retCode = Core.Ema(0, closePrice.Length - 1, closePrice, periodsAverage, out begin, out length, output);

    if (retCode == TicTacTec.TA.Library.Core.RetCode.Success)
        return new MovingAverage() { Begin = begin, Length = length, Output = output, Period = periodsAverage };

    return null;
}

问题是正确的蜡烛顺序,最近的条目是顶部还是底部? 图书馆如何进行计算? 我应该在计算Ema之前倒转蜡烛列表吗? 我对macd计算也有同样的问题

谢谢,

最早的日期/时间是数组中的FIRST元素 - 元素[0]。 时间顺序=数组顺序。 您最近的时间(最后一次)应该是数组中的最后一个元素。
该逻辑适用于所有TA-Lib功能。

public static double TA_MACDTest(int startIdx,int endIdx,Object[] InputValues, int FastEMAPeriods, int SlowEMAPeriods, int SignalEMAPeriods)
{
    int i = 1;
    double[] newInputValues = new double[InputValues.Count()];
    int intItr = 0;
    foreach (object objValue in InputValues)
    {
        newInputValues[intItr] = Convert.ToDouble(objValue);
        intItr = intItr + 1;
    }
    int outBegIdx;
    int outNBElement;

    double[] outMACD = new double[endIdx - startIdx + 1];
    double[] outMACDSignal = new double[endIdx - startIdx + 1];
    double[] outMACDHist = new double[endIdx - startIdx + 1];

    Core.RetCode res = Core.Macd(startIdx, endIdx, newInputValues, FastEMAPeriods, SlowEMAPeriods, SignalEMAPeriods, out  outBegIdx, out  outNBElement, outMACD, outMACDSignal, outMACDHist);
    List<Macdres> resarr = new List<Macdres>(endIdx - startIdx + 1);
    Macdres macdres = new Macdres();
    macdres.Index = i;
    macdres.Macd = outMACD.Last();
    macdres.Signal = outMACDSignal[i];
    macdres.MacdHistogram = outMACDHist[i];
    return macdres.Macd;
}

暂无
暂无

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

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