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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

End If

If marketPosition = -1 Then

Call Trade(ExitShort, "ExitShortStop", entryPrice +

2000 / myTickValue, stp, i)

If barsShort > 10 And myClose(i) > entryPrice Then

Call Trade(ExitShort, "10dayShOut", myClose(i), moc, i)

End If

End If

If marketPosition = 1 Then

Call Trade(ExitLong, "ExitLongStop", entryPrice -

2000 / myTickValue, stp, i)

If barsLong > 10 And myClose(i) < entryPrice Then

Call Trade(ExitLong, "10dayLgOut", myClose(i), moc, i)

End If

End If

’****************************************************************

’**** End of Main Traiding Loop ****

’**** No orders allowed below this point ****

’****************************************************************

160

USING MICROSOFT EXCEL TO BACKTEST YOUR ALGORITHM

This is the complete listing for this simple Bollinger Band system. Don’t worry

about any of the source code above the Main Trading Loop comment block:

’****************************************************************

’**** This is a good place to put all of your function calls ****

’**** and system calculations. ****

’****************************************************************

All of your programming will take place below these comments. For illustration

purposes, I immediately call four indicator functions/subroutines.

Call BollingerBand(myClose, 60, 2, avg, upBand, dnBand, i, 1)

simpleAvg = Average(myClose, 10, i, 1)

rsiVal = RSI(myClose, 14, i, 1)

Call Stochastic(3, 4, 7, stoK, stoD, slowD, i, 1)

This algorithm will just use the values modified in the BollingerBand subroutine:

avg, upBand, dnBand. Let’s look at the other function calls in the program:

Average. This function returns a moving average value for the past 10 days. Its

first argument is the data array that is to be averaged, and the second argument

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!