Supertrend Indicator: Easy Explanation + How to Use It in a Trading Strategy (Open-Source Code)

Need More Help? Book Your FREE Strategy Session With Our Team Today!

We'll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.

BOOK YOUR FREE STRATEGY SESSION NOW >>

Supertrend is one of the Internet's most frequently cited technical analysis indicators. However, articles on the subject don’t always provide clear enough explanations to understand how it works and its potential.

That’s why we decided to offer you a video dedicated to the Supertrend Indicator, where we not only explain the theory behind it but also perform some tests to check its potential performance in a trading system.

In this video, you’ll find:
-A clear explanation of what the Supertrend Indicator is and how it is constructed
-An example of a strategy that opens long and short positions based on the signals provided by this indicator (with open-source code)
-Backtest, optimization and results of the strategy applied to Gold

Enjoy! 😎

Transcription

Introduction

Hey everyone, good to have you with us again. In this video, we’re going to be discussing one of the most frequently cited indicators on the Internet, namely, the Super Trend Indicator.

Now the Internet is full of articles about this indicator, but we’ve noticed that there is also some confusion.

So, in this video, we're going to shed some light on the subject.

What is the SuperTrend?

Alright, thank you so much.

Okay, so let's start by explaining what the Super Trend Indicator is.

So, it's nothing more than the combination of two values, namely the mid-price and the Average True Range.

What do we mean by mid-price? Well, mid-price is what I’ve plotted on this chart.

And basically, it's the average between the maximum and the minimum price of each bar.

You can see that for each bar, I’ve plotted the midpoint of that bar.

Then, we’ll add or subtract the Average True Range based on this mid-price.

For simplicity, we can think of the Average True Range as the average of the bar ranges, that is to say, the average of the monetary swings of each bar.

In this way, we get a kind of upper and lower channel starting from the mid-price and delineating exactly a price channel.

But what is the Super Trend Indicator?

Again it’s nothing more than the reproduction of these channels, but with particular rules.

Here it’s plotted.

Let's say we start from the top and then plot the indicator above the prices.

Once the indicator starts, which is from this point, it can no longer increase in value.

You can see that the indicator can only decrease.

I’ll take the minimum value, which has never been reached since we plotted the indicator above the prices.

After I reach the condition where the price closes above the indicator, as you see here on this bar, I’ll start plotting the indicator using the lower channel.

So mid-price minus Average True Range.

Following the same rule, the same mirror rule,

in this case, I’ll plot the indicator only for the values corresponding to the high of this channel that has been reached so far.

From here, we’ll draw the channel by precisely replicating the channel of the Mid-price minus the Average True Range.

Then, in case the level of the indicator moved down, we won’t deviate and will maintain a continuous line.

You can see here that the low goes above the indicator, but no close closes below this indicator.

Now, in case there was a close below the indicator, and here is an example, we’ll go back above it at some point and then draw the indicator above the prices.

I mean, that's it really. There isn’t much more to add.

We do need to mention, you know, what parameters are used for this indicator, namely, the inputs, the degrees of freedom of the strategy.

The parameters for the Super Trend are only two.

The first parameter is the length of the Average True Range, which is the channel used to check the Average True Range.

The default parameter is 10, which means that at this point, I’ll average the last ten ranges to add and subtract them starting from the mid-price.

After that, we have a second parameter, this one here, which is indicated as 3 and is simply the multiplier of this Average True Range.

So, to recap: when I reach a point, starting from the mid-price, I calculate the average of the last 10 ranges, and I add or subtract the value of this average multiplied by three, which is the value of our multiplier.

Starting from the mid-price, adding 3 times the 10-period Average True Range and subtracting 3 times the 10-period Average True Range.

After that, the last step consists in drawing the indicator above the price line when there is a reversal signal, and then draw the indicator below the price line when the opposite happens, that is, when the price crosses the indicator.

The Trading System

With that, we’re pretty much done with the theory. But we are systematic traders. So what we need to do now is to test this indicator.

With what? Well, with a strategy that bases its entries precisely on the reversal of the positions predicted by this indicator.

We’ve prepared a straightforward strategy for this video that calculates the Super Trend indicator through this function, which works exactly as I described to you before in this video.

We have two inputs, the length of the ATR and the multiplier of the ATR.

This is followed by a parameter determining whether the indicator is plotted above or below the prices.

If we are in an uptrend, the indicator will be drawn below the prices, and therefore, "ST" will be positive.

If we were short and the indicator was plotted above the prices, this indicator would be negative.

