Trading System on Amazon Stocks - Creating a Strategy (Open 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 >>

Over the past 5 years the value of Amazon shares has almost tripled, which obviously makes them very appealing to traders and investors.

In this video we’ll show step-by-step how to build an automated strategy that makes the most of Amazon stock trends while reducing the impact of market drawdowns.

By watching the video you'll learn:

- How to program the strategy in Power Language and Easy Language (the system is open source so you can reuse it freely!)

- How to optimize strategy parameters to improve performance

- What kind of performance the system is able to produce once it’s optimized

Enjoy!

Transcription

Hey everyone, welcome back! One of the coaches at Unger Academy here and today we’re going to talk about Amazon and more specifically about a very simple and effective trading system that seems to be able to ride the most important bullish movements on this market.

We’re going to build a strategy based on breakout entries that lead to more interesting results than a traditional Buy and Hold.

What you see here is the result of the trading system and we’re going to build it from scratch together.

As already mentioned, we're going to look for a breakout operation. This means riding on a market trend that has just formed. And then we'll manage the positions through a symmetrical exit based on the same approach of the market entry.

There will then be a precautionary take profit and stop loss. So let's see together what the code is. Here it is. You can see it's very simple, just a few lines of code.

Let's review it together quickly. We have inputs dedicated precisely to the monetary amount of the stop loss and take profit.

You see here that they are set to 0.02 and 0.07 because we're going to insert them together with the input "MyCapital", namely the capital that we're going to invest for each trade. The resulting monetary value obtained by multiplying MyCapital by StopLoss or by TakeProfit will be the monetary amount of the stop loss and take profit of each trade.

Indeed, you can see that here we are using the "setstopposition" command, which indicates the monetary stop of the whole trade.

Going forward in the code, we have the variable "MySize", which is used to determine how many shares we're going to buy in each entry. In this case, you see that it's 100000 which means $100,000 divided by the closing bar price. So, we're going to decide how many shares to buy based on the countervalue of the position, which will be $100,000.

Then there is a filter based on the previous day's candlestick. For now, we'll leave it at 1. So, this "DF", or "Daily Factor", we'll leave it equal to 1 as input. Later on we'll be able to optimize it.

You can see that this Daily Factor coincides with the ratio between the body and the range. Of course, the body is always less than the range, so saying that this part of the code is less than 1 automatically implies a condition that's always true. So, it's as if this filter didn't exist.

Once this condition is met, and given a time range, meaning a trading time window, we'll buy at the breakout of the highs of the current session. After that, as I said, there will be a symmetrical exit on the lowest price of the current session.

So, let's start by studying a setup that we could call and define "standard". Namely: our monetary amount per position of $100,000, a stop loss at 2%, a larger take profit of 4% and the entry times at 10 am and 3:30 pm respectively.

Why these two hours? Because they coincide exactly with half an hour after the opening of the market and half an hour before the end of the cash session. Remember that these are always Exchange Times.

So we give our system the opportunity to process at least the first 30-minute bar, which runs from 9:30 to 10:00 am to determine what our breakout entry will be.

So let's look at this first result. The equity is already, let me say, very interesting. The Total Trade Analysis however tells us that the average trade you see here of $300 would coincide with about 0.3% of the trading countervalue.

It's still quite low. Commission costs are very low, even slippage on this type of action should not involve any type of risk. However, we could still work on it in order to isolate the most important trades, namely the trades that make us earn more, maybe by excluding the potentially negative trades.

Let's see with an optimization what are the effects of modifying the operative time window.

So, let's test different entry times ranging from 10 am to let's say 12:45 pm or maybe even 1 pm. Let's also vary every 15 minutes the part related to the minutes.

We can do the same with the end of the time window. We could start it maybe from 2:00 pm until 3:45 pm. We'll do the same with the minutes and the hours.

Let's launch this optimization. There are 128 combinations so it really takes very little time. Let's order the results by net profit.

Going to take a look both at the drawdown and the average trade, you’ll see that compared to the $300 from which we started at the beginning, not only do we earn more but we also increase our average trade.

Let's see what the hours are. Let's look for an acceptable and therefore fairly robust level. For example, we can take this level, which starts at 10:45 am instead of 10:00 am and ends at 2:30 pm instead of 3:30 pm.

We would then get an average trade of around $435. Still not, let me say, very high. But the equity line has definitely improved.

What we could do now is to figure out if the filter that we've prepared on the daily bar of the day before our entries could help us in some way.

So, using the same parameters found above, let’s optimize our Daily Factor starting from zero to one with step 0 1. Let’s adjust the values we found, so 10:45 am and 2:30 pm.

Let's launch these eleven combinations. Let's see if this filter is actually effective or not. Remember that we were starting from 1, so with many trades, zero filter and an average trade of about $435.

You can see that as we go to filter the entries, thus decreasing the number of trades that are executed, the average trade seems to increase.

We have got 435, 444, 468, and then it increases until we get to a 650, 625, 645. Then it goes down, but here we're already talking about 100 trades, 200 trades so the effect obviously starts to wear off.

I would stay with 0.5, which is a halfway value. It isn't the best in absolute as an average trade, as you can see here, 645, but it certainly allows us to make more trades and to earn more money. Not as much as 0.6, but that's a personal choice. I prefer a slightly larger average trade with fewer trades even if it earns slightly less.

Let's go get this setup choice. Now the equity we got isn't bad at all! The average trade is reaching almost 1%. We're now at 0.65. As I said, slippage costs and commissions aren’t included at the moment, but they shouldn't affect this kind of action too much.

And once again simplicity has rewarded us. Because remember that this strategy is made up by very few lines of code. It employs a very simple operational filter, a time window, and an entry based on a really very simple trigger.

Well I hope I have aroused your curiosity. You can examine it further, perhaps by adding another filter or, why not, varying the triggers. For example, you could switch to using triggers related to the high or low of the previous day and not of the current session.

In short, Amazon seems to be a good choice for this kind of breakout approach.

I really hope this video was helpful! And hey, if you need any help to start investing in the markets with a systematic approach, just like the one we've just shown in this video, I’d suggest that you click on the link below. It'll take you to a page full of very useful resources. You can sign up for a free presentation by Andrea Unger, our founder and the only 4-time world champion of real money trading, get our best-selling book "The Unger Method" paying only postage, or even book a free call with a member of our team for a free consultation.

Finally, I'd like to remind you, if you haven't already done so, to please subscribe to our channel and click on the notification bell to stay updated on the release of all our new content. And if you liked this video, hey leave us a “Like”!

And with that, I will see you soon in our next video! Until then, 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.