Trading System on Tesla Stocks: Script, Backtest and Optimization

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 >>

Tesla's shares have risen a lot in recent times, but they have also gone through periods of drawdown not always easy to digest...

As is often the case, a good trading strategy can be the best way to invest in a market without suffering the drawdowns that you might encounter with a simple Buy and Hold strategy.

In this video, you’ll learn step-by-step how to build a breakout strategy for Tesla shares (TSLA) that produces a very good equity line.

By watching the video you'll learn: 

- How to code the strategy in MultiCharts (and TradeStation)

- How to improve the efficacy of entries

- How to set stop loss and take profit

Enjoy the video! 😎

Transcription

Intro

Hey everyone and welcome back. Today we’re going to be talking about a very simple and yet effective strategy to dominate the market of one of the most famous American stocks, Tesla. You’ll learn how to build a real trading system based on very simple entries that lead to much more interesting results than the classic Buy and Hold strategy that you could do on this stock.

I'm one of the coaches of Unger Academy. 

The Strategy and the Script

Okay, so let's start right away by saying what our intentions are towards this market. We're going to build a breakout strategy, so we're going to be hoping on the train of a market movement that has formed, and then manage the positions with an exit based on the same approach, or with a take profit and a precautionary stop loss.

Here is the code. I'll describe it quickly for you. We have some inputs dedicated to the monetary amount of the stop loss and take profit. After that, an input to establish which is the operating time slot at which we're going to place the orders. Then we have the variable "My Size", which is used to go and determine how many shares we're going to buy in each entry. In this case, you see 10000, which stands for $10,000, divided by the closing price of the bar. So we' re going to decide how many shares to buy based on the countervalue of the position, which will be $10.000.

We'll enter the market through stop orders based on the highest price reached from the beginning of the session. Then we'll sell upon reaching the lowest price of the session so far, and we'll control the position through a stop loss and take profit order.

Notice in this position the "set stop position" which indicates that the monetary value we're going to write here and here will refer to the whole position. So not to the single contract, as we do for futures, but to the whole position. So if for example, we write a stop loss of $200, it will correspond to a percentage stop loss of 2% of our $10,000 position. 

Let's compile our strategy. I've already entered, as you see here at the top, the values of $250 and $750 for the first two inputs, so we'll be dealing with a 2.5% stop loss and a 7.5% take profit. The operation starts at 10 am and ends at 3:30 pm, half an hour before the end of the American cash session. In fact I'd like to point out that the trading hours considered are from 9:30 am to 4:00 pm exchange time.

Initial Results

Let's look at the performance this system would have done from early 2010 onwards. It is obviously only a long system because it's an equity asset. The result is definitely good. We can see it here, this $66.50 average trade corresponds to 0.6% of the position's value.

It's not bad at all but more could be done. How could we do more? We can go looking for the best times to use this breakout entry. Maybe waiting a little longer for significant highs and lows for the breakout entry could lead to a benefit. For now, with an input set to, you see here, 1000, which stands for 10:00, we're going to build high and low values, so HighD(0) and LowD(0), based only on the first 30 minutes of trading. 

Optimization

So how can we find out what the best times would be? With a very simple optimization. So let's optimize the starting time. We could make, as an example, a start value of 9 am to finish at 12:45 pm. Notice that I'm going to optimize the times, namely at 9:00 am, 10:00 am, 11:00 am and 12:00 pm, and at the same time also the minutes. This optimization from 0 to 45 minutes in steps of 15 minutes means that for each hour, I'm going to see the times ranging from 0 to 45 minutes. It is a little trick to allow us, in one optimization, to get an output that is as precise as the timeframe that we're using as reference, in this case 15 minutes.

You see that the results are identical for the first few timeframes. So, from 9 am to 9:45 am. Why? Because trading starts at 9:30 am and the first useful bar will be the one closing at 9:45 am.

So from here on you can see that waiting for entry, namely waiting until around 11:30 am could bring benefits in terms of average trade. Here you can see that we reach a good 1% which is already very good, because a trading system with 1% of average trade is already enough to cover all slippage costs and commissions that we might encounter during live trading. We have a rather small drawdown compared to the values obtained by entering at breakout immediately. The number of trades is obviously reduced. So, the net profit is reduced a little bit but by operating with half of the trades, we'll definitely get only the most relevant trades from a performance standpoint.

We then go to choose 11:30 am as our entry time. Let's check the equity improvement. We now find ourselves with $103 of average trade and an equity line that produces results that are definitely better. 

We could echo the same statement for the end of trades. So, let's go through the same process again. We're going to optimize also here from 2 pm to 4 pm and from 0 to 45 minutes. We'll notice that also for this optimization from a certain point onwards we'll get the same results. In particular 4:15 pm, 4:30 pm and 4:45 pm will produce the same results because the market closes at 4 pm, remember? Using the earlier time, so 4:15pm, which is the earliest one from 4 pm that includes the last bar, so 4:15 is the last useful result. We can see that there is some consistency in the results, so to speak, and therefore we could use a time around 3:15 pm, 3:00 pm or 3:30 pm. It doesn't make a great difference. You see that in terms of average trade, it really changes very little. And the same goes for drawdown and net profit.

So let's pick 3:15 pm and we could say that our trading system can be considered complete. We've reached a very interesting rising equity, with a large average trade and a pretty steady performance over time. There's only 2016 that you know wavers a little bit.

Of course, this doesn't bring the returns that a Buy and Hold strategy of Tesla stocks would have produced from the beginning of 2010 until today. But it is also true that having such an equity line is certainly much more comforting than a Buy and Hold on this stock.

Final Results and Thoughts

If we were to take the chart of Tesla for example in the last period, here on the tradingview, you can see that in the last year or year and a half, the shares have experienced crazy drawdowns and so it's far more difficult psychologically to manage the Buy and Hold of such a share compared to a strategy of this type, which certainly earns less in absolute terms, but also allows us to at least have a good night's sleep.

This is just a small sample of what we do on a daily basis here at Unger Academy. If you want to learn more about systematic trading and how to build these automated strategies, I invite you to go and check out our free webinar. You can find a link to that in the description of this video. In this webinar, Andrea Unger, the only 4-time world trading champion will explain step-by-step how to approach this fascinating world.

Finally, if you haven’t done it yet, I invite you to please go and subscribe to our channel, leave us a “Like” and click on the notification bell to stay updated on the release of all our new videos coming out.

Also please, if there are any topics that you would like to be discussed in our next videos, please write them down in the comments.

Thank you so much for watching this video and we really hope that this has helped you. And I will see you soon! Bye-bye! 

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.