straightforward method to mechanically refine your · pdf fileatas meeting march 2, 2016 mark...
TRANSCRIPT
![Page 1: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/1.jpg)
ATAS Meeting March 2, 2016
Mark Bates, CFTe
Straightforward Method to Mechanically Refine Your Trading Strategies Using Amibroker
1
![Page 2: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/2.jpg)
• Step By Step Method to Install Amibroker• Step By Step Method to Write Your Strategy• Step By Step Method to Backtest Your Strategy• Step By Step Method to Forward Test Your Strategy
Outline
2
![Page 3: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/3.jpg)
• Back testing refers to applying a trading system to historical data to verify how a system would have performed during the specified time period.
• Forward testing is also known as Walk forward testing is the simulation of the real markets data on paper only
• Walk forward optimization is a method used in finance for determining the best parameters to use in a trading strategy. The trading strategy is optimized with in sample data for a time window in a data series. The remainder of the data are reserved for out of sample testing.
• Today I will demonstrate Back Testing and Walk Forward Optimization using Amibroker.
Testing Considerations
3
![Page 4: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/4.jpg)
Amibroker Home Page
Navigate to Amibrokerhome page at URLwww.amibroker.com
4
![Page 5: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/5.jpg)
Download Tab
Amibroker loads with allutilities using a single link.
Pick the 32 bit option if you are unsure between the32 and 64 bit options.
5
![Page 6: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/6.jpg)
Post Download
The download takes verylittle time.
6
![Page 7: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/7.jpg)
Wizard Starts
Double-click on the downloadfile to start the install.
7
![Page 8: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/8.jpg)
Install to D Drive
I run Amibroker from athumb drive that I can insert into any machine.
But you can install to your C drive and that is likelythe most common option.
8
![Page 9: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/9.jpg)
Full Installation
You want the “Full” installation since it is brandnew. Thereafter, updates are “Upgrade” installs.
9
![Page 10: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/10.jpg)
Install Complete – Launch Amibroker
It finishes loading quickly. Then launch it.
10
![Page 11: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/11.jpg)
AB installed – Main Page
11
The default load comes with several tickers built in. It defaultsto using AA and these two charts.
![Page 12: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/12.jpg)
Update Quotes
12
There is a one-click “auto update” to get the most recent tickers in Yahoo.
![Page 13: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/13.jpg)
Load Historical Results
13
Load history quotes as an option as well.
![Page 14: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/14.jpg)
Setup Historical Load
14
Set historical dates and run the load.Note that you can load daily or Intraday data.
![Page 15: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/15.jpg)
Historical Load Completed
15
![Page 16: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/16.jpg)
All Data from 1980 to Current
16
After historical load occurs, you can seethe daily data loaded back to 1980 aswas noted in the historical load.
![Page 17: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/17.jpg)
Select SPY with which to do analysis
17
Pull down individual security from thelist to change the chart.
![Page 18: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/18.jpg)
SPY in its entirety
18
Note this is SPY, Daily, closing date of 02/22/2016.
![Page 19: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/19.jpg)
Select Charts to Display
19
You can build your own studies. Or Amibroker comes with other views.We’ll load a MACD view now.
![Page 20: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/20.jpg)
Add MACD pane to charts
20
The various studies’ parameters canbe easily modified without programming.
![Page 21: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/21.jpg)
Screen Now includes MACD pane
21
Note the MACD chart added to the bottom.
![Page 22: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/22.jpg)
Open Formula Window
22
We are now going to customize thechart. It is fairly straightforward.Right click and “Edit Formula”.
![Page 23: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/23.jpg)
Just Price Screen
23
Lets pull down a simple Price chart.
![Page 24: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/24.jpg)
Initial Formula for the Chart
24
So here is the initial formula for the chart.
We are going to forget it for the moment.
It is not important to get started.
![Page 25: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/25.jpg)
Add Two MA lines
25
I have added two MA lines.
50dMA and a 200dMA.
We will look at a crossover system
![Page 26: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/26.jpg)
Result of Adding Two MA Lines
26
You can now see the 50d and 200d MA lines on the chart.And in the Title information at the top of the chart.
![Page 27: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/27.jpg)
Add BUY and SELL logic
27
I have added a BUY and a SELL equation.
BUY when the 50dMA is greater than the 200dMA.
SELL when the 50dMA is less than the 200dMA.
![Page 28: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/28.jpg)
Open Analysis Tab
28
Now we are going to run an Analysis and see how this particularBUY and SELL trading scheme backtests against the SPY ETF.
![Page 29: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/29.jpg)
Initial Backtest of MA Crossover Result
Each trade listed.This formula was “long only” but it can be “long and short” or “short only”.“Settings” can be used to change starting principal and a number of variables.
29
![Page 30: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/30.jpg)
View Trading Report
30
You can get a detailed backtesting report through the pulldown.
![Page 31: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/31.jpg)
Backtest Results for MA Crossover
Note comparative outputsparticularly between thisstrategy and “buy and hold”
31
![Page 32: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/32.jpg)
Open Formula to add Optimize Steps
32
Let’s edit the formula to do some Forward Testing.
![Page 33: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/33.jpg)
Adding the Optimizing Logic
Modify crossover strategy to allowShort and long term MA to vary.
Vary short term MA from 10 to 60 days.Vary long term MA from 100 to 300 days.
33
![Page 34: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/34.jpg)
Set Optimizer Settings
Optimizer is sophisticated andcan optimize along a numberof different variables.
Forward testing is a powerfulconstruct that objectively proves out the potential of strategies over various periods.
34
![Page 35: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/35.jpg)
Forward Testing Optimizer Results
Note difference in “in sample” and “out of sample” results. This is why forward testing is important.
35
![Page 36: Straightforward Method to Mechanically Refine Your · PDF fileATAS Meeting March 2, 2016 Mark Bates, CFTe Straightforward Method to Mechanically Refine Your Trading Strategies Using](https://reader031.vdocuments.mx/reader031/viewer/2022022421/5a84c7c47f8b9a882e8bc4fe/html5/thumbnails/36.jpg)
Takeaways
• Amibroker is fairly easy to set up but able to handle complex concepts• Backtesting is doable and should be done before you use real money• Forward testing is required if you want to see how a strategy will behave
If you are not rigorously testing your strategies, particularly as they might behave in a recessionary downturn, now is a time to start.
Mark Bates, [email protected]
36