Free Algo Strategy.pdf

  • Uploaded by: Enrique Blanco
  • 0
  • 0
  • January 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Free Algo Strategy.pdf as PDF for free.

More details

  • Words: 4,125
  • Pages: 31
Loading documents preview...
Algo Trade The Strategy Factory® Way

A FULLY DISCLOSED Trading Strategy For the Mini S&P and The Micro Mini S&P

Copyright © 2020 by Kevin J Davey. All Rights Reserved. All rights reserved. No part of this book may be reproduced in any form or by any electronic or mechanical means including information storage and retrieval systems, without permission in writing from the author. The only exception is by a reviewer, who may quote short excerpts in a review.

Kevin J. Davey Visit my website at KJTradingsystems.com Printed in the United States of America First Printing: January 2020 Update March 2020

Contents DISCLAIMER................................................................................................................................................... 5 Introduction .................................................................................................................................................. 6 Let’s Start With The End ............................................................................................................................... 7 Don’t Forget About the ELD and Tradestation Workspace........................................................................... 8 March 2020 Update ...................................................................................................................................... 8 How I Developed This Strategy ................................................................................................................... 10 Goals and Objectives................................................................................................................................... 11 Trading Idea ................................................................................................................................................ 12 Preliminary Testing ..................................................................................................................................... 13 Walkforward Testing................................................................................................................................... 14 Monte Carlo Testing.................................................................................................................................... 17 Incubation ................................................................................................................................................... 19 Diversification and Position Sizing .............................................................................................................. 21 Full Money Operation ................................................................................................................................. 22 Strategy Rules – Plain English ..................................................................................................................... 23 Strategy Rules – Tradestation Format ........................................................................................................ 24 Conclusion ................................................................................................................................................... 29 ABOUT THE AUTHOR – KEVIN J. DAVEY ...................................................................................................... 30

DISCLAIMER Data, information, and material (“content”) is provided for informational and educational purposes only. This material neither is, nor should be construed as an offer, solicitation, or recommendation to buy or sell any securities. Any investment decisions made by the user through the use of such content is solely based on the users independent analysis taking into consideration your financial circumstances, investment objectives, and risk tolerance. Neither KJTradingSystems.com (KJ Trading) nor any of its content providers shall be liable for any errors or for any actions taken in reliance thereon. By accessing the KJ Trading site, a user agrees not to redistribute the content found therein unless specifically authorized to do so.

Individual performance depends upon each student’s unique skills, time commitment, and effort. Results may not be typical and individual results will vary.

U.S. Government Required Disclaimer - Commodity Futures Trading Commission states: Futures and Options trading has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to Buy/Sell futures, stocks or options on the same. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed in this document. The past performance of any trading system or methodology is not necessarily indicative of future results.

CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS SHOULD BE YOUR OWN.

Email: kdavey at kjtradingsystems.com

Introduction Have you heard the saying “Give a man a fish, and he eats for a day. But teach a man to fish, and he can eat for a lifetime?”

That is my general philosophy for trading. I like teaching traders how to fish like I do. This book, however, is a bit different. This book gives you a fish (strategy) you can trade for yourself with the mini S&P or the micro mini S&P. It is very similar to a strategy I currently trade myself. It is fully disclosed, I hold nothing back with it. It is your free “fish!” In this book, as I reveal the strategy, I also teach you a bit of how I created it. That way you can follow my process to develop your own algo trading strategies. In the long run, developing your own strategies is the best way to reach success. So, this book is a fish, with some fishing instruction added in. The best of both worlds, maybe?

Thanks for downloading this book, and let’s get started!

Let’s Start With The End Before you get too far, I thought I’d share the equity curve for the algo strategy given in this book:

As you can see, it has performed pretty well in a walkforward backtest, and also for 6+ months of real time simulated trading (the light blue shaded area). You’ll get all the rules fully disclosed. If you use Tradestation, you’ll also get the code in Easy Language format, along with a workspace with the strategy built in both a mini S&P chart (@ES.D) and a micro mini S&P chart (@MES.D).

Don’t Forget About the ELD and Tradestation Workspace To help you out, I have included a simple ELD (Tradestation code file) and Tradestation workspace (Tradestation chart file) as part of this package. It includes all the code. I have included 3 charts in the workspace: @ES.D 5 minute (mini S&P) @MES.D 5 minute (micro mini S&P) @NQ.D 5 minute (mini Nasdaq)

Of course, you can copy the try the strategy on other markets, and other bar sizes too. This strategy is free to use. If you have success with it, just drop me an e-mail – I love hearing from other traders!

March 2020 Update Due to volatile market conditions in February and March 2020, I added a “volatility filter” to the strategy. This can be switch on or off.

The idea behind this filter is described in this YouTube video: https://youtu.be/BzyijasW7gI

The performance with the volatility filter:   

Net Profit is decreased Max Drawdown is decreased Return to Drawdown Ratio is increased

With the filter, the strategy avoids trades during very volatile times. This is a very nice feature, as stop losses get hit a lot easier with more volatility.

Here is the performance as of March 6, 2020 with the volatility filter turned on:

How I Developed This Strategy I built this strategy in the same way I build all my strategies. I call my approach the Strategy Factory® approach. The United States Patent and Trademark Office has recognized this, so legally I am the only one allowed to teach it. The Strategy Factory process is a methodical, objective approach to developing algo trading strategies. It consists of steps, as shown below.

I am going to (quickly) walk you through this process as I develop the strategy.

Goals and Objectives Before you take a trip in your car, you usually know where you want to end up, right? Most of us don’t just hop in our car and start driving without some sort of destination in mind. In other words, you have a goal – a destination – and your plan is to drive there. The same principle applies if you are creating an algo trading strategy. You have to know what you want before you start. Otherwise, how will you know when you get there? My goal for this exercise was to create a strategy for the mini S&P that had certain characteristics and performance metrics, some of which I reveal later on.

KEY POINT: Have a goal in mind for any trading strategy you develop. If you don’t, you’ll constantly be trying to improve the strategy backtest by adding rules and filters. And trust me, that is NOT a good thing to do!

QUESTIONS YOU MAY HAVE: What is a good goal for an algo trading strategy?

Trading Idea Any good trading strategy starts with an idea. For this strategy, I took an idea that I heard in a webinar by well known trader Art Collins. He has a lot of cool trading ideas and strategies, and I encourage you to check him out. His idea was that the opening 5 minutes of the mini S&P (using traditional stock market hours) is key to determining the short term direction of the market. Using 5 minute bars, if the low of the 2nd bar of the day is greater than the open of the 1st bar, that is a good buy indicator. And vice versa for short trades: if the high of the 2nd bar of the day is less than the open of the 1st bar, that is a good sell short indicator. So that was what I started with, but not where I ended up. That is my usual method of operation – I take an idea I find, modify it, add to it and make it my own. In this case, I made the following modifications:    

Added in an entry filter based on the RSI indicator Added in a rule to trade only if near term momentum was in my favor Added in an exit to get out of short trades relatively quickly if they are in profit Added a stop loss

KEY POINT: Every trading strategy starts with an idea. It could be an idea you develop from scratch, or an idea you found from someone else, and then modified (if desired).

QUESTIONS YOU MAY HAVE: How do I know if an idea is good or bad? Where do I find ideas?

Preliminary Testing Archaeologists have just uncovered a beautiful vase in the Egyptian desert. But they don’t know if it is a week old, or 10,000 years old. Have you ever wondered how scientists figure out how old the object is? Many times they use a carbon dating test. They take a small piece of the object, and run a test on it to determine its radioactivity. That allows them to determine how old the object is. The problem is that the test destroys the test sample. So, they only use a small piece of the original object. But, the smaller the piece, the more uncertainty in the age calculation. If they tested the whole object, they’d get a pretty accurate age estimate. But then the object would be completely destroyed! I view testing algo trading strategies in the same way. One thing I avoid when testing a strategy is making a lot of changes to the strategy, and then testing on all the historical market data. When I do that, I am basically destroying the data. So, when I am first testing a strategy, I only use a limited amount of market data. Then, I feel safe about adding rules and filters, and performing some optimization, without fear of curve fitting or over optimization (two HUGE issues all strategy developers should be worried about). All the changes I made to Art’s original idea? I first tested them all on a small piece of market data, and determined they were worth keeping.

KEY POINT: As you develop a strategy, don’t test on all the data until you are completely done adding rules and filters.

QUESTIONS YOU MAY HAVE: How many rules should my strategy have? How much optimization can I safely do? How do I determine ranges for the variables I want to optimize? Should I include slippage and commissions in my testing, and if so, how do I estimate it?

Walkforward Testing Once I have a strategy that I think has potential, I run the “big” test, with all the historic market data. For this, I use a process called walkforward testing. This is a complicated test, and I provide a high level explanation here: https://kjtradingsystems.com/walkforward-testing-for-algorithmic-trading.html

With the software I use, the result of the walkforward testing is shown below:

The tool I use provides parameter values that change with time, based on my selection of walkforward testing specifics (anchored/unanchored, IN sample time period, OUT sample time period, objective fitness function, etc.) Here is an example of walkforward code, for Tradestation Easy Language: if date >= 1140107 and date < 1150107 then begin

stopL = 40 ; end ; if date >= 1150107 and date < 1160107 then begin stopL = 40 ; end ; if date >= 1160107 and date < 1170106 then begin stopL = 35 ; end ; if date >= 1170106 and date < 1180108 then begin stopL = 35 ; end ; if date >= 1180108 and date < 1190109 then begin stopL = 40 ; end ; if date >= 1190109 and date < 1200109 then begin stopL = 40 ; end ; if date >= 1200109 and date < 1210109 then begin stopL = 25 ; end ;

There is quite a bit to set up and figure out with walkforward testing, but once you do it a few times, it becomes fairly routine and straightforward.

KEY POINT: Take some time to learn walkforward testing, and how it works, before attempting it. AND Don’t make any changes to your trading strategy based on your walkforward test results – that is cheating!

QUESTIONS YOU MAY HAVE: How do I pick walkforward parameters such as IN period and OUT period? Why is walkforward testing considered “out of sample?” Do I really have to do this testing, instead of just a normal optimization?

Monte Carlo Testing With the results of walkforward testing, you can proceed to the next step in the process, which is Monte Carlo testing. Monte Carlo testing helps you determine if your strategy is acceptable. The math behind it is a little complicated, and is based on the same principles used to computer simulate atomic explosions. Luckily, we use it for a far less dangerous purpose! Just as with walkforward testing, there is a lot to Monte Carlo testing. I discuss it in more detail here: https://towardsdatascience.com/improving-your-algo-trading-by-using-monte-carlo-simulation-andprobability-cones-abacde033adf And, if you go to my website, you can download a free Monte Carlo and Probability Cone spreadsheet from my Calculator page: https://kjtradingsystems.com/calculators.html For the strategy in this book, here is a snapshot of the Monte Carlo analysis results, and the Probability Cone:

KEY POINT: Monte Carlo analysis is a great way to determine if your strategy is a good one, based on risk adjusted return.

QUESTIONS YOU MAY HAVE: What numbers should I be looking at with Monte Carlo results? How can I use Monte Carlo to tell me if a strategy is worth trading? Can Monte Carlo analysis tell me if a strategy is “too good” and possibly curve fitted?

Incubation Once the strategy passes   

Preliminary Testing Walkforward Testing Monte Carlo Testing

It is time for one final test before trading the strategy with real money. I call this test “Incubation.” During this test, you watch how the strategy performs live, without risking actual money. The figure below shows the performance during a typical incubation period, shown in the light blue circle. Based on its performance, this strategy is a “pass!”

KEY POINT: Incubation can reveal many issues with a strategy, BEFORE you actually commit real money to it.

QUESTIONS YOU MAY HAVE: What is acceptable performance during incubation? Do I really have to incubate? I just want to trade! What development mistakes can incubation uncover? What mistakes can’t it uncover?

Diversification and Position Sizing After a successful incubation, which the strategy described in this book has passed, you have some confidence that the strategy is acceptable to trade with real money. But unless you only trade one strategy, you need to do some work first. You need to see if this strategy fits in with your other strategies. Does it provide more diversification to your portfolio, or does it add more risk? And what position size approach should you use for this strategy? Developing the strategy is obviously the first step, but remember to address these other issues before launching into full money operation.

KEY POINT: Once the strategy is ready to trade live, there are other considerations that you need to address. Diversification and Position Sizing are two very important areas to look at.

QUESTIONS YOU MAY HAVE: I really do not like this strategy, even though it makes money. Should I trade it? How do I determine if my new strategy provides more diversification, instead of more risk? What kind of position sizing technique is best? How many strategies do I need to be adequately diversified?

Full Money Operation Congrats! Now you are ready to trade the strategy with real money. Of course, a strategy could fail to work at any time. Strategies break – just ask traders who followed the “Turtle” method, or traders who exploited the Swiss Franc/Euro peg a few years ago. So, you need to be prepared for that. Instead of a failure scenario, hopefully the strategy will be profitable, and your account will grow. Then you can either add size to your existing strategies, or you can introduce new strategies to your portfolio. With walkforward strategies, you also have to occasionally re-optimize the strategy to keep it “fresh.” Regular review of your strategies is important as you trade with real money. It is not as simple as “set and forget.” This is a trading BUSINESS, not a trading hobby. Make sure you treat it that way.

KEY POINT: Once you start real money trading, there are still daily and monthly tasks you must perform. Failure to maintain your portfolio will likely lead to losses.

QUESTIONS YOU MAY HAVE: How do I know if a strategy is broken? I am trading futures – how do I rollover my position? How do I create and manage a portfolio of strategies? Should I be automating my strategies?

Strategy Rules – Plain English 1. Set up your chart with the mini S&P, 5 minute chart, starting at 8:30 AM Exchange time, and ending at 3:15 PM. 2. Record the open of the first bar of the day, and refer to it as “openp” 3. At the close of the second bar of the day (at 8:40 AM) go long if: A. The low of bar 2 is greater than openp B. The 5 bar RSI indicator is below 50 OR both the close if greater than previous bar close AND the close if greater than close 2 bars ago 4. At the close of the second bar of the day (at 8:40 AM) go short if: A. The high of bar 2 is less than openp B. The 5 bar RSI indicator is above 50 OR both the close if less than previous bar close AND the close if less than close 2 bars ago 5. If you are in a short trade, and the time is after than 11:00 AM and the position is profitable, exit at the open of the next bar. 6. Have a stop loss at “stopl” points from entry. As of 2020, the value of stopl is 25 points, which is $125 for MES and $1250 for ES. This parameter has to be updated every year, using walkforward analysis. 7. If neither rule 5 nor rule 6 is hit, stay in the trade until either is hit, or the trade reverses via rules 3 or 4. 8. To add the volatility filter: A. Use the variable CANTRADE to allow trading (or not). When CANTRADE=True, then trading can occur. B. If the true range of the daily bar is greater than the average true range of the last 5 daily bars, then: 1. No new trades can be entered 2. Any existing trades should be closed out C. If the true range condition is not met, then trading should proceed as usual.

Strategy Rules – Tradestation Format Here is the strategy, in Tradestation Easy Language format:

Use @ES.D or @MES.D 5 minute bars, with Exchange time for the chart.

//based on Art Collins webinar //modifications by Kevin J. Davey // // // www.kjtradingsystems.com // [email protected] // //Development completed June 30, 2019 // //ATR "Can Trade" Switch added March 2020 // See video for details: https://youtu.be/BzyijasW7gI // // //non symmetrical exit (OK for stock indices)

{Chart Info: Symbol#1

@MES.D, @ES.D

Bar Length

5 min

Symbol#1

@ES.D

Bar Length

Daily

Start Date

1/1/2012

End Date

present

Session regular

Strategy Name:

Strategy - Properties For All: General Tab Commission (per Share/Contract)

.64 MES, 2.5 ES

Position Slippage (per Share/Contract) 1.25 MES, 12.5 ES Back Testing Resolution check/not checked

not checked, 1 min bars

Details if checked Max Number of bars study will reference Position limits checked/not checked

50

not checked

Details if checked Backtesting Tab "Fill Entire Order when trade price exceeds limit price" must be chosen

Walkforward Optimization: Total Iterations: 7 IN Period (trading days):

504

Out Period (trading days):

252

Fitness Function:

net profit

Anchored/Unanchored: unanchored Parameters, Ranges: Stopl=20-50, step 5

Additional/Extra Info: } input:CanSwitch(1); //=0 with no ATR on/off switch, =1 with ATR on/off switch

