31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

upSumAvg = upSum / length

dnSumAvg = dnSum / length

Else

If dataList(index - offset) > dataList(index - 1 - offset) Then

diff1 = dataList(index - offset) - dataList(index - 1 - offset)

upSum = upSum + diff1

End If

If dataList(index - offset) < dataList(index - 1 - offset) Then

diff2 = dataList(index - 1 - offset) - dataList(index - offset)

dnSum = dnSum + diff2

End If

upSumAvg = (upSumAvg * (length - 1) + upSum) / length

dnSumAvg = (dnSumAvg * (length - 1) + dnSum) / length

End If

If upSumAvg + dnSumAvg <> 0 Then

rsiVal = (100 * (upSumAvg)) / (upSumAvg + dnSumAvg)

Else

rsiVal = 0

End If

End Sub

304

EXCEL SYSTEM BACKTESTER

Function RSI(dataList, length, index, offset)

Function RSI(dataList, length, index, offset)

Dim i As Integer

Dim diff1, diff2, upSum, dnSum As Double

Static upSumAvg, dnSumAvg As Double

upSum = 0

dnSum = 0

If upSumAvg = 0 And dnSumAvg = 0 Then

’seed the original RSI Value

For i = (index - offset) - (length - 1) To

(index - offset)

If dataList(i) > dataList(i - 1) Then

diff1 = dataList(i) - dataList(i - 1)

upSum = upSum + diff1

End If

If dataList(i) < dataList(i - 1) Then

diff2 = dataList(i - 1) - dataList(i)

dnSum = dnSum + diff2

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!