40 4 5MB
® The Trading Method of the 4-Time World Champion
BIAS SYSTEMS How to exploit repetitive behavior such as seasonal patterns
ANDREA UNGER
INTRODUCTION There’s a Chinese proverb I’ve always kept in mind as a trader: “When you lose, don’t lose the lesson”. It’s something I firmly believe in: every mistake made, every “lesson learnt”, helped me refine my method and build a correct approach to trading, the same I’ve been teaching my students for years. Mistakes in trading can be expensive, so following the advice of those who’ve trodden the same path in the past is the best way to avoid making mistakes in the future. I’d like to be able to tell you, as many self-proclaimed “gurus” do, that all you need is to learn a few “secret” tricks to become a trader, but THAT’S just not true, and those looking for some magical formula are simply wasting their time and energy. The only way that works is to study, to learn from those who have real experience in the field. That’s why I’ve concentrated my know-how and direct experience in this report on how to exploit the repetitive behaviour of some markets, such as seasonal patterns. I hope my advice and experience will help you avoid the traps many traders fall into.
Andrea Unger, Founder of Unger Academy® and the only 4-Time World Trading Champion
Click on the link to download the code of the indicator described below and watch a video on how to use it! https://autc.pro/BiasEN
BIAS SYSTEMS
ANDREA UNGER
INTRADAY BIAS SYSTEMS
Markets often behave in a repetitive way, something that can in some ways be explained, and you can build automated intraday and multiday strategies to exploit this behavior.
WHAT IS A “BIAS” SYSTEM? If we’re talking about trading strategies, the term “bias” covers all the logics that attempts to exploit recurring behaviors that may arise at quite regular intervals, using one particular financial instrument, or on a basket of several financial instruments. In fact, to build this kind of system you have to analyze the behavior of an instrument at various times of the day, week, month or year, and try to see whether the financial instrument has any regularly average trends in the interval of time studied. The most common bias is hours of the day. In this case you try to see whether an instrument has a tendency to rise or fall for various consecutive hours, and in a significant way within certain bands of the trading session.
VARIOUS EXAMPLES OF BIAS Bias systems, as mentioned above, could be analyzed on the basis of different time intervals. The main ones I’d like to draw the reader’s attention to are: • Intraday bias: you attempt to analyze whether a financial instrument has a tendency to rise and/or fall for various consecutive hours in the trading session; • Intraweek bias: in this case you try to see whether there’s a up and/or down trend for a few consecutive days (or portions of days) during the trading week; • Intramonth bias: this type of strategy is evaluated in an attempt to see what happens buying on every working day of the month and closing at the end of the same. In this way you try to see whether there’s a trend in the working month that can be exploited; • Seasonal systems: in this case you try to see whether there’s a seasonal trend in the year. The analysis of this type of strategy requires a certain amount of experience however, due to the limited amount of data available (in fact, there will be just a few events if you analyze data from the last decades).
4
ANDREA UNGER
INTRADAY BIAS SYSTEMS
INTRADAY BIAS SYSTEMS
5
ANDREA UNGER
INTRADAY BIAS SYSTEMS
Intraday bias This is a BIAS-based approach to developing automated strategies. And the idea is to check if there are time windows within the trading session in which the financial instrument has an up or a down BIAS that could be exploitable. You try to see whether the financial instrument, on average, rises or falls in a significant and consecutive way for various hours during the day. To do this, simply create a script for your platform that buys at the start of each (hourly) bar during the day, and closes the trade when the bar itself closes.
CODE 1 in EasyLanguage/PowerLanguage Input: MyTime(0); if Time=MyTime then buy next bar market; if marketposition=1 then sell next bar market;
AN EXAMPLE OF THE CODE To run this type of basic analysis we use the script in code box 1, coded in Power Language on the MultiCharts platform. At this point we apply the signal created to the chart and optimize the “MyTime” input to see what happens if we trade the financial instrument every hour of the session. Now let’s try applying the signal to Crude Oil Futures, using a 60 minute chart. The “MyTime” input is optimized from 0 to 2300 in steps of 100, to check the average behavior of Crude Oil during the entire session. You can clearly see from the highlighted regions that there are distinguishable periods of negative results from periods of positive results (Figure F1), all of which are in buying crude oil at the beginning of the hour and selling at the end of that hour. Also, remember that the session starts at 18:00 or 6:00 PM, which is why the result at that point is empty because the platform considers the closing time of the instrument. In this case note that the Crude Oil Futures’ session appears to be split into two parts: one part from 19:00 to 12:00 next morning shows a significant bearish trend (in fact there are many consecutive bars with negative results if trading long at that time), but in the part from 12:00 to 17:00 the average behavior is definitely bullish. We’ll exclude the 17:00 bar from the analysis of the bearish part. In fact this is when Crude Oil closes the session and trading starts again at 18:00 so it’s better to avoid working at times between different sessions.
6
ANDREA UNGER
INTRADAY BIAS SYSTEMS
F1 Optimization report - Bias hourly test on Crude Oil FONTE: Ungeracademy®, screenshot obtained with MultiCharts
To get a better idea of the financial instrument’s behavior, you can export the optimization data to Excel and plot the results of the single bars as histograms (Figure F2). At this point we can draw up a basic strategy: • we’ll open a short position every day at 19:00 and close it at 12:00 the next day; • we’ll open a long position at 12:00 and close it just before the end of the trading session.
7
ANDREA UNGER
INTRADAY BIAS SYSTEMS
F2 Optimization report - Bias hourly test on Crude Oil scaled on Net Profit FONTE: Ungeracademy®, screenshot obtained with Excel
As the long position will be closed at the end of the trading session (just before 17:00), I rewrote the entire code on the basis of a 15-minute chart, so I can exit in a more precise way at the end of the session. In fact, if I continued to use a 60-minute chart, I would have had to close the position 1 hour before the session closed or as soon as the market opened again (at 18:00), altering the original idea; but with a 15-minute timeframe I can tell the platform to exit 15 minutes before the end of the same session, at 16:45. This shouldn’t have a significant impact on system performance, but should prevent unpleasant live trading problems that might arise!
CODE 2 EasyLanguage/PowerLanguage if Time>=1200 and Time=1645 and Time=1900 and Time=1200 and Time=1515 then sell(“LX”) next bar market; if dayofweek(date)=0 and Time>=2230 then sellshort(“SE”) next bar market; if dayofweek(date)=1 and Time>=1630 then buytocover(“SX”) next bar market;
23
ANDREA UNGER
INTRAWEEK BIAS SYSTEMS
The results obtained by applying this strategy can be seen below. The system was tested using MultiCharts, fed with TradeStation data on a 5-minute timeframe and the historical period considered was from January 2010 to July 2019. As for the results in Figures F18 - F23, we can make the following considerations: • NetProfit is interesting on both sides of the system: approximately $110,000 for the long side and $143,000 for the short side; • avg trade is good and on average should avoid excessive impact from commissions and slippage: approximately $230 on the long side and $300 on the short side; • the equity curve shows good strategy constancy for almost all the historical data considered. There were a few difficulties with the system in 2017 and 2018. 2019 however seems to produce good results, so we could assume that the difficulties in the last two years have ceased and system performance is once again quite regular; • if we observe the Annual Period Analysis, note that in the current year the Avg Trade would be approximately $260 ($13,000 NetProfit/50 trades placed), which confirms the sustainability of the system also in the more recent period (current year).
F18 Strategy Performance Analysis - Bias Intraweek Strategy line FONTE: Ungeracademy®, figure obtained with MultiCharts
on
RBOB Gaso-
24
ANDREA UNGER
INTRAWEEK BIAS SYSTEMS
F19 Equity Line with Drawdown - Intraweek Bias Strategy on RBOB Gasoline FONTE: Ungeracademy®, figure obtained with MultiCharts
F20 Equity Line - Intraweek Bias Strategy on RBOB Gasoline - Long side FONTE: Ungeracademy®, figure obtained with MultiCharts
25
ANDREA UNGER
INTRAWEEK BIAS SYSTEMS
F21 Equity Line - Intraweek Bias Strategy on RBOB Gasoline - Short side FONTE: Ungeracademy®, figure obtained with MultiCharts
F22 Total Trade Analysis - Intraweek Bias Strategy on RBOB Gasoline FONTE: Ungeracademy®, figure obtained with MultiCharts
26
ANDREA UNGER
INTRAWEEK BIAS SYSTEMS
F23 Annual Period Analysis - Intraweek Bias Strategy on RBOB Gasoline FONTE: Ungeracademy®, figure obtained with MultiCharts
OTHER MARKETS THIS TYPE OF ANALYSIS CAN BE USED ON I tried to apply this type of study also on other markets, with interesting results on some. I refer in particular to British Pound Futures, EuroFX Futures, the Futures of the principal US indexes (Mini S&P 500, Nasdaq 100, Mini Dow-Jones 30) and Gold Futures. Our test specimen for this version of the approach will be the eMini S&P500 Future at CME. • Tool: Mini S&P 500 (CME) • Session: 5:00 PM to 4:00 PM (next day) GMT -6 (Chicago Time) • Data: IQFeed • Test period: January 2008 to March 2018 • Platform: MultiCharts
F24 Optimization Report - Day by day on eMini S&P500 Future FONTE: Ungeracademy®, figure obtained with MultiCharts
27
ANDREA UNGER
INTRAWEEK BIAS SYSTEMS
As you may notice in the first column (Figure F24), there is the optimization parameter I have named “MyDay,” whose values correspond to the days of the week; hence, 1-5 referring to Monday through Friday, respectively, with the non-trading weekends excluded. And our test yielded some interesting variations in the profits between the days. For example, on the average trade column it seems Tuesday and Thursday, for whatever reason, have yielded very high values in comparison; furthermore, the same days also seem to have much lower maximum drawdowns. As such, it may be beneficial to create and implement a strategy based on this concept. Perhaps it would not be enough to trade a system based off of this rule, but it nevertheless provides a very important and insightful edge on those two days.
Do you want to start making a profit with Systematic Trading without wasting time on discretionary analysis? Book a FREE 45-minute Strategic Consulting Call with a member of my team NOW, to see how we can help you achieve your trading goals! https://autc.pro/ReportEN
28
INTRAMONTH BIAS SYSTEMS
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
Intramonth bias We have covered both instances of intraday seasonal BIAS in previous sections. Here, we will see the more conventional idea of seasonality, which is identified across the months to distinguish ascending or descending monthly BIAS.
HOW DO YOU CALCULATE THE INTRAMONTH AVERAGE TREND? Calculate the average price variations for every day of the month; in fact it’s the same principle applied above for intraweek patterns. The only difference is that the calculation is done on the basis of the month instead of the week. Note that there are two ways to calculate the intramonth average trend: 1. calculating it for the days of the month: in this case you calculate the average of the variations from the close of the current session to that of the previous day, for every calendar day of the month. Note however that in every month there will be days for which there’s no data, both because most financial markets are closed for the weekend and holidays, and because some months are shorter than others; 2. the second method involves counting the current working day in each month and therefore considering the working day (or trading day) in the month. In practice, you calculate the average variances from the close to the previous session for every working day of the month. Unfortunately, to date I haven’t found any free source online to recommend; but the good news is, you can study these trends in various ways using the most popular platforms: • exporting the data required for this type of analysis to process the data with Excel or another application (e.g. MatLab, Octave, Python); • or you can plan a simple backtest for every trading day of the month and use the results to analyze the trend for each day.
30
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
MATLAB/OCTAVE ANALYSIS As mentioned above, you can analyze this kind of trend using other programs such as MatLab, Octave or Python. I chose Octave and also implemented a study of the intramonth patterns in the program I used for the intraweek patterns. The functions in Octave are very similar to MatLab and you can work quite efficiently on matrixes, so it’s an excellent application for this kind of analysis, and it’s free too. Obviously the program wasn’t designed with pre-set functions for this specific task, so you do have to code all the operations to get the result you’re looking for, which does take some time. The advantage, on the other hand, is that you can customize the entire calculation process to suit your requirements. In particular, I set up the program to perform the following operations: 1. calculate the summation of the variations for every trading day of the month between the close of the current bar and the previous one; 2. divide all the values found for the average number of events. In this way the end-of-month data that occurs less often, has less of an effect on the end result; 3. the cumulative curve of the average variances is shown in a chart, weighted with the criterion described above. At the end of the process you obtain a chart like the one in Figure F25, in which the trading day of the month is on the axis of the abscissa, and the monetary value of the cumulative sum of the weighted average variances in relation to the average events that occurred, is shown on the axis of the ordinates. F25 Intramonth Bias on Crude Oil Future
FONTE: Ungeracademy®, figure obtained with Octave
31
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
ANALYSIS USING MULTICHARTS AND EXCEL With some platforms like MultiCharts and TradeStation you can export the principal data of a financial instrument to a text file, so it can easily be analyzed in Excel or another electronic spreadsheet program. I wrote a script that can be used both as an indicator and a signal with MultiCharts, that exports both the average value of the variations for each trading day of the month, and the cumulative sum of the same variations, weighted in relation to the average events that occurred. Therefore the values exported can easily be imported into Excel and analyzed in quite a simple and intuitive way.
F26 Analysis of average daily changes on Feeder Cattle Future FONTE: Ungeracademy®, figure obtained with Excel
32
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
F27. Analysis
of the cumulative variation of the average on a daily basis on Feeder Cattle Future FONTE: Ungeracademy®, figure obtained with Excel
F28.Custom Future Setup - Feeder MultiCharts FONTE: MultiCharts
33
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
AN EXAMPLE OF AN ANALYSIS ON FEEDER CATTLE FUTURES (CME) On the basis of these premises, I’d like to give you an application example on Feeder Cattle Futures listed on the Chicago Mercantile Exchange (CME). Feeder Cattle Futures are characterized by scarce liquidity and they aren’t traded a lot (average volumes per session are approximately 5,000 contracts), but these Futures are strong trend followers: they are therefore quite volatile with quite significant price swings that let you trade prolonged trends. The purpose, in the case in question, is to try and improve a trading idea that works due to its nature quite well with Feeder Cattle Futures, using breakout logic on the previous day’s limit levels, so it’s a very simple system. The code is written for MultiCharts/TradeStation, the instrument used is Custom Futures on Feeder Cattle Futures, and the rollover criterion is based on the Open Interest of the next contract compared to the current one. CODE 5 in formato EasyLanguage / PowerLanguage buy next bar highd(1) stop; sellshort next bar lowd(1) stop; The initial system code is quite banal (code box 5), but the breakout and trend follower behavior of the instrument would appear to be confirmed. In the images of the enclosed report (Figures F29-F30), note how the financial instrument responds in a positive way to the applied logic. In fact, the resulting equity curve is certainly encouraging, despite the fact it’s a raw data motor rather than a finished system. Furthermore, note that the average trade is just $112, mostly concentrated in the central part of the backtest period and this doesn’t offer protection from the impact of commissions and slippage, even more so as this is an instrument with scarce liquidity.
F29. Equity Curve with Drawdown (unfiltered breakout on Feeder Cattle Future) FONTE: Ungeracademy®, figure obtained with MultiCharts
34
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
F30. Total Trade Analysis (unfiltered breakout on Feeder Cattle Future) FONTE: Ungeracademy®, figure obtained with MultiCharts
We can try to see if there’s bias in the month when it’s best to trade only long and a part when on the other hand it’s best to trade only short. To do so, we can try to find any trends using the previous charts (31).
F31. Average Daily Trend (Feeder Cattle Future) FONTE: Ungeracademy®, figure obtained with Excel
35
ANDREA UNGER
INTRAMONTH BIAS SYSTEMS
On the basis of the chart in Figure F31 it would appear that there are mainly two alternating phases in the trading month: • from the 3rd day of trading in the month until the 14th there appears to be a marked bearish trend. In fact we can see that on average there are many consecutive days in which the price falls and the series is interrupted by just a few days in which the price rises; • from the 15th day of trading in the month until the 2nd day of the following month on the other hand, there appears to be a marked bullish trend. Also in this case, note how the series of consecutive bullish days is quite marked and isn’t affected to any great extent by the few bearish sessions found on average in that period of time. Therefore, we can try to use the days found with this type of analysis as a filter for the system written previously. After a few tests, I found the application of the filter to be sufficiently valid when used as follows: • trade long only from the 15th trading day of the month; • the long trade will be closed on the 1st possible day of the following month; • short positions can only be opened before the 15th trading day of the month; • short trades will be closed from the 15th working day of the same month; • the entry triggers are the same as in the previous version (previous day’s limit breakout). the strategy code can be seen in code box 6.
CODE 6 EasyLanguage/PowerLanguage format var: TDOM(0); if month(d)month(d)[1] then TDOM = 0; if sessionlastbar[1] then TDOM = TDOM + 1; if if if if
TDOM=15 then buy next bar highd(1) stop; TDOM>=15 then buytocover next bar market; TDOM