So, if we went from a short to a long condition, namely, if "ST" changes from negative to positive, we have the trigger for a long entry.

And conversely, we have the trigger for a short entry.

Once the triggers are set, we can enter orders with this small constraint, namely, when the condition to go short occurs, I’ll place a sell stop order at the low of the current bar.

And conversely, I'll place it at the high of the current bar, when we reach the long trigger.

We can now load this strategy on a chart.

For this occasion, I’ve prepared a chart with an hourly time frame for Gold.

I mean, we can use any time frame, if you want, either the daily time frame, the 2-hour time frame, or the 1-hour time frame.

I recommend that you don’t go beyond that, so don't lower the time frame any further, to 30, 15 minutes, or even 5 minutes, because that could lead to false entries due to market noise.

We entered this strategy with 10 and 3, the default parameters.

Let's go and take a look at what this strategy would do in terms of performance - and it would do nothing, I'd say.

Yeah, I mean we have quite an up-and-down period of performance, with an excessively lucky period in 2020 and then a terrible period in 2021 and 2022.

So what we can do now is go and see if there are any parameters, namely an ATR length and an ATR multiplier, that could perhaps improve the performance of the indicator for this underlying at this time frame.

So, let's optimize the parameters and test all possible combinations of "ATR length."

So, an ATR length from 5, let's say, to 60 - let's take it from 4, with steps of 2.

And then we’ll test the multiplier from 2 to - let's take 8, with steps of, say, 0.2.

Alright, we get about 900 combinations that we’ll process in less than 10 seconds.

That's it. I mean, we’re almost done. Okay. What do we get?

So we sort by net profit, and we see that the first strategy made almost $300,000 with a drawdown of about $40,000.

Take a look at the one in third place, which makes a little bit less profit, $250,000, with a drawdown of about $30,000.

The optimized System

Ok so let's try this example which implies an Average True Range length of 18 and a multiplier of 5.

Let's take a look at the equity line obtained. Here it is.

Alright, so for starters, this looks like a lovely equity line, so we’ve just coded the inputs based on the indicator.

The Average trade is excellent because it lets us easily cover commission and slippage costs.

We do about 50% of the trades long and 50% of the trades short, so the strategy is perfectly symmetrical in terms of both entry criteria and also as trades.

Let's take a quick look at this... The long side of the strategy is performing exceptionally well. The short side does as well.

It has a small negative trend in the first part.

And if we look at the trend year-by-year, we see that we have all positive years, and only 2010 is slightly negative.

Final thoughts

So…. can we consider the evolution of this system complete? No, definitely not!

I want to remind you that we still don’t have position management in place here.

And we haven’t even entered a stop loss or a take profit.

And we don't know still how to manage this strategy from a money management perspective.

And look, all these aspects are part of our daily work at Unger Academy.

And if you need help investing in the markets systematically and professionally as we do, I recommend that you go and click on the link in the description of this video.

That's going to take you to a page where you can find several handy resources. There you can sign up for a free presentation by Andrea Unger, you get our best-selling book, "The Unger Method," by just covering the shipping costs, or you can even book a call with a member of our team for a completely free strategic consultation.

And also, finally, I’d like to remind you to subscribe to our channel if you haven't already so of course, that way you’ll be notified immediately when new videos and content are released. And of course, if you did find this content particularly useful, please I invite you to leave us a Like.

With that, we will see you again soon with some new operational insights. Will see you next time, bye bye for now!

Need More Help? Book Your FREE Strategy Session With Our Team Today!

We'll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.

BOOK YOUR FREE STRATEGY SESSION NOW >>
Andrea Unger

Andrea Unger

Andrea Unger here and I help retail traders to improve their trading, scientifically. I went from being a cog in the machine in a multinational company to the only 4-Time World Trading Champion in a little more than 10 years.

I've been a professional trader since 2001 and in 2008 I became World Champion using just 4 automated trading systems. 

In 2015 I founded Unger Academy, where I teach my method of developing effecting trading strategies: a scientific, replicable and universal method, based on numbers and statistics, not hunches, which led me and my students to become Champions again and again.

Now I'm here to help you learn how to develop your own strategies, autonomously. This channel will help you improve your trading, know the markets better, and apply the scientific method to financial markets.

Becoming a trader is harder than you think, but if you have passion, will, and sufficient capital, you'll learn how to code and develop effective strategies, manage risk, and diversify a portfolio of trading systems to greatly improve your chances of becoming successful.