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.

The first subroutine call holds the RSI value in rsiVal1 and the upSumAvg1

and dnSumAvg1 values are held over until the next subroutine call. The second

subroutine call stores its RSI value in rsiVal2 and the up sum and down sum averages

in upSumAvg2 and dnSumAvg2, respectively. So keep in mind that if you want

to call a subroutine more than once, then you will need to create separate parameter

names so that the subroutine can keep track of the different lookback lengths and

indicator values.

Function Highest(dataList, length, index, offset)

Function Highest(dataList, length, index, offset)

Dim i As Integer

Dim tempHH As Integer

tempHH = 0

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

Next i

Highest = tempHH

End Function

If (dataList(i) > tempHH) Then tempHH = myHigh(i)

Sub RSISub(dataList, length, rsiVal, upSumAvg, dnSumAvg, index, offset)

Sub RSISub(dataList, length, rsiVal, upSumAvg, dnSumAvg, index, offset)

Dim i As Integer

Dim diff1, diff2, upSum, dnSum 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

End If

Next i

303

EXCEL SYSTEM BACKTESTER

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!