1

Aroonシリーズを作成するためのクラスを構築しようとしています。しかし、手順がよくわからないようです。period パラメータをどのような目的で使用する必要があるのか​​ わかりません。

これが私の最初の試みです:

/// <summary>
/// Aroon
/// </summary>
public class Aroon : IndicatorCalculatorBase
{
    public override List<Ohlc> OhlcList { get; set; }
    public int Period { get; set; }

    public Aroon(int period) 
    {
        this.Period = period;
    }

    /// <summary>
    /// Aroon up: {((number of periods) - (number of periods since highest high)) / (number of periods)} x 100
    /// Aroon down: {((number of periods) - (number of periods since lowest low)) / (number of periods)} x 100
    /// </summary>
    /// <see cref="http://www.investopedia.com/ask/answers/112814/what-aroon-indicator-formula-and-how-indicator-calculated.asp"/>
    /// <returns></returns>
    public override IIndicatorSerie Calculate()
    {
        AroonSerie aroonSerie = new AroonSerie();

        int indexToProcess = 0;

        while (indexToProcess < this.OhlcList.Count)
        {
            List<Ohlc> tempOhlc = this.OhlcList.Skip(indexToProcess).Take(Period).ToList();
            indexToProcess += tempOhlc.Count;

            for (int i = 0; i < tempOhlc.Count; i++)
            {   
                int highestHighIndex = 0, lowestLowIndex = 0;
                double highestHigh = tempOhlc.Min(x => x.High), lowestLow = tempOhlc.Max(x => x.Low);
                for (int j = 0; j < i; j++)
                {
                    if (tempOhlc[j].High > highestHigh)
                    {
                        highestHighIndex = j;
                        highestHigh = tempOhlc[j].High;
                    }

                    if (tempOhlc[j].Low < lowestLow)
                    {
                        lowestLowIndex = j;
                        lowestLow = tempOhlc[j].Low;
                    }
                }

                int up = ((this.Period - (i - highestHighIndex)) / this.Period) * 100;
                aroonSerie.Up.Add(up);

                int down = ((this.Period - (i - lowestLowIndex)) / this.Period) * 100;
                aroonSerie.Down.Add(down);
            }
        }

        return aroonSerie;
   }
}

以前にそれをやろうとした人はいますか?

私が使用するcsvファイルは次のとおりです。

https://drive.google.com/file/d/0Bwv_-8Q17wGaRDVCa2FhMWlyRUk/view

しかし、Aroon up と down の結果セットは、R の TTR パッケージの aroon 関数の結果と一致しません。

table <- read.csv("table.csv", header = TRUE, sep = ",")
trend <- aroon(table[,c("High", "Low")], n=5)
View(trend)

R の結果のスクリーンショット:

ここに画像の説明を入力

前もって感謝します、

4

3 に答える 3