wheelie pete
New Member
- Joined
- Mar 1, 2019
- Messages
- 6
Afternoon - I searched the forums and couldn't come up with anything, but I'm wondering if anyone could help modify this code that I found on another site, so that it would take into account the average of one of the functions of the previous cells. Effectively, I'm trying to modify this code
So that it takes into account the average of previous averages as shown on this page.
https://stockcharts.com/school/doku...hnical_indicators:relative_strength_index_rsi
Any takers on this? I believe it needs an array, but I'm just not sure. Thanks!! pete
Code:
Function RSI(MyCells As Range)
Dim up_day, down_day, ups, downs
Dim average_up, average_down
Dim RS, cellcount As Long
Dim cll As Range
ups = 0
up_day = 0
downs = 0
down_day = 0
cellcount = 0
For Each cll In MyCells
cellcount = cellcount + 1
If cellcount = MyCells.Count Then Exit For
If cll.Value >= cll.Offset(1, 0).Value Then
downs = downs + cll - cll.Offset(1, 0).Value
ElseIf cll.Value < cll.Offset(1, 0).Value Then
ups = ups + cll.Offset(1, 0).Value - cll.Value
End If
Next cll
average_up = ups / cellcount
average_down = downs / cellcount
RS = average_up / average_down
RSI = 100 - (100 / (1 + RS))
End Function
So that it takes into account the average of previous averages as shown on this page.
https://stockcharts.com/school/doku...hnical_indicators:relative_strength_index_rsi
Any takers on this? I believe it needs an array, but I'm just not sure. Thanks!! pete
Last edited by a moderator: