You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Aroon Indicator has the following error:
given the list of highs (lows the same but only use high in this example) it first calculates the highs with the Max function. This returns a list for i ... n where i the high for i - 25. Next it uses the function Since but this is not correct. The function since checks for value i when it last changed. But this is not what you want. You want to know for point i how many days was the last high.
Example high [48, 52, 50, 49, 10]
lets say window is 3 in this example. Max will return:
[48, 52, 52, 52, 50]
Since would be in this case:
[0, 0, 1, 2, 0]
In the aroon calculation you do 3 - sinceLastHigh / 3 * 100
for n this would be (3 - 0) / 3 * 100
It thinks the amount of days since the last high is 0 which is wrong. I think you don't want to check since when the value changed but for value i how many days ago was the last high in a given period.
so for example instead of the function since() and max() use something like the following:
func SinceHigh(period int, values []float64) []int {
result := make([]int, len(values))
for i := 0; i < len(values); i++ {
startIndex := i - period
if startIndex < 0 {
startIndex = 0
}
highest := math.Inf(-1)
highestIndex := startIndex
for j := startIndex; j <= i; j++ {
if values[j] > highest {
highest = values[j]
highestIndex = j
}
}
result[i] = i - highestIndex
}
return result
}
func SinceLow( period int, values []float64) []int {
result := make([]int, len(values))
for i := 0; i < len(values); i++ {
startIndex := i - period
if startIndex < 0 {
startIndex = 0
}
lowest := math.Inf(1)
lowestIndex := startIndex
for j := startIndex; j <= i; j++ {
if values[j] < lowest {
lowest = values[j]
lowestIndex = j
}
}
result[i] = i - lowestIndex
}
return result
}
And then in Aroon do:
sinceLastHigh25 := SinceHigh(25, high)
sinceLastLow25 := SinceLow(25, low)
The text was updated successfully, but these errors were encountered:
Thank you very much for your detailed bug report. I think you are correct. If you want to send a PR, please feel free to do so. Otherwise, I'll fix it aligned with your note here. If you happen to have some test data that can be used for unit testing here please let me know as well.
Describe the bug
The Aroon Indicator has the following error:
given the list of highs (lows the same but only use high in this example) it first calculates the highs with the Max function. This returns a list for i ... n where i the high for i - 25. Next it uses the function Since but this is not correct. The function since checks for value i when it last changed. But this is not what you want. You want to know for point i how many days was the last high.
Example high [48, 52, 50, 49, 10]
lets say window is 3 in this example. Max will return:
[48, 52, 52, 52, 50]
Since would be in this case:
[0, 0, 1, 2, 0]
In the aroon calculation you do 3 - sinceLastHigh / 3 * 100
for n this would be (3 - 0) / 3 * 100
It thinks the amount of days since the last high is 0 which is wrong. I think you don't want to check since when the value changed but for value i how many days ago was the last high in a given period.
so for example instead of the function since() and max() use something like the following:
And then in Aroon do:
sinceLastHigh25 := SinceHigh(25, high)
sinceLastLow25 := SinceLow(25, low)
The text was updated successfully, but these errors were encountered: