Best Choice For Beginners!
Free Trading Education!
Free Demo Account!
Big Sign-up Bonus!
Perfect For Experienced Traders!
Intraday Technical Analysis 28 November
U.S. third quarter GDP expected to be revised slightly higher to 3.6%
The U.S. Dollar was seen rallying to previously established highs from just a few weeks ago. The strong rally in the USD sent most of its peers back to their lows. Economic data from the Eurozone was relatively quiet for the most part.
The NY trading session saw the National House Price index falling for the sixth consecutive month. Reports showed that housing prices rose 5.5% on an annualized basis in September. This was weaker than the 5.7% increase registered in August.
The weaker NHPI report echoes similar views as existing home sales; housing starts fell sharply in September. The declines were attributed to the higher costs for borrowing.
The Fed vice chair, Richard Clarida was speaking yesterday. He supported the Fed’s view for gradual rate hikes noting that it was appropriate for interest rates to rise as it moves closer to its optimal setting.
Looking ahead, the markets seem to a somewhat busy day today. In the overnight trading session, the RBNZ Governor Orr was speaking. The RBNZ head said that the Central Bank would ease lending restrictions from January next year while requiring higher capital requirements for banks.
The European session will see the release of the German Gfk consumer climate. Economists forecast the consumer climate to ease to 10.5 from 10.6. Meanwhile, in the NY trading session the, second revised GDP estimates will be coming out. There is an expectation for the third quarter GDP to be revised slightly higher to 3.6% from the initial estimates which showed a 3.5% increase.
The GDP report is later followed by the new home sales report which is expected to rise to 583k on a seasonally adjusted basis. The Richmond Fed manufacturing index is expected to edge higher to 16 from 15 previously.
Wrapping up the day, Fed Chair, Jerome Powell is expected to speak late in the evening.
EURUSD intraday analysis
EURUSD (1.1295): The EURUSD currency pair posted declines with price action seen falling back to the support area of 1.1315 – 1.1300. A brief drop below this level has seen the common currency clearing the support level. This could potentially expose the lows of 1.2200 that was tested in early November. The declines could stall at this level in the near term as the common currency could establish a new range. If the EURUSD manages to break past the current support area, we expect the sideways consolidation to continue.
GBPUSD intraday analysis
GBPUSD (1.2738): The British pound finally gave way near the support level of 1.2808 as prices slipped lower back into the major support area. We expect the declines could push the pound sterling down to the 1.2683 level of lower support. In the near term, however, price action could turn rather flat. Any reversal in price action could be seen retesting the 1.2808 level where resistance could be established.
XAUUSD intraday analysis
XAUUSD (1214.65): Gold prices extended the declines strongly after a few sessions of trading flat. The declines came as price broke past the support level at 1223.50 pushing prices lower. For the moment, the precious metal seems to be bouncing off the temporary support mentioned at 1213.50. A reversal off this level could drive gold prices back to testing the 1223.50 where resistance could be established. Alternately, a break down below 1213.50 could trigger further declines down to the 1204.08 level.
Stop Hunting With the Big Forex Players
The forex market is the most highly leveraged financial market in the world – meaning that traders take on debt to acquire larger positions than they could with only their cash on hand. In equities markets, the standard margin is set at 2:1, which means that a trader must put up at least $50 cash to control $100 worth of stock. In options, the leverage increases to 10:1, with $10 controlling $100. In the futures markets, the leverage factor is increased to 20:1.
Best Choice For Beginners!
Free Trading Education!
Free Demo Account!
Big Sign-up Bonus!
Perfect For Experienced Traders!
- Because forex trading involves a great deal of leverage, traders large and small often employ stop and stop-limit orders to stave off margin calls or lock in profits automatically.
- Stop hunting is a strategy that attempts to force some market participants out of their positions by driving the price of an asset to a level where many have chosen to set their stop-loss orders.
- The triggering of several stop losses at once can lead to high volatility and present a unique opportunity for investors who seek to trade in this environment.
Leverage in Forex Markets
For example, in a Dow Jones futures e-mini contract, a trader only needs $2,500 to control $50,000 worth of stock. However, none of these markets approaches the intensity of the forex market, where the default leverage at most dealers is set at 100:1 and can rise up to 200:1. That means that a mere $50 can control up to $10,000 worth of currency. Why is this important? First and foremost, the high degree of leverage can make FX either extremely lucrative or extraordinarily dangerous, depending on which side of the trade you are on.
In FX, retail traders can literally double their accounts overnight or lose it all in a matter of hours if they employ the full margin at their disposal, although most professional traders limit their leverage to no more than 10:1 and never assume such enormous risk. But regardless of whether they trade on 200:1 leverage or 2:1 leverage, almost everyone in FX trades with stops. In this article, you’ll learn how to use stops to set up the “stop hunting with the big specs” strategy.
Stops are Key
Precisely because the forex market is so leveraged, most market players understand that stops are critical to long-term survival. The notion of “waiting it out,” as some equity investors might do, simply does not exist for most forex traders. Trading without stops in the currency market means that the trader will inevitably face forced liquidation in the form of a margin call. With the exception of a few long-term investors who may trade on a cash basis, a large portion of forex market participants are believed to be speculators, therefore, they simply do not have the luxury of nursing a losing trade for too long because their positions are highly leveraged.
Because of this unusual duality of the FX market (high leverage and almost universal use of stops), stop hunting is a very common practice. Although it may have negative connotations to some readers, stop hunting is a legitimate form of trading. It is nothing more than the art of flushing the losing players out of the market. In forex-speak they are known as weak longs or weak shorts. Much like a strong poker player may take out less capable opponents by raising stakes and “buying the pot,” large speculative players (like investment banks, hedge funds and money center banks) like to gun stops in the hope of generating further directional momentum. In fact, the practice is so common in FX that any trader unaware of these price dynamics will probably suffer unnecessary losses.
Because the human mind naturally seeks order, most stops are clustered around round numbers ending in “00.” For example, if the EUR/USD pair was trading at 1.2470 and rising in value, most stops would reside within one or two points of the 1.2500 price point rather than, say, 1.2517. This fact alone is valuable knowledge, as it clearly indicates that most retail traders should place their stops at less crowded and more unusual locations.
More interesting, however, is the possibility of profit from this unique dynamic of the currency market. The fact that the FX market is so stop driven gives scope to several opportunistic setups for short-term traders. In her book “Day Trading The Currency Market” (2005), Kathy Lien describes one such setup based on fading the “00” level. The approach discussed here is based on the opposite notion of joining the short-term momentum.
Taking Advantage of the Hunt
The “stop hunting with the big specs” is an exceedingly simple setup, requiring nothing more than a price chart and one indicator. Here is the setup in a nutshell: on a one-hour chart, mark lines 15 points of either side of the round number. For example, if the EUR/USD is approaching the 1.2500 figure, the trader would mark off 1.2485 and 1.2515 on the chart. This 30-point area is known as the “trade zone,” much like the 20-yard line on the football field is known as the “redzone.” Both names communicate the same idea – namely that the participants have a high probability of scoring once they enter that area.
The idea behind this setup is straightforward. Once prices approach the round-number level, speculators will try to target the stops clustered in that region. Because FX is a decentralized market, no one knows the exact amount of stops at any particular “00” level, but traders hope that the size is large enough to trigger further liquidation of positions – a cascade of stop orders that will push price farther in that direction than it would move under normal conditions.
Therefore, in the case of long setup, if the price in the EUR/USD was climbing toward the 1.2500 level, the trader would go long the pair with two units as soon as it crossed the 1.2485 threshold. The stop on the trade would be 15 points back of the entry because this is a strict momentum trade. If prices do not immediately follow through, chances are the setup failed. The profit target on the first unit would be the amount of initial risk or approximately 1.2500, at which point the trader would move the stop on the second unit to breakeven to lock in profit. The target on the second unit would be two times initial risk or 1.2515, allowing the trader to exit on a momentum burst.
Aside from watching these key chart levels, there is only one other rule that a trader must follow in order to optimize the probability of success. Because this setup is basically a derivative of momentum trading, it should be traded only in the direction of the larger trend. There are numerous ways to ascertain direction using technical analysis, but the 200-period simple moving average (SMA) on the hourly charts may be particularly effective in this case. By using a longer-term average on the short-term charts, you can stay on the right side of the price action without being subject to near-term whipsaw moves.
Let’s take a look at two trades – one a short and the other a long – to see how this setup is traded in real time.
Curtis Miller’s Personal Website
Curtis Miller’s personal website, with resume, portfolio, blog, etc.
Subscribe Via RSS
Jobs for R Users
Jobs for Python Users
Around September of 2020 I wrote two articles on using Python for accessing, visualizing, and evaluating trading strategies (see part 1 and part 2). These have been my most popular posts, up until I published my article on learning programming languages (featuring my dad’s story as a programmer), and has been translated into both Russian (which used to be on backtest.ru at a link that now appears to no longer work) and Chinese (here and here). R has excellent packages for analyzing stock data, so I feel there should be a “translation” of the post for using R for stock data analysis.
This post is the first in a two-part series on stock data analysis using R, based on a lecture I gave on the subject for MATH 3900 (Data Science) at the University of Utah. In these posts, I will discuss basics such as obtaining the data from Yahoo! Finance using pandas, visualizing stock data, moving averages, developing a moving-average crossover strategy, backtesting, and benchmarking. The final post will include practice problems. This first post discusses topics up to introducing moving averages.
NOTE: The information in this post is of a general nature containing information and opinions from the author’s perspective. None of the content of this post should be considered financial advice. Furthermore, any code written here is provided without any form of guarantee. Individuals who choose to use it do so at their own risk.
Advanced mathematics and statistics have been present in finance for some time. Prior to the 1980s, banking and finance were well-known for being “boring”; investment banking was distinct from commercial banking and the primary role of the industry was handling “simple” (at least in comparison to today) financial instruments, such as loans. Deregulation under the Regan administration, coupled with an influx of mathematical talent, transformed the industry from the “boring” business of banking to what it is today, and since then, finance has joined the other sciences as a motivation for mathematical research and advancement. For example one of the biggest recent achievements of mathematics was the derivation of the Black-Scholes formula, which facilitated the pricing of stock options (a contract giving the holder the right to purchase or sell a stock at a particular price to the issuer of the option). That said, bad statistical models, including the Black-Scholes formula, hold part of the blame for the 2008 financial crisis.
In recent years, computer science has joined advanced mathematics in revolutionizing finance and trading, the practice of buying and selling of financial assets for the purpose of making a profit. In recent years, trading has become dominated by computers; algorithms are responsible for making rapid split-second trading decisions faster than humans could make (so rapidly, the speed at which light travels is a limitation when designing systems). Additionally, machine learning and data mining techniques are growing in popularity in the financial sector, and likely will continue to do so. In fact, a large part of algorithmic trading is high-frequency trading (HFT). While algorithms may outperform humans, the technology is still new and playing an increasing role in a famously turbulent, high-stakes arena. HFT was responsible for phenomena such as the 2020 flash crash and a 2020 flash crash prompted by a hacked Associated Press tweet about an attack on the White House.
My articles, however, will not be about how to crash the stock market with bad mathematical models or trading algorithms. Instead, I intend to provide you with basic tools for handling and analyzing stock market data with R. We will be using stock data as a first exposure to time series data, which is data considered dependent on the time it was observed (other examples of time series include temperature data, demand for energy on a power grid, Internet server load, and many, many others). I will also discuss moving averages, how to construct trading strategies using moving averages, how to formulate exit strategies upon entering a position, and how to evaluate a strategy with backtesting.
DISCLAIMER: THIS IS NOT FINANCIAL ADVICE. Furthermore, I have ZERO experience as a trader (a lot of this knowledge comes from a one-semester course on stock trading I took at Salt Lake Community College)! This is purely introductory knowledge, not enough to make a living trading stocks. People can and do lose money trading stocks, and you do so at your own risk!
Getting and Visualizing Stock Data
Getting Data from Yahoo! Finance with quantmod
Before we analyze stock data, we need to get it into some workable format. Stock data can be obtained from Yahoo! Finance, Google Finance, or a number of other sources, and the quantmod package provides easy access to Yahoo! Finance and Google Finance data, along with other sources. In fact, quantmod provides a number of useful features for financial modelling, and we will be seeing those features throughout these articles. In this lecture, we will get our data from Yahoo! Finance.
Let’s briefly discuss this. getSymbols() created in the global environment an object called AAPL (named automatically after the ticker symbol of the security retrieved) that is of the xts class (which is also a zoo -class object). xts objects (provided in the xts package) are seen as improved versions of the ts object for storing time series data. They allow for time-based indexing and provide custom attributes, along with allowing multiple (presumably related) time series with the same time index to be stored in the same object. (Here is a vignette describing xts objects.) The different series are the columns of the object, with the name of the associated security (here, AAPL) being prefixed to the corresponding series.
Yahoo! Finance provides six series with each security. Open is the price of the stock at the beginning of the trading day (it need not be the closing price of the previous trading day), high is the highest price of the stock on that trading day, low the lowest price of the stock on that trading day, and close the price of the stock at closing time. Volume indicates how many stocks were traded. Adjusted close (abreviated as “adjusted” by getSymbols() ) is the closing price of the stock that adjusts the price of the stock for corporate actions. While stock prices are considered to be set mostly by traders, stock splits (when the company makes each extant stock worth two and halves the price) and dividends (payout of company profits per share) also affect the price of a stock and should be accounted for.
Visualizing Stock Data
Now that we have stock data we would like to visualize it. I first use base R plotting to visualize the series.
A linechart is fine, but there are at least four variables involved for each date (open, high, low, and close), and we would like to have some visual way to see all four variables that does not require plotting four separate lines. Financial data is often plotted with a Japanese candlestick plot, so named because it was first created by 18th century Japanese rice traders. Use the function candleChart() from quantmod to create such a chart.
With a candlestick chart, a black candlestick indicates a day where the closing price was higher than the open (a gain), while a red candlestick indicates a day where the open was higher than the close (a loss). The wicks indicate the high and the low, and the body the open and close (hue is used to determine which end of the body is the open and which the close). Candlestick charts are popular in finance and some strategies in technical analysis use them to make trading decisions, depending on the shape, color, and position of the candles. I will not cover such strategies today.
(Notice that the volume is tracked as a bar chart on the lower pane as well, with the same colors as the corresponding candlesticks. Some traders like to see how many shares are being traded; this can be important in trading.)
We may wish to plot multiple financial instruments together; we may want to compare stocks, compare them to the market, or look at other securities such as exchange-traded funds (ETFs). Later, we will also want to see how to plot a financial instrument against some indicator, like a moving average. For this you would rather use a line chart than a candlestick chart. (How would you plot multiple candlestick charts on top of one another without cluttering the chart?)
Below, I get stock data for some other tech companies and plot their adjusted close together.
What’s wrong with this chart? While absolute price is important (pricey stocks are difficult to purchase, which affects not only their volatility but your ability to trade that stock), when trading, we are more concerned about the relative change of an asset rather than its absolute price. Google’s stocks are much more expensive than Apple’s or Microsoft’s, and this difference makes Apple’s and Microsoft’s stocks appear much less volatile than they truly are (that is, their price appears to not deviate much).
One solution would be to use two different scales when plotting the data; one scale will be used by Apple and Microsoft stocks, and the other by Google.
Not only is this solution difficult to implement well, it is seen as a bad visualization method; it can lead to confusion and misinterpretation, and cannot be read easily.
A “better” solution, though, would be to plot the information we actually want: the stock’s returns. This involves transforming the data into something more useful for our purposes. There are multiple transformations we could apply.
One transformation would be to consider the stock’s return since the beginning of the period of interest. In other words, we plot:
This will require transforming the data in the stocks object, which I do next.
This is a much more useful plot. We can now see how profitable each stock was since the beginning of the period. Furthermore, we see that these stocks are highly correlated; they generally move in the same direction, a fact that was difficult to see in the other charts.
Alternatively, we could plot the change of each stock per day. One way to do so would be to plot the percentage increase of a stock when comparing day to day , with the formula:
But change could be thought of differently as:
These formulas are not the same and can lead to differing conclusions, but there is another way to model the growth of a stock: with log differences.
(Here, is the natural log, and our definition does not depend as strongly on whether we use or .) The advantage of using log differences is that this difference can be interpreted as the percentage change in a stock but does not depend on the denominator of a fraction.
We can obtain and plot the log differences of the data in stocks as follows:
Which transformation do you prefer? Looking at returns since the beginning of the period make the overall trend of the securities in question much more apparent. Changes between days, though, are what more advanced methods actually consider when modelling the behavior of a stock. so they should not be ignored.
Charts are very useful. In fact, some traders base their strategies almost entirely off charts (these are the “technicians”, since trading strategies based off finding patterns in charts is a part of the trading doctrine known as technical analysis). Let’s now consider how we can find trends in stocks.
A -day moving average is, for a series and a point in time , the average of the past days: that is, if denotes a moving average process, then:
Moving averages smooth a series and helps identify trends. The larger is, the less responsive a moving average process is to short-term fluctuations in the series . The idea is that moving average processes help identify trends from “noise”. Fast moving averages have smaller and more closely follow the stock, while slow moving averages have larger , resulting in them responding less to the fluctuations of the stock and being more stable.
quantmod allows for easily adding moving averages to charts, via the addSMA() function.
Notice how late the rolling average begins. It cannot be computed until 20 days have passed. This limitation becomes more severe for longer moving averages. Because I would like to be able to compute 200-day moving averages, I’m going to extend out how much AAPL data we have. That said, we will still largely focus on 2020.
You will notice that a moving average is much smoother than the actual stock data. Additionally, it’s a stubborn indicator; a stock needs to be above or below the moving average line in order for the line to change direction. Thus, crossing a moving average signals a possible change in trend, and should draw attention.
Traders are usually interested in multiple moving averages, such as the 20-day, 50-day, and 200-day moving averages. It’s easy to examine multiple moving averages at once.
The 20-day moving average is the most sensitive to local changes, and the 200-day moving average the least. Here, the 200-day moving average indicates an overall bearish trend: the stock is trending downward over time. The 20-day moving average is at times bearish and at other times bullish, where a positive swing is expected. You can also see that the crossing of moving average lines indicate changes in trend. These crossings are what we can use as trading signals, or indications that a financial security is changing direction and a profitable trade might be made.
Visit next week to read about how to design and test a trading strategy using moving averages.
Update: There were some errors in the original code, which were created when I posted this document to WordPress. They should be fixed now.
Best Choice For Beginners!
Free Trading Education!
Free Demo Account!
Big Sign-up Bonus!
Perfect For Experienced Traders!