Ideal for beginners!
Free Demo Account + Free Trading Education!
Get a Sign-up Bonus:
2nd place in the ranking!
Part 1: Technical Analysis – Trend Lines
I present to you a new series of binary options trading articles. It will be loosely related to the MT4 show, so if you do not know that show, be sure to check it out, it is essential to understanding of everything we will learn in this show.
In this show, we can look forward to explanation of various strategies, which will be little more complicated and not as easy, as watching simple indicators.
In the first part we will talk about one of the most basic things – trend lines.
What are trends?
Example of uptrend (click to enlarge)
There are two trends – increasing (uptrend) and decreasing(downtrend). Increasing trend means, that the price for the previous period (of eg. 40 candles) is increasing rapidly and if it (the price) falls, then its only slightly and it will begin to increase (uptrend) very soon. Decreasing trend is complete opposite – the price is rapidly decreasing.
Trends tell us, whether the long-term price rises or drops. Sometimes it also happens that the price does not have any trend = it is stagnating. This means that the price in the last period somewhat increased, but on the other hand also decreased. The price isnt higher or lower by much. Are we clear?
How to use such a trend to our advantage and proper assumption of further development is a question little more complicated. We have a choice of two options: Either the price will continue this trend or it will reach certain threshold and make so-called turnover and begin to develop in opposite direction.
Drawing trend lines
Drawing trend lines is one of the strongest indicators there is. It will help us predict the reversal of the trend, when (if) the price reaches certain limits. Lets learn together how to draw such lines.
Ideal for beginners!
Free Demo Account + Free Trading Education!
Get a Sign-up Bonus:
2nd place in the ranking!
Drawing trend lines for the growing trend
Example of drawing trend lines (click to enlarge)
- We will determine, whether the trend is actually increasing (according to the aforementioned definition. )
- In the chart we find a place that has recently been lowest. (A)
- We connect this place with the closest point drop in the graph. (B)
- We extend the line.
What is the line useful for?
We see that every time after the price touched our line, it bounced back up. Using this line, we can predict that if the price touches our line, then it will probably increase, so we can choose the CALL trade with our broker.
Drawing trend lines for the downtrend
Drawing trend line for the downtrend works on the same principles, the only difference is that everything is done the opposite.
Example of drawing trend lines (click to enlarge)
- We determine whether the trend is indeed decreasing (according to the aforementioned definition. )
- In the chart we find a place that has recently been highest.
- We connect this place with the closest point of maximum rise in the prices during a downturn.
- We extend the line.
And why did we do this again?
We see that every time after the price touched our line, it bounced back and started to decrease again. Using this line, we can predict that if the price touches the line, it should decrease and therefore we can choose the PUT trade with our broker.
That would be all for today. I hope that i have taught you something new, and in the next episode we will talk about the inner and outer trend lises which are equally important.
If you liked the article, or if you have any comments, i will be very happy if you let me know in the comment section.
More about the author Step
I’ve wanted to build a business of some kind and earn money since I was in middle school. I wasn’t very successful though until my senior year in highschool, when I finally started to think about doing online business. Nowadays I profitably trade binary options full-time and thus gladly share my experiences with you. More posts by this author
7 Responses to “Part 1: Technical Analysis – Trend Lines”
can i find the same tools on Olymptrade platform to draw this lines
Tetteh, unfortunately that’s not possible. I recommend to download the program Meta Trader 4 where you can make all the analysis.
That’s nice of you. But with what will I draw the line?
Dear Dave, if you’re using MT4, there’s plenty of tools to do so.
Implementing the up-trendline indicator with Python — From acquiring data to modeling an algorithm and implementing a solution — Part 1 consuming a REST API
Requirements — You should be familiar with the following topics:
- Having worked with python, objects, loops and data types.
- Have some understanding about pandas and the requests library.
- Know what technical analysis is.
Looking to refresh your skills or get an introduction to above topics? I can highly recommend following resources:
This is the first article in a series of articles about working with stock price data and implementing the up-trendline indicator with Python. The complete series will describe in detail implementation of the technical indicator called up-trendline. This article will describe the part of the solution which consumes the REST API, which will give us the data we will need in subsequent articles.
A brief explanation of the Up-Trendline indicator
In technical analysis the most well known and simple technical indicator is the up-trendiness analysis. This indicator is essentially a straight line and therefore relatively easy to recognize when looking at a graph. The pattern is a straight line which must go through at least three points. The lines slope must be increasing and must not be broken by a point that may be further ahead on the graph.
An uptrend line indicates; stock price will continue to be above the trend line, hence it will continue to rise. If at any time stock price hits the trend line, and as a result crosses the trend line; it signals the stock price will have a declining trend. See the illustration below.
If you keen to learn more about the indicator and in general about technical analysis. You will find more information here.
This is what we will build throughout this article
First and foremost you will need to install Python on your machine. I suggest installing Anaconda; in my opinion the easiest way to get working locally with python. But in this article I shall not go into the detail with setting up the developing environment. However, the matter will be subject in an exclusive article about installing Anaconda and setting up a development environment.
The rest of this article will focus on:
- how to connect to Alphavantage REST API.
- processing of data and placing it in a pandas data frame.
- working with pandas data frame in order to prepare it for actual analysis.
Connecting to Alphavantage
First you need to have an API Key. This can be obtained by visiting the following link: https://www.alphavantage.co/ selecting ‘GET YOUR FREE API KEY TODAY’.
Here I assume you have installed Anaconda and created an environment with Python 2.7.xx installed.
You also have to install the following libraries in the environment you are using:
Next create the .py files. Create following .py files inside your project folder:
The file ‘get_historical_data.py’
First you need to import all necessary libraries we will be using in file get_historical_data.py.
We are then interested in creating a new class which will contain all necessary methods needed to connect to the REST API and retrieve the necessary data.
We will name the class AlphaVantage . This class needs a __init__ method, which will be called upon instantiation of the class. The __init__ method should look as follows:
Now I shall go through each line of code line by line. We already have created a class by defining it inline 5. In line 7 we define the __init__ method. This method will take three arguments where two of them will have a default value, meaning they will be optional when calling the class. In the __init__ method there are six variables defined on between the lines 8 to 13.
- self.base_url contains the value “https//www.alphavantage.co” . This value will be used each time we need to build an url for calling the REST API.
- self.default_endpoint contains the value “/query” . This value is one of the endpoints of the REST API we will call multiple times. Therefore we want to put it in the __init__ method and thus avoid defining it multiple times.
- self.api_key here you want to enter the API Key you retrieved from Alphavantage.
- self.symbol_code the value for this variable is set by the parameter symbol_code , which we will be parsing when instantiating this class.
- self.interval is set by the parameter interval , which has a default value set to “60min” . This variable will later be used as a parameter when calling one of the endpoints provided by the REST API.
- self.outputsize is a variable set by the parameter outputsize , which also has a default value set to “compact” . This variable will also be used later as a parameter when calling one of the REST API endpoints.
Up to this point we have included all necessary libraries, defined a class and created our __init__ method within the class. Now we shall create an additional method called intraday inside the class AlphaVantage.
The intraday method does not take any arguments except self. Ff you want to understand what self does in Python I suggest reading this article.
The intraday methods purpose is to call a specific endpoint with some parameters and return the response as JSON. For the purpose of calling the REST API we use the requests library, more specific we will use the requests.get() method. This method takes a number of parameters. We will provide the following:
- The url we want to call. We build the url in line 21 specifically the part “<0><1>“.format(self.base_url, self.default_endpoint) . As you can see we use some of the variables defined in the __init__ method.
- We also have to provide parameters the REST API endpoint requires. For this we will build a dict called parameters , with some keys and values. The dict with its keys’ and values is defined in line 12 to 19. The keys’ and values in the dict, each represent a parameter the REST API endpoint requires in order to respond with the desired output.
Let’s go through some of the parameters defined in our dict called parameters .
- “symbol” this keys’ value is set to variable self.symbol . We need to provide the endpoint with this parameter in order to specify for which company we want to see the stock price.
- “interval” this keys’ value is set to the variable self.interval which has the value “60min” . This means we want intraday data by the hour, resulting in 24 data points for each day.
- “outputsize” this keys’ value is set to the variable self.outputsize which has the value “compact” . In short this means we will receive the latest 100 data-points for any given “symbol” we make a request for.
If you want to learn more about this specific endpoint and in general about the Alphavantage REST API. I suggest taking a look at the documentation.
So now we have defined the method intraday , where we call a specific endpoint in the Alphavantage REST API. Furthermore, we have also defined all necessary parameters in a dict and provided the dict as a parameter to requests.get() method in line 21. Finally the last part of our method, line 23, returns the response we receive from the REST API we are calling.
Now we shell implement another method called daily in our class AlphaVantage .
This method is very similar to the previous one. The daily methods’ purpose is to return stock price data on a daily basis instead of intraday. For that purpose there are two differences in this method compared to the previous. In line 13 the value for key “function” is now set to “TIME_SERIES_DAILY” , and we no longer have key “interval” . Everything else stays the same and therefore no additional explanation is needed for this method.
The final get_historical_data.py file should now look as follows:
The file ‘get_main_df.py’
For this file you need to import the libraries pandas and json , in addition you also need to import the AlphaVantage class from file get_historical_data.py.
We are now interested in creating a new function called get_main_data_frame . This function will at the moment contain all the logic we implement in the file get_main_df.py.
The first step we want to do in the function is call the AlphaVantage class in order to get some data we can then work with. We name this instance historical_data_daily .
Notice that we also call the method daily() which is one of the methods implemented in class AlphaVantage . This means we will receive daily data and not intraday data.
The next code snippet contains a lot of code, however, the main focus is to iterate through the response received from calling the Alphavantage REST API.
In line 15 and 16 two empty lists are defined. list_keys will contain all keys’ which are relevant for us and list_historical_data_daily will end up containing all data we want to work with. Here I am assuming that you have some basic knowledge working with dicts and JSON data.
Line 17 and 18 iterate through all keys’ found in key “Time Series (Daily)” . Each key we find is appended to list_keys . In this context each key actually represents a date.
Lines 20 to 40 do couple of things. First we access the data in each key we have in list_keys and assign it to the variable data . Then four data points are identified price_open , price_high , price_low and price_close . All four variables will contain a numeric value representing a price for a given day.
Next a dict is defined with keys’. This will be the data we want to save for each day. The dict contains a date and a symbol, and the four price values. Finally the dict is appended to list_historical_data_daily .
The reminder of the code which can be seen in next code snippet is focusing on working with pandas in order to prepare the data for further analysis.
The first thing we want to do is take all our data stored in list_historical_data_daily and convert it to a pandas data frame. This is done in line 15.
- Line 20 creates the field ‘date_str’ . This field is derived from ‘date’ field.
- Line 21 sets field ‘date’ to be the new index of the data frame.
- Line 22 sorts the index. The default sorting is ascending meaning the oldest date will be first.
- Line 24 creates the field ‘price_close_lag’ . This field shows close price data from previous day. This will be useful when we in a subsequent article want to compare today’s price with the day before price, in order to determine the direction of the price.
- Line 25 creates the field ‘price_close_lag’ . This field shows close price data from tomorrow. Like the previous field this field will also be of interest for later analysis in terms of comparing the prices.
- Line 27 creates the field ‘date_id’ . This field increments an int value starting from 1. It is important that the pandas data frame is sorted ascending. Therefore, previously the index, which is a date value is sorted ascending.
Finally the data frame called df is returned.
The final get_main_file.py file should now look like following:
Hopefully, this article can give some ideas on how to start working with stock data, where to get data, and how to start preparing it in order to apply algorithms.
The next article PART 2 will focus on implementing the technical indicator up-trendline. I hope you are up for it, as it will be a bit more complicated but on the contrary more exciting.
If you are interested to know more about me. Please visit my personal profile on LinkedIn https://www.linkedin.com/in/vedranmarkulj/
Thanks for reading. If you are interested in future posts about Machine Learning and similar topics written by me, follow me on Medium and LinkedIn. More articles are on the way.
Support and Resistance Basics
The concepts of support and resistance are undoubtedly two of the most highly discussed attributes of technical analysis. Part of analyzing chart patterns, these terms are used by traders to refer to price levels on charts that tend to act as barriers, preventing the price of an asset from getting pushed in a certain direction. At first, the explanation and idea behind identifying these levels seem easy, but as you’ll find out, support and resistance can come in various forms, and the concept is more difficult to master than it first appears.
Trading With Support And Resistance
- Technical analysts use support and resistance levels to identify price points on a chart where the probabilities favor a pause or reversal of a prevailing trend.
- Support occurs where a downtrend is expected to pause due to a concentration of demand.
- Resistance occurs where an uptrend is expected to pause temporarily, due to a concentration of supply.
- Market psychology plays a major role as traders and investors remember the past and react to changing conditions to anticipate future market movement.
- Support and resistance areas can be identified on charts using trendlines and moving averages.
Support and Resistance Defined
Support is a price level where a downtrend can be expected to pause due to a concentration of demand or buying interest. As the price of assets or securities drops, demand for the shares increases, thus forming the support line. Meanwhile, resistance zones arise due to selling interest when prices have increased.
Once an area or “zone” of support or resistance has been identified, those price levels can serve as potential entry or exit points because, as a price reaches a point of support or resistance, it will do one of two things—bounce back away from the support or resistance level, or violate the price level and continue in its direction—until it hits the next support or resistance level.
The timing of some trades is based on the belief that support and resistance zones will not be broken. Whether the price is halted by the support or resistance level, or it breaks through, traders can “bet” on the direction and can quickly determine if they are correct. If the price moves in the wrong direction, the position can be closed at a small loss. If the price moves in the right direction, however, the move may be substantial.
Most experienced traders can share stories about how certain price levels tend to prevent traders from pushing the price of an underlying asset in a certain direction. For example, assume that Jim was holding a position in stock between March and November and that he was expecting the value of the shares to increase.
Let’s imagine that Jim notices that the price fails to get above $39 several times over several months, even though it has gotten very close to moving above that level. In this case, traders would call the price level near $39 a level of resistance. As you can see from the chart below, resistance levels are also regarded as a ceiling because these price levels represent areas where a rally runs out of gas.
Support levels are on the other side of the coin. Support refers to prices on a chart that tend to act as a floor by preventing the price of an asset from being pushed downward. As you can see from the chart below, the ability to identify a level of support can also coincide with a buying opportunity because this is generally the area where market participants see value and start to push prices higher again.
The examples above show a constant level prevents an asset’s price from moving higher or lower. This static barrier is one of the most popular forms of support/resistance, but the price of financial assets generally trends upward or downward, so it is not uncommon to see these price barriers change over time. This is why the concepts of trending and trendlines are important when learning about support and resistance.
When the market is trending to the upside, resistance levels are formed as the price action slows and starts to move back toward the trendline. This occurs as a result of profit-taking or near-term uncertainty for a particular issue or sector. The resulting price action undergoes a “plateau” effect, or a slight drop-off in stock price, creating a short-term top.
Many traders will pay close attention to the price of a security as it falls toward the broader support of the trendline because, historically, this has been an area that has prevented the price of the asset from moving substantially lower. For example, as you can see from the Newmont Mining Corp (NEM) chart below, a trendline can provide support for an asset for several years. In this case, notice how the trendline propped up the price of Newmont’s shares for an extended period of time.
On the other hand, when the market is trending to the downside, traders will watch for a series of declining peaks and will attempt to connect these peaks together with a trendline. When the price approaches the trendline, most traders will watch for the asset to encounter selling pressure and may consider entering a short position because this is an area that has pushed the price downward in the past.
The support/resistance of an identified level, whether discovered with a trendline or through any other method, is deemed to be stronger the more times that the price has historically been unable to move beyond it. Many technical traders will use their identified support and resistance levels to choose strategic entry/exit points because these areas often represent the prices that are the most influential to an asset’s direction. Most traders are confident at these levels in the underlying value of the asset, so the volume generally increases more than usual, making it much more difficult for traders to continue driving the price higher or lower.
Unlike the rational economic actors portrayed by financial models, real human traders and investors are emotional, make cognitive errors, and fall back on heuristics or shortcuts. If people were rational, support and resistance levels wouldn’t work in practice!
Another common characteristic of support/resistance is that an asset’s price may have a difficult time moving beyond a round number, such as $50 or $100 per share. Most inexperienced traders tend to buy or sell assets when the price is at a whole number because they are more likely to feel that a stock is fairly valued at such levels. Most target prices or stop orders set by either retail investors or large investment banks are placed at round price levels rather than at prices such as $50.06. Because so many orders are placed at the same level, these round numbers tend to act as strong price barriers. If all the clients of an investment bank put in sell orders at a suggested target of, for example, $55, it would take an extreme number of purchases to absorb these sales and, therefore, a level of resistance would be created.
Most technical traders incorporate the power of various technical indicators, such as moving averages, to aid in predicting future short-term momentum, but these traders never fully realize the ability these tools have for identifying levels of support and resistance. As you can see from the chart below, a moving average is a constantly changing line that smooths out past price data while also allowing the trader to identify support and resistance. Notice how the price of the asset finds support at the moving average when the trend is up, and how it acts as resistance when the trend is down.
Traders can use moving averages in a variety of ways, such as to anticipate moves to the upside when price lines cross above a key moving average, or to exit trades when the price drops below a moving average. Regardless of how the moving average is used, it often creates “automatic” support and resistance levels. Most traders will experiment with different time periods in their moving averages so that they can find the one that works best for this specific task.
In technical analysis, many indicators have been developed to identify barriers to future price action. These indicators seem complicated at first, and it often takes practice and experience to use them effectively. Regardless of an indicator’s complexity, however, the interpretation of the identified barrier should be consistent to those achieved through simpler methods.
The “golden ratio” used in the Fibonacci sequence, and also observed repeatedly in nature and social structure.
For example, the Fibonacci retracement tool is a favorite among many short-term traders because it clearly identifies levels of potential support/resistance. The reasoning behind how this indicator calculates the various levels of support and resistance is beyond the scope of this article, but notice in Figure 5 how the identified levels (dotted lines) are barriers to the short-term direction of the price.
Measuring the Significance of Zones
Remember how we used the terms “floor” for support and “ceiling” for resistance? Continuing the house analogy, the security can be viewed as a rubber ball that bounces in a room will hit the floor (support) and then rebound off the ceiling (resistance). A ball that continues to bounce between the floor and the ceiling is similar to a trading instrument that is experiencing price consolidation between support and resistance zones.
Now imagine that the ball, in mid-flight, changes to a bowling ball. This extra force, if applied on the way up, will push the ball through the resistance level; on the way down, it will push the ball through the support level. Either way, extra force, or enthusiasm from either the bulls or bears, is needed to break through the support or resistance.
A previous support level will sometimes become a resistance level when the price attempts to move back up, and conversely, a resistance level will become a support level as the price temporarily falls back.
Price charts allow traders and investors to visually identify areas of support and resistance, and they give clues regarding the significance of these price levels. More specifically, they look at:
Number of Touches
The more times the price tests a support or resistance area, the more significant the level becomes. When prices keep bouncing off a support or resistance level, more buyers and sellers notice and will base trading decisions on these levels.
Preceding Price Move
Support and resistance zones are likely to be more significant when they are preceded by steep advances or declines. For example, a fast, steep advance or uptrend will be met with more competition and enthusiasm and may be halted by a more significant resistance level than a slow, steady advance. A slow advance may not attract as much attention. This is a good example of how market psychology drives technical indicators.
Volume at Certain Price Levels
The more buying and selling that has occurred at a particular price level, the stronger the support or resistance level is likely to be. This is because traders and investors remember these price levels and are apt to use them again. When strong activity occurs on high volume and the price drops, a lot of selling will likely occur when price returns to that level, since people are far more comfortable closing out a trade at the breakeven point rather than at a loss.
Support and resistance zones become more significant if the levels have been tested regularly over an extended period of time.
The Bottom Line
Support and resistance levels are one of the key concepts used by technical analysts and form the basis of a wide variety of technical analysis tools. The basics of support and resistance consist of a support level, which can be thought of as the floor under trading prices, and a resistance level, which can be thought of as the ceiling. Prices fall and test the support level, which will either “hold,” and the price will bounce back up, or the support level will be violated, and the price will drop through the support and likely continue lower to the next support level.
While spotting support and resistance levels on a chart is relatively straightforward, some investors dismiss them entirely because the levels are based on past price moves, offering no real information about what will happen in the future.
Determining future levels of support can drastically improve the returns of a short-term investing strategy because it gives traders an accurate picture of what price levels should prop up the price of a given security in the event of a correction. Conversely, foreseeing a level of resistance can be advantageous because this is a price level that could potentially harm a long position, signifying an area where investors have a high willingness to sell the security. As mentioned above, there are several different methods to choose when looking to identify support/resistance, but regardless of the method, the interpretation remains the same—it prevents the price of an underlying asset from moving in a certain direction.
Ideal for beginners!
Free Demo Account + Free Trading Education!
Get a Sign-up Bonus:
2nd place in the ranking!