variables: stopL ( 0 );

if date >= 1140107 and date < 1150107 then begin stopL = 40 ; end ; if date >= 1150107 and date < 1160107 then begin stopL = 40 ; end ; if date >= 1160107 and date < 1170106 then begin stopL = 35 ; end ; if date >= 1170106 and date < 1180108 then begin stopL = 35 ; end ; if date >= 1180108 and date < 1190109 then begin

stopL = 40 ; end ; if date >= 1190109 and date < 1200109 then begin stopL = 40 ; end ; if date >= 1200109 and date < 1210109 then begin stopL = 25 ; end ;

var: openp(2),CANTRADE(TRUE);

CANTRADE=TRUE; If CanSwitch=1 and TrueRange of data2>AvgTrueRange(5) of data2 then CANTRADE=FALSE;

if date >= 1140107 and CANTRADE=True THEN begin

If time=835 then openp=open;

If time=840 then begin

If low>openp and (RSI(close,5)<50 or (c>c[1] and c>c[2])) then begin buy next bar at market; end;

If high50 or (c
end;

If time>=1100 and openpositionprofit>0 then begin

Buytocover next bar at market; end;

setstoploss(stopl*BigPointValue);

end;

If CANTRADE=False then begin Sell next bar at market; Buytocover next bar at market; End;

Conclusion Well, we’ve come to the end of this book. But, it is only the beginning of your algorithmic trading journey. Feel free to use the strategy I provided, either as is, or with whatever modification you desire. Just remember to test any changes first! If you want to learn more about developing your own algos, check out my award winning Strategy Factory workshop. In it, I address all the questions I have listed in this book, plus much, much more. WARNING: My course is only for serious traders – those who want to take their algo trading to the next level. It requires a significant time commitment, and a money commitment too (although my course can be free via a Rebate Program I have with Tradestation). It is not for everyone.

Good Luck, and please let me know of your algo trading success!

ABOUT THE AUTHOR – KEVIN J. DAVEY

As an award winning full time trader, and best-selling and award winning author, Kevin Davey has been an expert in the algorithmic trading world for several decades. Between 2005 and 2007, Kevin competed in the World Cup Championship of Futures Trading, where he finished first once and second twice, achieving returns in excess of 100% each year. Kevin develops, analyzes, and tests trading strategies in every futures market from the e-mini S&P to crude oil to corn to cocoa. He currently trades full time with his personal account. He also helps small groups of traders significantly increase their trading prowess via his award winning algorithmic trading course, “Strategy Factory®.” Kevin’s Strategy Factory Workshop was awarded 2016 “Trading Course of The Year” by a prestigious trading website. Kevin also helps educate the trading community via his 4 best-selling winning books: “Building Winning Algorithmic Trading Systems” “Introduction To Algo Trading” “Entry and Exit Confessions Of A Champion Trader” “Stock Market Investing For Everyone” All these books are available at amazon.com.

Kevin is a Summa Cum Laude graduate of The University of Michigan, with a B.S.E in aerospace engineering. Kevin also has an MBA with Technology Management Concentration from Case Western Reserve University – Weatherhead School of Management, where he received the Dean’s Academic Achievement Award with a perfect 4.0 grade point average.

Prior to trading full time, Kevin was Vice President of Quality and Engineering for an aerospace company that designed and manufactured flight critical components, managing over 100 engineers and support staff. For his efforts, he was honored with the prestigious “40 Under 40” Award from Crain’s Cleveland Business Magazine. Kevin currently lives outside of Cleveland, Ohio with his wife and three children.

Related Documents

Free Algo Strategy.pdf
January 2021 1
Tft Algo Reference Sheets
February 2021 2
Algo Va Mal
March 2021 0
Free
February 2021 2
Free
March 2021 0

More Documents from "GOOGLEERR"

Free Algo Strategy.pdf
January 2021 1
February 2021 0
January 2021 4
Collected Works Vol 1
January 2021 2