+ All Categories
Home > Documents > Designing Strategies

Designing Strategies

Date post: 07-Apr-2018
Category:
Upload: scribd121979
View: 224 times
Download: 0 times
Share this document with a friend

of 44

Transcript
  • 8/4/2019 Designing Strategies

    1/44

    d r . j o h n c l a y b u r g

    Designing and Using Automated Trading Strategies

  • 8/4/2019 Designing Strategies

    2/44

  • 8/4/2019 Designing Strategies

    3/44

    c o n t e n t s

    Chapter 1: What Is an Automated Trading Strategy?........... 1

    Chapter 2: First Steps in Designing a Success ul System.... 7

    Chapter 3: Back-Testing and Optimization.....................13

    Chapter 4: Exits Are Critical............................................ 21

    Chapter 5: Fully Automated Trading...............................25

    Chapter 6: Implementing Your Automated Strategy ........ 29

    Designing and UsingAutomated

    Trading Strategiesdr. john clayburg

  • 8/4/2019 Designing Strategies

    4/44

    Disclaimer

    Trading involves the risk o loss. Please consider care ully whether trading is appropriate to your inancial situation.Only risk capital should be used when trading the inancial markets. Past results are not necessarily indicative o

    uture results. The risk o loss in trading can be substantial; please care ully consider the inherent risks o any suchinvestments in light o your personal inancial situation.

    All in ormation and ideas expressed in this book are based on the opinions and experiences o the author. In thisregard, neither TradeStation nor any o its employees are responsible or the content contained herein, nor do they express an opinion or endorse any o the contents.

    While the author has personally used the in ormation he is providing in this book to pro itably trade in the oreignexchange and other markets, he is o ering this in ormation purely as a guideline based on his experience. You as atrader, i you decide to accept and apply the ideas and in ormation contained herein, do so at your own risk.

    No part o this publication may be reproduced, stored in a retrieval system, or transmitted in any orm or by any

    means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Section107 or 108 o the 1976 United States Copyright Act, without the written permission o TradeStation or the author.

    This publication is designed to provide accurate and authoritative in ormation in regard to the subject matter covered.It is o ered with the understanding that neither TradeStation nor the author is engaged in rendering pro essionalservices. I expert advice or other expert assistance is required, the services o other competent pro essionals shouldbe sought.

    Copyright 2009 by John Clayburg. All rights reserved.

  • 8/4/2019 Designing Strategies

    5/44

    1

    c pte 1What is an automated trading

    strategy?

    Why Use One? An automated trading strategy is created when a trader or programmer designs a giventrading system and then writes the system into computer code using TradeStations built-inEasyLanguage. The resulting program then calculates and graphically represents all tradingdecisionsentries, stops, targets, etc., on your trading chart. I so desired, this same program will place and ill the orders at the appropriate exchange where the item in question isactually traded in real time.

    Be ore we deal with the speci ics o automated strategy trading, lets be sure that weunderstand the di erences between discretionary and automated trading.

    Trading on a discretionary basis is probably the method with which most traders will havethe greatest amiliarity. Also re erred to as manual trading, this is a method whereby thetrader will accumulate a variety o data, be it undamental or technical, and then make abuying or selling decision based on this analysis. For example, i the latest non- arm payrollreport is considered bullish, housing starts are greater than anticipated by the market, thestochastic divergence is positive, and momentum crosses above zero, then one may decideto buy the S&P 500 index. This trade requires that the trader analyze each o these actorsindividually, make the decision, and then manually pull the trigger.

    figure 1

  • 8/4/2019 Designing Strategies

    6/44

    2

    Figure 1 is an example o a discretionary trade setup utilizing our common technicalindicators.

    First, the trader notices that momentum, a basic tool used or trend de inition, is greaterthan zero and is in an uptrending pattern. Second, the Relative Strength Index (RSI)con iguration is bullish, being above 50 and also uptrending. Third, another trend de initiontool, the Parabolic Indicator, is in an uptrending mode below the price bars. Finally, the tradeis con irmed with the appearance o an upside key reversal bar.

    To complete this entry and to success ully ollow this trade setup in the uture, our tradermust actively monitor each o these our indicators accurately and intensively throughout thetrading session.

    Those utilizing the power o TradeStation to totally automate their technical trading routinesallow the EasyLanguage programs created on the plat orm to per orm all the calculationspertinent to the programmed trade setup and then utilize the order-execution network to place and ill the trades. I so designated, the same procedures can manage the trade,automatically entering and maintaining protective stops, calculating and placing limit ordersor pro it targets, or appropriately adjust trailing stops instantly when necessary.

    In Figure 2 above, the identical trade entry is generated by an automated strategy programmed using TradeStations EasyLanguage. The program accurately identi ies eachcomponent (Momentum, RSI, Parabolic, and Key Reversal Up) and places a buy arrow on the actual chart when all o the conditions that make up the entry are satis ied. I thetrader takes the steps necessary to automate the process, the trade is automatically placedimmediately at the appropriate exchange with no other decision process needed. Executionis instantaneous and accurate, removing much o the e ort and stress involved in placing asimilar trade using a discretionary approach. Each trade is placed utilizing the exact setupdesired, drastically removing the possibility o trader error in a ast-moving market.

    figure 2

  • 8/4/2019 Designing Strategies

    7/44

    3

    Advantages of Automated Trading

    Advantages realized when using an automated strategy are many and varied.

    First and oremost, all calculations and the analysis o the various trading components that

    make up the actual trade setup are per ormed accurately and identically each time the tradeconditions are satis ied. Additionally, i autotrading is enabled, the trades are placed andilled instantaneously at the appropriate exchange, resulting in execution superior to that o any manually placed order.

    Automated trading also makes accurate, simultaneous trading o multiple markets possible. While this can be done manually, the e ort required to do so is reduced exponentially usingautomation.

    While it is possible to back-test a manually traded routine by reviewing the various tradesetups on historical charts, most ind the wealth o trade data and graphical displays createdby back-testing an automated strategy much more use ul. Data generated in this ashion canthen be used to more clearly de ine the desired trading pattern.

    Last but not least, most traders utilizing strategy automation enjoy a signi icant reduction inthe stress o trading. Rather than being pressured to constantly evaluate a trade setup or openposition and then make proper decisions, the traders role is reduced to the active monitoringo the system. All entries and stops are handled by the computer program, thereby taking

    much o the trading burden o the shoulders o the trader.

    Accuracy and Efficiency

    Order generation is signi icantly more accurate when the computer is allowed to crunchall the data and make the appropriate comparisonsespecially when the market ismoving astwhen real bullets are lying. It is one thing to think and act accurately whenormulating a strategy o line or while paper trading. It is quite another task to do thisduring live trading with real money on the line.

    For example, it is the tendency o most traders to avoid taking a loss, even when it is obviousthat the current trade is going south aster than a lock o geese in November. I I just giveit a little more time, itll go back in my direction has led many traders to allow smaller,acceptable losses to turn into devastating reductions in a trading account. Automating themoney-management phase o a trade removes emotion rom the equation and allows thetrader to ollow a logical, realistic, and statistically proven process to exit a trade and preservecapital.

    Automation also drastically improves entry and exit e iciency as the orders are placed literally milliseconds a ter the trade setup is completed. O ten this can be the di erence in getting thedesired ill, as it can obviously take longer to con irm and place the trade manually, especially i one reviews the setup multiple times just to be sure the trade is right.

  • 8/4/2019 Designing Strategies

    8/44

    4

    Simultaneously Trading Multiple Markets

    Trading multiple markets simultaneously is di icult even or the most experienceddiscretionary trader. While it is possible to trade several items at once, the mental strain thatcan result rom monitoring several indicators on separate charts simultaneously can lead to

    trading errors, especially in a ast market. When utilizing the e iciency o automated strategy calculation and execution, one has the ability to easily trade several disparate items at thesame time. While it is certainly necessary to monitor all o your actively trading charts, thee ort necessary to simply ensure that no errors have occurred is certainly much less than thato constantly monitoring multiple events on several charts.

    O ten the discretionary trader will get bogged down during the many decisions that may benecessary to make a trading decision. Many individuals get lost in the weeds when analyzingcomplex trading plansparalysis by analysis has been the down all o more than one

    otherwise good trader. Great opportunities can slip away be ore being acted on in a timely ashion. When using automated trading, many times the irst hint o a programmed tradesetup being active is getting the ill back rom the exchange. Automation makes it almostimpossible or calculation delays to a ect timely trade placement.

    Test Before You Trade

    Undoubtedly the superior advantage o strategy automation is the ability to accurately back-test any programmed trading system. Although a success ul strategy testing result does notby any means guarantee a pro itable trading experience, the process itsel is invaluable to thedevelopment o a programmed system. The ability to examine hundreds o simulated tradeson historical data can quickly identi y overlooked situations or actual errors in the tradingstrategy that can be corrected be ore actual live trading commences.

    figure 3

  • 8/4/2019 Designing Strategies

    9/44

    5

    Each individual automated strategy on a speci ic chart will generate a Strategy Per ormanceReport that contains data unique to the system on the chart.

    The graphic on the previous page (Figure 3) illustrates a small portion o the data generatedin a Strategy Per ormance Report, which can be used by the trader or strategy developerto analyze the net result o the system had it been traded historically using the data rangeprovided to the underlying price chart. The results detailed on these reports are invaluableor evaluating the productivity o the system. Furthermore, this in ormation can be usedto provide indications o parameters within the strategy that can be altered to ultimately improve the net pro itability o the underlying system.

    Contained within the TradeStation plat orm is an extensive Help section detailing thede initions o the various data categories in the per ormance report. Suggestions are alsoprovided explaining the interactions o various strategy properties and methods by whichthey can be altered to alter the unctionality o the strategy.

    Another very use ul eature o the Strategy Per ormance Report is the automatically generatedEquity Curve Line, an example o which is illustrated above (Figure 4). These graphs, while use ul in the initial development o a system, are invaluable when used to evaluatethe per ormance o a system when it is actually trading on real-time data. Comparing thehistorical per ormance o a strategy to the results obtained rom real-time trading can quickly aid the trader in deciding when adjustments may be necessary to the system.

    Although it is certainly possible to manually examine price charts and identi y tradesgenerated by a de ined trading system, it quickly becomes evident when examining theresults o a back-tested strategy that the human eye can be very selective when identi ying

    figure 4

  • 8/4/2019 Designing Strategies

    10/44

    6

    winning and losing trades. The increased testing accuracy derived rom a properly programmed system can certainly be the di erence between a sound strategy and one thatjust looks good.

    Reduction of Trading Stress

    Trading a live market is a stress ul task regardless o the simplicity or complexity o thetrading routine, experience o the trader, position size, etc. Also, many traders ind it di icultto pull the trigger and enter a trade or place an exit orderagain adding to the stress o theendeavor. Once the trader gains con idence in an automated system and allows the programto handle most, i not all o the trading decisions necessary to complete a trade, much o thisstress goes away. Although this eature may be more important to some than others, the actremains that many traders would be success ul i they could simply ollow their trading planin a disciplined manner. O ten it is the stress o trading that prevents the accurate and timely

    execution o a trading plan. Many ind that the reduction in stress that goes along withautotrading makes a signi icant di erence on the bottom line o their trading account.

    Conclusion

    There are signi icant di erences between discretionary and automated trading.1. A computer program can accurately and quickly calculate and execute trade2.setups and exits. Autotrading simpli ies simultaneous trading o multiple markets.3.It is possible to test a strategy be ore trading it live.4.Many traders report a signi icant reduction in the stress o trading when using5.an automated system.

  • 8/4/2019 Designing Strategies

    11/44

    7

    c pte 2first steps in designing a

    successful system

    There are ew absolutes in the worldrarely is it wise to use the words always or never when describing speci ic situations. Never say neverweve all heard that one.

    Im going to make a glaring exception herei there is anything approaching near-absolutecertainty in the world o system development, it is that the simpler the system, the greaterthe likelihood o pro itability.

    In over 20 years o systems programming or many individuals and irms rom Wall Street toMain Street, it has become obviousin some cases, pain ully obviousthat simplicity reigns when it comes to strategy development.

    Some o the most success ul traders I know simply concentrate on one or two indicatorsapplied to one or two items. They actually spend most o their trading days on otheractivities waiting or their programmed alerts to enter or exit designated positions. They willsay in con idence that their days are incredibly boringbut very pro itable.

    The bottom line is that it doesnt need to be complicated to be pro itable.

    On the other hand, I have created strategies that encompass page a ter page o EasyLanguagecode in an attempt to conquer every twist and turn o the market, including multi-conditional entries, complex exits, re-entries, alternating stop routines, and on and on. Rarely i ever have these programming migraines proven to be success ul.

    When you drill down to the basics o any strategy, you come up with the same resultwhat we are attempting to do is accurately predict uture price activity within a reasonableprobability range. It logically then ollows that to do so requires that we stay as close to thecurrent market price as possible when making our calculations and recognizing reliable chartpatterns. Many systems actually over-analyze price movement to the degree that the endresult becomes a lagging indicator incapable o reacting e iciently in a real-time situation.Creating an RSI o a Stochastic plot and then calculating a moving average o the resultingsolution is only one example o over-analyzing price movement and ending up with a laggingindicator or trading strategy. O ten the major portion o the move is over be ore a lagging seto calculations can identi y the current trend.

    Also think about this onewhenever we apply technical analysis to a price chart, what weare e ectively attempting to accomplish is the mathematical prediction o human behavior.

  • 8/4/2019 Designing Strategies

    12/44

    8

    All price activity on any item is the result o human interactionwhether it is trading ina pit, discretionarily placing trades or programming a computer to place the trades using apre-determined solution. While it is inherently problematic to create an objective solution toa subjective situation, it only becomes more complicated when one attempts to over-analyzethe problem mathematically.

    Step One: Chart Analysis

    Yogi Berra would probably say, You can see a lot by just watchin. Thats the irst step inormulating a strategyyou must spend a lot o time simply observing multiple price chartssearching or what would appear to be a repeatable, pro itable trading setup.

    Keeping with the simple is best routine, heres a typical two-item, reliable setup usinga single moving average line and the popular Relative Strength Indicator. In this example

    (Figure 5), a buy signal is generated when the RSI dips below 40 while the 200-bar movingaverage is trending higher.

    Now that we have ormulated a testable buy signal, the next step is to design an exit or ourstrategy. Looking at this chart (Figure 6) only, it is obvious that an RSI signal greater than 65

    will produce a pro itable exit or each o our trades.

    figure 5

  • 8/4/2019 Designing Strategies

    13/44

    9

    The chart below (Figure 7) illustrates the hypothetical results generated by our programmedstrategy.

    figure 6

    figure 7

  • 8/4/2019 Designing Strategies

    14/44

    10

    Step Two: Test the System

    Our automated strategy appears to be pro itable, at least on this chart. But what aboutother days? This is where the ability to back-test a strategy over a large amount o historicaldata enters our system-creation process. Only by looking at the data generated by these

    simulations will the trader be able to ascertain the value o this approach to actual trading.Testing may indicate the necessity o changing our system inputs (moving average length,RSI buy and sell levels), adding other ilters such as time o day to begin and end trading, orusing actual dollar stops and target levels.

    Few i any o these necessary adjustments would be possible without the availability o historical testingonly available when the system is set up as an automated strategy.

    TradeStations extensive Strategy Per ormance Report provides a great deal o detail onthe per ormance o your system, both numerically and graphically. You are able to analyzealmost any parameter o system per ormance that you choosebe it net pro it, pro it actor,percentage o winning trades, number o consecutive winners and losers, drawdown, periodicresults by the day, week, month or year, to mention only a ew. While not everyone will useevery analysis category available, it would be the rare individual who could not ind adequatedata here to check out a system. These reports are discussed in more detail in the nextchapter.

    However, these reports should not be the end-all or strategy per ormance analysis. Many detailed and technically oriented traders and developers o ten all into the trap o con iningtheir system analysis to the statistical approach alone. Frequently this data-only-based analysiscan cause the trader to overlook signi icant details o strategy per ormance that will havea de inite impact on uture per ormance. For this very reason, I always encourage tradersto not only go over per ormance data but also care ully examine the actual trading chartor obvious errors or impractical trades that may have been generated by the strategy. Forexample, you may notice that speci ic time periods during the trading day may be generatingmany long and short trades in rapid succession due to market congestion. This activity can

    certainly impact both the pro itability and consistency o the strategy. While this scenario cancertainly be corrected by a ew simple changes to the system code, it is highly unlikely thatthe problem would have been discovered strictly by examining the numbers generated in theStrategy Per ormance Report.

    A ter all, you originally designed your strategy by examining a series o price charts. Dontabandon these examinations during the testing phase.

    Step 3: Keep It Practical

    Simplicity o system design is not the only actor that can lead to a success ul systemtheroutine itsel also has to be practical in the real world. A strategy designed to trade 30 timesper day using a 3-cent pro it objective while using a 25-cent protective stop is not likely tolive long in the real world. Although this system may look good on a chart and may support

  • 8/4/2019 Designing Strategies

    15/44

    11

    decent back-testing results, it doesnt take much imagination to understand that a single stopout that wipes out the pro it on the last 9 trades is not a reliable solution.

    Remember this modi ied KISS principleKeep It Simple and Sensible.

    Match Your Trading Style Your strategy must duplicate or at least complement your own personal trading style. You will not be e ective trading it i you dont believe in the basic theory. Everyone has hisown trading styleeven i you have never placed a trade in your li e. You know your risk tolerance, how o ten you want to trade, which markets you understand, etc.

    O ten the most di icult part o making a system work or you is having the con idence toturn it on and allow it to actually trade a live market. A ter all, trading is basically a head

    gameits o ten stated that 75% o trading is psychological. Many will question each andevery trade that is generated by their own strategy and will o ten immediately exit the trademanually at a small loss or modest pro it only to watch it go on to a much more pro itableconclusion.

    Designing your automated strategy around your own personal trading style will make itmuch easier to actually trade the system a ter it is completed and tested.

    Conclusion

    The oremost rule o strategy design is to keep it as simple as possible.1.The amount o time spent studying price charts and indicators is directly 2.proportional to the quality o the completed strategy.Proper testing is critical.3.Re er to price charts regularly during the development process.4.Ensure that the inal product places practical trades in real time.5.Strategies that closely match the trading style o the user have a much higher6.probability o success.

  • 8/4/2019 Designing Strategies

    16/44

  • 8/4/2019 Designing Strategies

    17/44

    13

    c pte 3Back-testing and optimization

    Strategy back-testing and optimization, which both utilize historical market data to createand ine tune an automated strategy, are actually distinct individual processes.

    Back-Testing

    Back-testing, as discussed brie ly in the previous chapter, is used both as a strategy development tool and a utility to evaluate system per ormance when real-time trading begins.

    The ability to observe trades generated by your strategy using historical data is anindispensable tool or automated strategy development. Each and every trade generated overa speci ic date range is displayed in digital and graphic ormats.

    Using back-testing or system development is airly straight orwardthe developer simply checks each trade on the chart to be sure all it the system pro ile. When deviations romexpected trades become evident, the programmer can then use this in ormation to makemodi ications in the code that will eliminate these errors.

    Back-testing can also be e ectively used to point out where supplementary strategy parameters or ilters may be necessary to improve the per ormance o the program.

    For example, one could discover that over the historical testing period, 5% o the trades aregenerating over 35% o the losses or the system and that the largest loss incurred over thetesting period was twice the value o the largest pro it or the same period. In this instance,the inclusion o a more responsive stop-loss routine will probably both reduce the amount o the average loss and cut the system drawdown to acceptable levels.

    Additionally, testing may indicate that trading the stock indices one hour each side o thenoon hour is much less pro itable than trading the remaining portions o the trading day. Inthis instance, it might be productive to include additional code in the strategy that wouldprevent trading during these periods.

    The range o possibilities or system improvement when utilizing reasonable system back-testing is limited only by the imagination o the trader/programmer. O course, all alterations will not necessarily be improvements. Testing a ter making these changes will make the inalassessment o whether or not to keep the alteration a simple decision.

    Optimization

    Using the optimization eature o TradeStation to ine tune a developed system can get tricky.

  • 8/4/2019 Designing Strategies

    18/44

    14

    Optimization can be either your best riend when used to properly ine tune a system or itcan be your worst enemy i used improperly, resulting in the creation o a curve- itted systemthat has little i any chance o success in the real world.

    The setup or an optimization run is airly straight orward. The screen below is accessedthrough the Format Strategies Inputs Optimize sequence.

    In Figure 8 above, the S1 input or the system is set up to test all values o the input rom 5to 25 with increments o 1.

    Figure 9 reveals that two separate inputs are being optimized simultaneously. In this instance,all values o both inputs are being tested rom 5 to 25 with increments o one. All otherinputs or the system are held at a static value or this test.

    figure 8

    figure 9

  • 8/4/2019 Designing Strategies

    19/44

    15

    While it is possible to test all system variables pertinent to a given system over any range o values simultaneously, the trader will quickly discover that the amount o time necessary to complete such a test increases exponentially with each added optimization parameter.Furthermore, testing all inputs concurrently carries with it the inherent danger o over curveitting the system to historical data, thereby signi icantly reducing the likelihood o systemsuccess in real-time trading.

    Here is the Strategy Optimization Report (Figure 10) that was generated by the optimizationparameters in the previous image above. While it is not practical to display all o the reportcolumns here, the data or the system input values, the net pro it resulting rom thesesettings, as well as the percentage o pro itable trades, number o actual trades generated,maximum intraday drawdown and consecutive winning and losing trades, are displayed.

    System settings o 22 and 12 or the S1 and S2 inputs (Figure 11, next page) have producedthe greatest pro it when the results o all 441 tests are compared.

    However, these are probably not the parameter settings that will produce the most consistentresults going orward.

    While at irst glance it may seem logical that choosing the highest pro itability inputselections above should lead to the best per orming system, quite o ten this is not the case when real-time trading is begun using these parameters.

    figure 10

  • 8/4/2019 Designing Strategies

    20/44

    16

    Take a close look at the All: Net Pro it column (Figure 12, next page)note how muchgreater the pro it is or the 22 & 12 settings than or any o the others below. Extreme resultssuch as these are the result o including several trades where the strategy bought at the exactlow o a big move and sold at the very top o the trend. This is what happens when you allow the computer to test all possible combinations o our two inputs and sort them by greatestpro itability. The likelihood o a number o these trades occurring in the uture is not great.These trades are termed outliers and should be disregarded or testing purposes.

    Next take a look at results 10 15. Note the consistency o the net return or all o thesecombinations. These results are unlikely to include these outlier trades, as their results are tooclose together to have accommodated several huge pro its. Since any o these combinationsis unlikely to include outlier trades, selecting any o these settings has a greater probability o success than simply picking the most pro itable result.

    This process is called Selective Optimization.

    The Danger of Over-Optimization

    As stated above, the optimization utility in TradeStation can be your best riend or your worst enemy.

    figure 11

  • 8/4/2019 Designing Strategies

    21/44

    17

    figure 12

    Many system traders, both new and experienced, will be tempted to continue to optimizemultiple variables over tighter and tighter ranges and in various combinations in an attemptto squeeze every cent o pro itability out o their strategy.

    While the initial observation may suggest a healthy pro itability pro ile or the strategy settings created as a result o this process, the reality is that such a system has little i any chance o success in real-time trading.

    When exhaustively testing a system using a speci ied data set, you are e ectively tightly curveitting the strategy to this speci ic data stream. Consequently, or this strategy setup to bepro itable in real-time trading, it will be necessary or uture market data to exactly match thehistorical data used or testing. Any reasonable person even vaguely amiliar with the markets will readily recognize that the likelihood o this event is highly improbable.

    There are several precautions one can employ to signi icantly reduce i not eliminate thepossibility o over curve itting and thus ruining a good system by over-testing.

    First o all, realize that testing too many inputs at the same time leads the optimizationutility to identi y an excessive number o outlying trades and thus skew the testing results

  • 8/4/2019 Designing Strategies

    22/44

    18

    to give in lated pro itability results. To avoid this possibility it is recommended that strategy inputs be tested in small groups. For example, a strategy employing 10 separate input values would give a more repeatable optimization result when testing 2 inputs at a time, e ectively requiring 5 separate optimization runs to complete the process. Although testing 3 5 inputsin each run will give a more pro itable result, there is a greater likelihood here o creating anover-optimized, curve- itted system.

    Additionally, do not attempt to create better and better hypothetical results by testing andretesting all system inputs in various ranges o values and in various combinations. Whiledoing so may markedly increase the level o pro it or the various tests, what you are actually accomplishing is over curve itting your system to historical data and markedly decreasing thechances o success in real time.

    Finally, use the Selective Optimization process discussed above to reduce the chances o outlier trades arti icially a ecting your choice o system inputs.

    Testing Your System in Real Time

    While back-testing and optimization are valuable tools or creating and testing an automatedstrategy, there is nothing like real-time experience to reveal the validity o your programmedsystem. It is a very valuable exercise to observe the system trading on real-time data a terall the testing and resetting has been inished. You will know in a rather short time i yourtheory is indeed pro itable. This orward testing should initially be per ormed in test mode

    only be ore real capital is put at risk. The best way to evaluate a system in this manner is tosimply observe the equity curve rom the Strategy Per ormance Report. The equity curvegenerated in real time should closely approximate the plot generated by historical data i the system approach is indeed a valid one. Experience has shown that as little as two weeksreal-time data is su icient to get a eel or the viability o a new strategy or a new set o parameters or an existing system.

    Keep Your System in Sync with Current Market

    ConditionsTradeStations optimization routine can also be e ectively utilized to help keep your systemtuned in to the ever changing personality o the market. Depending on the nature o the strategy, these market changes over time can certainly a ect the responsiveness andpro itability o a system.

    The use ulness o optimization or this purpose is entirely dependent on the amount o historical data to be used or testing purposes. While it may be com orting to some to see a

    system showing pro itable results over a number o months or even years o historical data,the strategy settings arising rom testing over a large data range will not create a system that isexceptionally responsive to the current market.

    I am not really interested in how my systems traded the market several months ago. What

  • 8/4/2019 Designing Strategies

    23/44

    19

    happened several years ago is not really important to how I want my system to trade. I wouldrather have my system in sync with todays market, not with something that happened yearsago.

    For this reason, I regularly per orm my initial testing and subsequent re-optimizations on aminimal amount o back data. Rarely do I use more than our months data to create or testa new strategy. I know there are many who eel that a much larger sample size is necessary toensure a robust systemand that is per ectly acceptable initially. However, I would certainly encourage the use o minimal data when resetting system inputs or the current market.

    Be assured that TradeStation optimizationwhen used care ully and selectivelycan be usedto create a strategy with a signi icant prospect o success in real time.

    Conclusion

    Back-testing can be a valuable tool or strategy development.1.Optimization can either signi icantly enhance a system or ruin it completely, depending2.on how it is used.Over-optimization can lead to alse expectations or a strategy and render it useless.3.The best and inal test o a system can only occur in real time.4.Keep your strategy in step with current market conditions by using minimal data or5.re-optimization.

  • 8/4/2019 Designing Strategies

    24/44

  • 8/4/2019 Designing Strategies

    25/44

    21

    c pte 4exits are critical

    It can be stated almost without reservation that proper stop-placement and pro it-takingroutines will make or break any reasonably developed trading strategy.

    Getting into a position or generating trade entries using an automated strategy is usually theeasy part.

    Next comes arguably the most di icult and critical part o an automated tradegettingthe exits properly con igured to inish the trade with a positive outcome. Note that I wrotepositive outcome, not a pro itable trade. Many times exits are success ul when there is aloss on the trade and a proper exit has limited the degree o the loss to an acceptable level. A system can be pro itable over time without generating a high percentage o pro itable tradesi the inevitable losses are properly managed.

    Dynamic stops and pro it objectives based on actual market data and price movement, orthose that adjust automatically in response to market movements, are the most e ectivemoney-management tools. The ability o a strategy to automatically move protective stopsupon achievement o a pro it target can be critical to subsequent system per ormance.

    Many automated trading routines enter with multiple contracts or shares and then scale outo these positions at predetermined pro it targets. These targets can be either dynamically placed as a unction o current market conditions or can be set up using the strategy optimization eature discussed earlier.

    Figure 13 (next page) illustrates a programmed strategy initiating each new position withour contracts. As the market moves in avor o the position, irst one contract is liquidated attarget 1, then a second contract is taken o at target 2, and inally the target 3 objective takesout a third unit. The inal portion o the position is liquidated when the position is reversed.In all cases, the stop is moved automatically, reducing the risk or the position as each targetpoint is reached.

    Regardless o the routine used to place these targets, it is o ten advantageous to gradually reduce the current stop-loss level appropriately as targets are achieved. O ten systems willhave moved the protective stop(s) to breakeven or better while a signi icant portion o theoriginal position is still open.

  • 8/4/2019 Designing Strategies

    26/44

    22

    The system chart below (Figure 14) illustrates two buy-side trades that, a ter hitting theirpre-programmed target 1 exit, automatically move the stop to breakeven or the exit o the

    remainder o the position.

    figure 13

    figure 14

  • 8/4/2019 Designing Strategies

    27/44

  • 8/4/2019 Designing Strategies

    28/44

    24

    trailing stop behind the equity curve or the day. In this ashion, the trader can lock in apro itable session but still leave open the possibility o a urther signi icant increase in pro itor the period. The system can continue to rack up gains and will only liquidate the positionand stop trading or the day when the pro it level has pulled back a set dollar amount romthe equity high or the position.

    Once again, it is certainly possible to manually execute all o these stops, targets, and money-management routines; however, automating these routines greatly increases the accuracy andtiming o the event while signi icantly reducing stress during the trading day.

    Conclusion

    Setting proper exits is the most critical phase o strategy development.1.Scaling out o multi-contract positions enhances overall system per ormance.2.

    The systematic movement o protective stops related to hitting targets signi icantly 3. reduces risk.Programming various money-management routines en orces discipline in an arealoss4.managementthat can be di icult or most traders to handle manually.

  • 8/4/2019 Designing Strategies

    29/44

    25

    c pte 5fully automated trading

    When you are convinced that your automated strategy is per orming as designed, the step upto ully automated trading is as simple as a couple o mouse clicks.

    You will have presented to you the option to trade your live account or to trade on theTradeStation Simulator. It is strongly recommended that traders new to automated tradingutilize the trade simulator or at least a ew days. Keep in mind that trades executed on thesimulator can be somewhat di erent than those you will ind on your live account. This islargely due to limit orders that are all illed at the limit price in the simulator, whereas your

    live account may not get some o these ills in real time. The principal advantage o using thesimulator or new autotraders is to become amiliar with the automated trading sequence, windows, and alerts be ore trading a real-time account.

    Automated trading is enabled in the image below (Figure 16), but with the accountcon irmation in the on position, the trader must click the con irmatory button in the New Strategy Order window be ore the trade will be placed. It is strongly recommended thatanyone new to computerized, automated trading use this con iguration initially.

    figure 16

  • 8/4/2019 Designing Strategies

    30/44

    26

    The New Strategy Order window (Figure 17) presents several options to the trader when anew order needs to be placed. No entries or exits will be executed without con irmation romthe trader. Obviously, when autotrading in the con irmatory mode as illustrated here, thetrader must pay close attention to these screens. Protective stops and/or target orders will notbe in place until they are con irmed.

    figure 17

    When you click the box to Automate execution using (your account number) and turncon irmation o , each new trade entry, protective stop and money-management routine willbe executed at the appropriate exchange and placed in your account (Figure 18, next page).

    Once again, thats the easy part. It can be a signi icant challenge to leave the strategy alone andallow the computer to do your trading. Many are not initially com ortable with this arrangementand immediately begin moving stops, aborting entries or exiting trades early in direct con lict with their care ully developed automated strategy. Remember, you never get smarter during atradeallowing the system to operate as designed is a much clearer path to success.

    Trading is largely a head game where ear and greed are signi icant obstacles to ultimatesuccess. It is no di erent when using automated trading.

    Additionally, automated trading does not necessarily equate to unattended trading. Youcan have substantial amounts o capital at risk with any trading approachthis oneis no di erent in that respect. The serious trader will ind it advantageous to closely monitor Internet connections, computer per ormance and accuracy o actual entries andexits throughout the trading period. Autotrading is a complex process rom a technicalperspective, and like all electronic communications, the process is subject to occasionalproblems. There are also other trading issues to considerrejected or cancelled orders, ailureo a limit order to ill, data errors, etc. Traders must be aware o these potential problems andbe ready to make any necessary alterations. The sole purpose o ully automated trading is toincrease the speed o the execution o your trading strategiesnot to alleviate you rom thenormal responsibilities that accompany any trading activity. This eature is NOT designedto enable you to trade without paying close attention to your transactions on screen as they occur, as situations may arise that require your prompt intervention.

  • 8/4/2019 Designing Strategies

    31/44

  • 8/4/2019 Designing Strategies

    32/44

  • 8/4/2019 Designing Strategies

    33/44

    29

    c pte 6implementing your

    automated strategy

    First o all, it is obviously necessary to select a system that its your personal trading style.

    The irst and most convenient source or such a strategy is the wide array o automatedstrategies that come included in your TradeStation plat orm. You will ind a selection o available strategies that use many o the popular technical studies, such as the KeltnerChannel, MACD, Momentum and Moving Averages, programmed to create automatedentries when the proper conditions develop. Additionally available are a variety o pre-programmed exit strategies, including an ATR (Average True Range) exit, a Percent Trailingor a Percent Stop Exit, and a Parabolic Exit, just to name a ew.

    Here is a small selection o the strategies available (Figure 19).

    figure 19

  • 8/4/2019 Designing Strategies

    34/44

    30

    To work with these provided programs, simply add these strategies to a price chart set oryour selected trading item and time rame. You may then alter the provided inputs on each o these strategies and exits to con orm your strategy to your trading style.

    As an example, here (Figure 20) is a price chart o the E Mini S&P Index using a MACDLong and Short Exit (MACD LE and MACD SE) and using the provided Stops & Targetsexit program to set a $150.00 pro it target and a $150.00 stop loss per contract. This entireautomated strategy can be implemented and activated in just a ew minutes.

    Here is the actual screen (Figure 21) that can be used to set various inputs supplied withthese programs. For this particular example, the de ault settings or each program are used.

    figure 20

    figure 21

  • 8/4/2019 Designing Strategies

    35/44

    31

    A ter selecting or creating a strategy, such as the one suggested here, you have the option o adjusting the various strategy inputs to improve the unctionality o the system. I you decideto optimize these inputs, be sure that you understand all o the advantages and disadvantageso this process, as discussed in Chapter 3. Over curve itting is a process to be avoided at allcosts.

    When you are satis ied with your system con iguration, it is always best to test the strategy in real time by care ully observing each trade as it actually happens. Simulation Modeis per ectly acceptable or this phase. There are some aspects that the simulator cannotcompletely cover, but or the most part you will get a good eel or the accuracy o the systemusing this application. Let the strategy run or at least 25-30 trades or ive days, whichever islongest. There is nothing like real time to uncover the potential weaknesses o a strategy andto assess how accurately your projected per ormance matches up with actual live trades.

    Use the Trade Simulator InitiallyI you are completely new to automated trading, you should seriously consider operating thesystem using the trade simulator in TradeStation or at least a ew days. This is important notonly to test the system in real time as discussed above but also to become more amiliar withthe automated trading process. There are several screens involved in autotrading that youmay not have encountered when trading discretionarily.

    The TradeStation Matrix (Figure 22) will present your real-time position or your autotrades,

    as well as display your limit orders or entry and/or exit.

    figure 22

  • 8/4/2019 Designing Strategies

    36/44

    32

    The TradeStation TradeManager (Figure 23) is an application that you need to ully understand be ore autotrading in real time. It is rom the various screens in theTradeManager that you will be able to evaluate current positions, pending stop or entry orders, position matches between your real-time account and the strategy position, and many other items important to managing your autotrades.

    The amount o in ormation available rom this application, as well as the many use ultrading adjustments available, are too numerous and detailed to discuss adequately here. Toully understand this important trading tool, you are encouraged to ully review the varioustutorials available through the TradeStation plat orm prior to its actual use in real time.

    Using the Matrix and the TradeManager in the simulation mode will a ord you theopportunity to master these applications in a more relaxed mode than trying to igure all o this out when the real bullets are lying and your money is on the line.

    When you do begin real-time/real-money trading with your strategy, be sure to begin in avery conservative manner until you get your eet on the ground and become com ortable with automated trading. Many make the atal mistake o convincing themselves that theirstrategy is the latest in ATM machines and can do nothing but rack up huge pro its rom themoment it is activated. Do yoursel a avor and begin by trading only one or two lots to gaincon idence in your system be ore taking it to a higher level. Remember, there is nothing likethe real thingreal-time trading with real moneyto prove or disprove the validity o any trading strategy.

    Have a Backup Plan

    Youve all heard Murphys law (i anything can go wrong, it will) and its corollary (Murphy

    was an optimist). You must be prepared to deal with all o the problems that can crop upduring any trade.

    Your computer can crash. Your Internet connection can go down. You can lose power to youro ice. Exchange data eeds can go down. Any one o these, or a combination o any o theabove, could spell disaster i you are not prepared to deal with these situations.

    figure 23

  • 8/4/2019 Designing Strategies

    37/44

    33

    Heres a backup plan that I have ound to be help ul:

    Be sure that the workspace that you are using or real-time trading is up to date on a1.secondary computer and ready to activate at a moments notice should your primary trading computer ail or any reason.

    Be sure to have an alternate Internet connection. In my o ice, I have a laptop2.loaded with the same setup as my main computer, running and ready to go. On thiscomputer, I also have an aircard which can access the Internet using my cell phoneprovider. This not only provides a backup computer but also a backup Internetconnection should either or both be compromised in any ashion.

    Keep the number or the TradeStation trading desk and the number or your3.TradeStation account executive on the speed dial on both your land line and yourcell phone. They are trained to handle these problems and can o set your positioni you lose connectivity with the electronic exchanges. While there is nothing any o these individuals can do i an electronic exchange goes down, they may be able too set your position in the trading pits in an emergency.

    Keep an Open Mind

    Keep an open mind markets change their personalities more regularly than your teenageo spring and need to be approached as such. It has been shown with high-probability

    numbers that even the best, most robust trading systems will need adjustment rom timeto time to keep them in sync with current market conditions. Remember that when we aretrading with a mechanical strategy, we are in e ect attempting to mathematically predicthuman behavior.

    No matter how well your system is per orming, it is always good practice to regularly check your system theory and in particular to re-check your system parameters to assure yoursel that you are getting the most out o your strategy.

    There are several automated routines that attempt to keep a strategy in sync with currentmarket conditions. Numerous neural networks have been programmed with this in mindand some have been somewhat success ul in doing so.

    I have been working or some time on a routine that has proven use ul to keep my systemsin sync with the current market. This process involves the re-programming o a strategy intoa unction (I call these Parallel Functions since they closely simulate the system itsel ) thatcan be used to create multiple simulated systems in real time. Using these simulations, onecan in e ect monitor multiple settings o the same system in an attempt to always use the

    system settings that are most pro itable at any current moment.

    While it is possible to ully automate a sel -optimizing system using this technology, I haveound it more use ul to keep the human brain in the decision-making tree to the extentthat I manually assess the reports rom the multiple system simulations and select the set o system variables to use each day.

  • 8/4/2019 Designing Strategies

    38/44

    34

    Although the details o the programming required to create and utilize real-time systemsimulations rom parallel unctions un ortunately goes beyond the scope o this publication,you can get a eel or this idea by examining a graphic that displays the simulated systemsin real time. Note that in this example (Figure 24, next page), there are our separate systemsettings that are most pro itable at separate times during the trading day.

    Interestingly enough, it is possible to use pre-market data as a predictor o the nature o theactual day session using parallel unction technology.

    Conclusion

    Multiple programmed automated trading strategies are available on your1.TradeStation plat orm and can be used to create your own specialized tradingsystem.

    A ter selecting a suitable set o strategies and creating your system, it is possible to2. alter the various system inputs using the selective optimization routine describedin detail in Chapter 3.Be ore trading in real time with real money, it is advisable to irst observe3.autotrading using the TradeStation trade simulator.Keep in mind that your trading strategy may need to be altered in the uture to4.keep up with the current market.New technology is being developed that will allow real-time monitoring o 5.strategy reactions to market changes, enabling both the trader and eventually

    the system itsel to make the changes necessary to maintain maximum strategy pro itability.

  • 8/4/2019 Designing Strategies

    39/44

    35

    f i g u r e 2 4

  • 8/4/2019 Designing Strategies

    40/44

    36

  • 8/4/2019 Designing Strategies

    41/44

  • 8/4/2019 Designing Strategies

    42/44

  • 8/4/2019 Designing Strategies

    43/44

  • 8/4/2019 Designing Strategies

    44/44

    dr. john clayburg John Clayburg graduated rom Iowa State University in 1971 with thedegree Doctor o Veterinary Medicine. Following graduation, he practicedlarge-animal medicine in his hometown o Coon Rapids, Iowa, or 15 years.

    While marketing corn, soybeans, and cattle raised on his arm, John

    gradually developed an interest in commodity markets and began actively trading in the late 1980s. Trading decisions soon became technical innature, using printed charts received in the mail each weekend and updatingthem daily by hand. When TradeStation came on the scene, John becameinterested in automated strategy development and EasyLanguage.

    Johns automated strategies are regularly rated in the top 10 systemsby Futures Truth.

    John wroteFour Steps to rading Success in 2001, published by Wiley &

    Sons, discussing in detail alternate uses o common indicators, rst to de nea trend and then to identi y exhausted corrections against the major trend.He also has had numerous articles published inechnical Analysis of Stocks & Commodities , raders (Germany), Active rader , andTe Forex Journal,to name a ew.

    John has been a eatured presenter at trade shows and seminars throughoutthe United States and Europe, delivering the keynote address or the German

    Association o Technical Analysts (Vereinigung Technischer AnalystenDeutschlands) in Frank urt in 2005.

    Current strategy development projects include routines in EasyLanguagedesigned to keep automated strategies more in tune with current marketconditions using parallel unctions, efectively creating a sel -optimizingtrading strategy.

    John has garnered a loyal community o system traders or his current website, www.onlinesystemtrading.com, where he publishes daily systemvideos and trading charts, and where he can o ten be heard in the livetrading room as well. He still makes time or his arm, riends and amily.


Recommended