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.

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

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

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

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

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)

146

USING MICROSOFT EXCEL TO BACKTEST YOUR ALGORITHM

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

’**** Put All Of Your Orders Here ****

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

prevMarketPosition = marketPosition

If marketPosition <> 1 Then

Call Trade(Buy, "BB-Buy", upBand, stp, i)

End If

If marketPosition <> -1 Then

Call Trade(Sell, "BB-Sell", dnBand, stp, i)

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 ****

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

This system buys/sells short on the penetration of 60-day two-standard-deviations

Bollinger Bands, then risks $2,000 per trade and exits if the trade is not profitable

after 10 days. The code is Visual Basic, so it follows that syntax. In developing this

testing software my overall objective was simplicity—I wanted a very easy sloping

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!