Beth  Nabimanya

Beth Nabimanya


Algorithmic Trading Models — Breakouts

Introduction_In this series, I will look 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 I have backtested them on. The aim behind each of these models is that they should be objective and systematic, i.e., 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.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. If you 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 a separate series, I will describe exactly how we might go about coding one of these trading bots in MQL4 (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 theory being once they make that break, they will continue to move in that direction.From an algorithmic trading point of view, it is 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. If a small reversal does happen before the 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 levels.

Fig. 2 — The visual method for identifying S&R levels on the EUR/USD daily 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 we place our lines (i.e., the x most frequent price clusters are considered key levels).

#trading #commodities-trading

What is GEEK

Buddha Community

Algorithmic Trading Models — Breakouts

How I Made a 65% ROI with this Boeing Trading Algorithm

Since the market crashed in March of 2020 the rebound has been swift and irrational.

Boeing, for example, is in many ways worse off than it was in March.

It’s clear air travel has plummeted and that airlines will be impacted for

years. Where will airlines get the money to purchase planes?

An example of one headline in April: “Boeing customers cancel staggering 150 Max plane orders”.

Buy the dip?

One thing I’ve noticed is that since the end of March you can

basically just buy every dip and expect a pop, selling the next day. I

mentioned this to a friend on Friday and decided to backtest it.

Well, sure enough it works!

I’ll mention I made one modification. Originally I wrote the system like so:

1. Check if Boeing is down more than 3% 15 minutes from close

2. If yes, buy with 100% of portfolio

3. The next day, 15 minutes from open liquidate the portfolio.

This worked OK. Great actually! It returned about 25%. But want to know what really kicked it up a notch?

Instead of just selling the next day, I only sell if the position is

sitting at a realized gain. So e.g. if the next day its flat or drops

another 1%, don’t sell it, just keep holding on until its up and THEN

sell. Of course, this is completely insane and you would have to expect

the market to only go up, but that’s what has been happening.

Guess what? This simple system returned a whopping 65% in two-ish months. Yeah, I know, crazy.

Check out the backtest screenshot:

And here are the raw trading logs for those that want to see the dates the trades were made:

Here is the code!

Before we look at the code, I’ll just mention here are the details of the backtest:

  • start with 100k in cash

  • start at April first and go until last Friday (June 19th 2020)

  • end up with about 165k or a 65% return.

I wrote this little script on Quant Connect. The screenshot at the

top of the page is the backtest result, and the code below is everything you need to try this out.

Note the place I mentioned in the code you should comment if you want this to be a little bit less insane.

#algorithmic-trading #trading #python #algorithms #trading-algorithms

Beth  Nabimanya

Beth Nabimanya


Algorithm trading backtest and optimization examples

Algorithm trading backtest and optimization examples

Algorithmic trading backtests

Algorithm trading backtest and optimization examples.



#algorithms #optimization examples #algorithm trading backtest #algorithm #trading backtest

August  Larson

August Larson


Algorithmic Trading with the Keltner Channel in Python

A must-know indicator for all the traders out there


While you’re studying technical indicators, you would definitely come across a list comprising curated indicators that are widely considered as ‘must-know’ indicators that need to be learned by you before getting your hands dirty in the real-world market. The indicator we are going to explore today adds to this list given its performance in the market. It’s none other than the Keltner Channel (KC).

In this article, we will first discuss what the Keltner Channel is all about, and the mathematics behind the indicator. Then, we will proceed to the programming part where we will use Python to build the indicator from scratch, construct a simple trading strategy based on the indicator, backtest the strategy on Intel stocks, and finally, compare the strategy returns with those of the SPY ETF (an ETF particularly designed to track the movements of the S&P 500 market index).

#finance #python #algorithmic trading with the keltner channel in python #algorithmic trading #the keltner channel #algorithmic trading with the keltner channel

August  Larson

August Larson


Algorithmic Trading with Williams %R in Python

Learn to build a killer trading strategy with a powerful technical indicator in python


While having a look at the list of most popular momentum indicators that consists of the Relative Strength Index, and the Stochastic Oscillator, the one we are going to discuss today also joins the list when considering its usage and efficiency in the real world market. It’s none other than the Williams %R.

In this article, we are going to explore what Williams %R is all about, the math behind this indicator, and how a trading strategy based on it can be built with the help of python. As a bonus step, we will compare the returns of our Williams %R strategy returns with the returns of SPY ETF (an ETF specifically designed to track the movement of the S&P 500 Index) to get an idea of how well our strategy performs in the real-world market and can be considered as a step to evaluate the strategy. Considering your curiosity piqued, let’s dive into the article!

#python #algorithmic trading with williams %r in python #algorithmic trading with williams %r #algorithmic trading #williams %r

Implementing a Trading Algorithm with R

This story explains how to implement the moving average trading algorithm with R. If you’re interested in setting up your automated trading pipeline, you should first read this article. This story is a purely technical guide focusing on programming and statistics, not financial advice.

Throughout this story, we will build an R function which takes historical stock data and arbitrary threshold as…

#programming #statistics #algorithmic-trading #trading #data-science #algorithms