We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
sanz arte Ta
You have 2tree member-only stories left this month. Sign up for Medium and getan extra one
Algorithmic Trading Models —
Breakouts
The first article in a series that will look at the theory behind
producing algorithmic trading models
ee 28,2020:8rinread #sanz Arete Yan Mote — Sra oe Kary oa | 66,288 Maden
Fig.1—15 months of EUR/USD price behavier, plotted on adallycandlestick char,
Introduction
In this series, Iwill ook to summarise a collection of commonly used technical
analysis trading models that will steadily increase in mathematical and
computational complexity. Typically, these models are likely to be most effective
around fluctuating or periodic instruments, such as forex pairs or
commodities, which is what Ihave backtested them on. The aim behind each of
these models is that they should be objective and systematic, ie., we should be
able to translate them into a trading bot that will check some conditions at the
start of each time period and make a decision if a buy or sell order should be
posted or whether an already open trade should be closed.
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases a0srt Tag Mah — esas | On hay na Bs, 98 Man
Please note that not all of these trading models are successful. In fact, a large
number of them were unsuccessful. This summaries series has the sole objective
of describing the theory behind different types of trading models and is not
‘financial advice as to how you should trade. Ifyou do take some inspiration
from these articles, however, and do decide to build a trading bot of your own,
make sure that you properly backtest your strategies on both in and out of
sample data and also in dummy accounts with live data. I will cover these
definitions and my testing strategies in a later article.
As already mentioned, this article will cover a summary of a trading model. In
aseparate series, Iwill describe exactly how we might go about coding one of
these trading bots in MQLA (the modified C+ + language MetaTrader uses for
algorithmic trading in the financial markets)
Breakout models are one of the most commonly used and discussed types of
technical strategies because they build a trading methodology on top of the
most fundamental technical analysis method, support, and resistance. They
ultimately aim to profit off the price breaking through these levels, the
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases snoAr Tag Mak — Sats ny ve etary To A Ds, 280] Maden
theory being once they make that break, they will continue to move in that
direction.
From an algorithmic trading point of view, itis fairly straightforward to
decide when we enter a trade as we only have limited options available,
each with its merits and issues. We could instruct a buy market order when
the price closes above a resistance level or a sell market order when the
price closes below support. In order to avoid false breakouts or fakeouts
(when the price closes outside the support or resistance line but then
reverses its direction, indicating that a breakout has not actually occurred)
which market order might be prone to, we could place stop orders at a
certain value below or above our S&R levels so that when we enter, we are
sure that we have caught a breakout, The issue with this, naturally, is that
‘we may already have missed a large part of the move by the time we enter
the trade. In another scenario, we could wait for a second candle to confirm
a breakout before entering the trade, but this gives us the same issue as the
stop order method. We could also use a limit order, in which we expect the
price to retract slightly back below the level before then continuing in its
original direction, From a sentiment point of view, this strategy has some
merit. Support and resistance levels are available to all traders, and many
institutional ones, such as banks, may place large limit orders at these levels
to try and sway a reversal. Ifa small reversal does happen before the
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases woMoxtnedin tonearm nant armas
Ate Tig Mone — rss Dv Rhy [ou D628 [Mets
breakout continues, then we benefit ourselves by entering a trade at a more
optimal price. There are two obvious issues with this strategy, however. The
first is that we hit a strong S&R level, and after bouncing off, the price
continues to reverse, at which point we have entered a losing trade. The
second is that the amount of traders pushing for a reversal at the level isn’t
enough to bring the price back down to our limit level, leaving us with an
unactivated limit order and a price traveling in the direction that we could
have made a profit from had we entered the trade.
‘The far harder factor in determining in this scenario is establishing support
and resistance levels. There are plenty of videos online that teach you how
to observe and plot these levels visually. They begin by looking at the longer
timeframe charts and moving to the shorter ones, iteratively plotting lines
in which the prices appear to touch or come close to on at least 2 separate
occasions. This, however, is not a method we can use in algorithmic trading
because we want a purely objective method of identifying these levelsArete Yan Mote — Sra ve ear oar 66,288 Maden
Fig.2 — The visual method for identiying SBR levels onthe EUR/USD dally chart
‘There are a few ways in which we can do this. We can plot support as the
lowest point and resistance as the highest point in the last x bars. Whilst this
only entails one “price-touch,” it can be considered a slightly weaker level,
suggesting that a breakout is more likely. Dynamic levels can also be
employed, with a moving average that we hope the price will breakthrough.
A third method is to create upper and lower bands, with Bollinger Bands,
for example. In this case, when we see a bar break through one of the
bands, we place a trade in the direction of the movement. If we want to
specifically try and mimic the traditional visual methods of drawing S&R
levels, we could consider some machine learning methods. A clustering
algorithm that groups price levels could give us a good indication of where
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases wowe place our lines (i.e., the x most frequent price clusters are considered
key levels)
Fig. — The typical S&Revels that might be plated whes loking forthe maximun/minimum eloing values
inthe last xbars
Moxtnedinantoneanan alee tinicrde-noanaha dba aeaases m0Fig.¢— A tratogy to use a 100 period Simple Moving Average (SMA) asa breakout ovesanz Arete Yan Mote — Sry Oe erry oar |, 288 Maden
Fig, — A strategy to use Bolinger Bands as our dynamic breakout levels
‘There are many more variations to breakout models than I've described
here, and adding complexity appears to be a necessity from the multiple
fakeouts that we see in the graphs above, even if it is a small sample size.
What we do have here, however, is a foundation on which to build on. The
basic principle of breakout models is to define support and resistance levels
and to place trades when these levels appear to be broken. The method of
defining these levels, the type of trade entry to use, and what stops to place
are all determined by exhaustive iteration, research, and testing. Ihave
designed and backtested about 10 breakout models, and I will aim to
outline a few in greater detail in coming articles, particularly on the coding
le, so that you can see exactly how to produce these yourselves.
Sign up for Towards Al Newsletter
“Towards Al publishes the best of tech, science, and engineering. Subscribe to receive
‘our updates rightin your inbox. Interested in working with us? Please contact us —-
https:/towardsalnet/contact Take alook
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases wo‘moot Abst Tag Moto — Sts ty Ona ketene A Dee 208 | Mss
Your email
“Thanks to TDS Eaters
Algorithmic Trading Algorithms Trading Forex Commodities Tasing
Learn more. Make Medium yours. Share your thinking.
Moxnedin toner nlwenlptinicrade-mdanha dA aeaases oH