Detecting Support and Resistance Levels

Support & Resistance levels are essential for every trader. The define the decision points of the markets. If you are long and the market falls below the previous support level, you most probably have got the wrong position and better exit.

The detection of support and resistance levels is usually highly subjective and based on the analysts experience. In this article I will use a simple algorithm to detect the levels and show them on the chart.

The first and second deviation of a curve

If you remember your high school math class you have heard about the first and second deviation of a curve and how to use it to find the turning points and extremes of a curve,

The deviation of a curve is nothing else than the momentum of a curve. It defines the slope of the curve. If the slope of a curve is zero, you have found a local extreme. The curve will change from rising to falling or the other way round.

The second deviation, or the momentum of momentum, shows you the turning points of the first deviation. This is important, as at this point the original curve will switch from acceleration to break mode.

But don’t worry about the theory behind the indicator, see the chart below to get the idea.

First the market data is smoothed.

Second the momentum of the market is calculated. Third the momentum of the momentum is calculated.

If the second momentum crosses above zero, the first momentum will have local low and the market will be in a state when the trend comes to an end.

Support and Resistance explanation

Algorithmic turning points

Using the logic laid out above the support&resistance indicator will show the turning points of the market in a timely manner.

Depending on level of market-smoothing it will show the long term or short term turning points.

support and resistance

If you are a trend follower you might only be interested in support levels. Therefore I added the possibility to use the Wells-Wilder Directional Movement Index as a trend filter.

support and resistance DMI filter

Tradesignal indicator code

I used the Tradesignal software suite to program this indicator. The code used is shown below.

It first calculates the first and second deviation of the smoothed market, and in a second step runs the turning point detection.

Tradesignal indicator code

Analysis done using the Tradesignal software suite and data from Refinitiv. Thanks!

Overnight Risk Premium in Equity and Commodity Markets

Over the last 20 years equity markets and ETFs did a significant part of their total performance over night. This article will examine the relationship of in-session moves vs. the out-of-session moves of ETFs and commodities.

The overnight risk premium

As an investor you can expect to get paid for taking risk. If someone sell its stock to you he gets the risk free return for holding cash,  but you will have to finance the risk of the stock moving against you. This risk is quite low when the market is open and liquid, as you could always sell the stock in case of an adverse movement. But when markets are closed you have to bear a higher risk as you will be bound to your position until the markets opens on the following day.

According to this theory the market returns over night should be positive, to compensate you for the higher risk of holding a position you can’t liquidate immediately. Let’s see if there is some truth in this theory and how big the overnight risk premium might be.

Test code and data

To test the theory I took daily market data from Refinitiv and used the Tradesignal code below to sum up the percent values of daily and overnight moves.

Tradesignal overnight performance test code

Tradesignal overnight performance test code

ETFs overnight risk premium

The chart below shows the outcome of the calculation for the QQQ ETF.  As it can be seen, the good performance over the last years has happened mostly when markets where closed. Even during the financial crisis the overnight returns have mostly been positive.

QQQ overnight risk premium

QQQ overnight risk premium

 

Having a look at the distribution of returns you see quite a different behaviour on e.g. a rolling sum of 10 day or night moves. The daily open to close returns show a higher tendency for big moves than the overnight move. So from a risk perspective the day session bears more risk than the night session.

QQQ overnight returns distribution

QQQ overnight returns distribution

 

QQQ is not the only ETF showing this excess overnight performance. The overview below gives you the data. The numbers show the sum of percent moves since 2001. (starting at 100)

SPY ETFs overnight performance analysis

SPY ETFs overnight performance analysis

A look at commodities

With futures and commodities this overnight effect is not as prolonged as with equities. Sometimes it even is non existent at all.

The chart below shows the overnight and daytime performance of the German Bund future. Beside the phase from 2015 to 2017 the overnight movement did not add to the total performance.

Bund Future FGBL overnight risk premium

Bund Future FGBL overnight risk premium

 

The december future on emission certificates (chart below) shows no significant overnight movement at all.

CFI2 Emissions overnight performance

CFI2 Emissions overnight performance

German power, yearly contract, shows a strong negative overnight performance.

F1BY overnight performance

F1BY overnight performance

Implications for trading

As the overnight move has got a significant impact on the total performance of equity markets, it will also have implications on the design of a trading strategy. A first implication of this overnight effect might be that you should not be short over night in equity markets, and you might not want to open your long position at the beginning of the day.  But keep in mind, if everyone knows the trick, this overnight movement will have implications for the first and last hour of trading. This will be a topic for another article…

 

Profit from large daily moves

Whenever the market shows an exceptional day ranges it is time to take bite. See how you can profit from large daily market moves.

Open-Close Range

When looking at any chart, you will surely notice that the large candles tend to close near the high or low. This is due to herding. Once the market is moving significantly, everyone hops on and the large move becomes even larger. This is true for daily, weekly and intraday candles.

The chart shows an indicator which plots the daily move. Every opening is set to zero and the absolute move of the day is drawn. Around these normalised candles a long term 2 standard deviation volatility band is drawn.  Right now the 2 standard deviation volatility for SPX is about +/- 46 points.

Take a bite before the market closes

As you can see this +/-46 point barrier above/below the opening of the day is a wonderful entry point. If you enter long 46 points above the opening and go short 46 points below the opening nearly all entries would have lead to a profitable trade. To get an even higher probability of success you can volume as a confirmation. Large moves must also show high volume. The exit is done at the end of the session. This analysis does not give any indication for the next days move. So be fast, take your bite and go home with a small profit and no overnight position.

No free lunch

On the chart it looks easy, but be careful. As an example the last bar shown on the chart first crossed the band to the downside, reversed and crossed above the upper band. So you will need to use a trailing stop to lock in profits and avoid to take the full -46 to +46 points trade as a loss!

 

 

 

 

Python Regression Analysis: Drivers of German Power Prices

German Power prices can be explained by supply and demand, but also by causal correlations to underlying energy future prices. A properly weighted basket of gas, coal and emissions should therefore be able to resemble the moves of the power price.  This article will introduce multivariate regression analysis to calculate the influence of the underlying markets on a given benchmark. It is an example of  a machine learning algorithm used in analysis and trading.

Multivariate regression analysis

Continue reading

RSI Hellfire Heatmap Indicator

Chart analysis is all about visualizing data. The RSI hellfire indicator uses a heat-map to visualizes how overbought or oversold the market is on a broad scale. This helps to get a broad picture of the current market setup.

Multiple Time-frame Relative Strength Index

Wells Wilder’s RSI is an old timer of technical indicators. It tries to find out if markets are overbought or oversold. Usually it is calculated using a 14 bar setting. But a 14 bars RSI on a daily chart will give a different reading than 14 bars on an hourly or weekly chart. As it is always nice to see what traders on a different time-frame see on their charts, you could simply display several RSI settings on your chart. Continue reading

The Edge of an Entry Signal

When developing a new trading strategy you are usually confronted with multiple tasks: Design the entry, design the exit and design position sizing and overall risk control. This article is about how you can test the edge of your entry signal before thinking about your exit strategy. The results of these tests will guide you to the perfect exit for the tested entry signal (entry-exit combination)

Quality of an Entry Signal

When you develop a new idea for an entry signal there are two things you would like to see after the entry: no risk and fast profits. This would be the perfect entry with the highest possible edge. In reality the market response to your entry will be risk and chance. With a good entry the upside would outnumber the downside. Continue reading

A simple algorithm to detect complex chart patterns

Finding complex chart patterns has never been an easy task. This article will give you a simple algorithm and a ready to use indicator for complex chart pattern recognition. You will have the freedom to detect any pattern with any pattern length. It has been described as Fréchet distance in literature. This article shows a simple adaptation for chart pattern analysis.

Defining a chart pattern

Continue reading

The Edge of Technical Indicators

Classical technical indicators like RSI and Stochastic are commonly used to build algorithmic trading strategies.  But do these indicators really give you an edge in your market? Are they able to define the times when you want to be invested? This article will show you a way to quantify and compare the edge of technical indicators. Knowing the edge of the indicator makes it an easy task to select the right indicator for your market.

The edge of an indicator

Any technical indicator, let it be RSI, moving averages or jobless claims, has got a primary goal. It should signal if it is a wise idea to be invested or not. If this indicator signal has any value, on the next day the market should have a higher return than it has on average. Otherwise  the usage of no indicator and a buy and hold investing approach would be the best solution.

The edge of an indicator in investing consists of two legs.

  1. the quality of the signal
  2. the number of occurrences

Continue reading

Noisy Data strategy testing

Adding some random noise to historic market data can be a great way to test the stability of your trading strategy. A stable strategy will show similar profits with noisy and original data. If the noise has a great impact on your results, the strategy might be over fitted to the actual historic data.

Synthetic market data?

Generating completely synthetic market data to test algorithmic trading strategies is a dangerous endeavour.  You easily lose significant properties like classic chart patterns or the trend properties of your market. Continue reading

Monte Carlo Simulation of strategy returns

Monte Carlo Simulation uses the historic returns of your trading strategy to generate scenarios for future strategy returns. It provides a visual approach to volatility and can overcome limitations of other statistical methods.

Monte Carlo Simulation

Monte Carlo is the synonymous for a random process like the numbers picked by a roulette wheel. Continue reading

Overnight vs Daytime Performance & Volatility

Analysing the market performance of the day session vs. the overnight movement reveals some interesting facts.

Daytime vs. Overnight Performance

The chart below gives a visual impression on where the performance of the SPY ETF is coming from.

The grey line represents a simple buy and hold approach. The green line shows the performance if you would have held SPY only during daytime, closing out in the evening and re-opening the position in the morning. Continue reading

Bullish? Buy stock or sell put option?

So you are bullish on a specific stock, but you also have realised that timing is major problem? So what would be the best strategy to implement your bullish opinion but avoid the problems of any timing strategy?

Selling a put option might be the answer.

Bullish probability

For discussing this question let’s use the current Apple chart as an example. The question is, if you are bullish on apple, should you buy 100 Apple stocks right away or should you sell an at-the-money put option. To find the pros and cons of these two possibilities let’s have a look at some charts. Continue reading

Technical vs. Quantitative Analysis

“The stock market is never obvious. It is designed to fool most of the people, most of the time” Jesse Livermore

Technical Analysis

Technical analysis is a form of market analysis based on historic price patterns. The basic assumption of technical analysis is, that human behaviour does not change over time, and thus similar historic market behaviour will lead to similar future behaviour. Technical analysis is a predictive form of analysis, a technical analyst will try to estimate what the market might most probably do over the next period of time. Continue reading

Market crash or market correction?

Over the last days and weeks some traders have been worried if the currently ongoing correction in the markets will evolve into a crash, or if it is just a normal correction.

Crash or correction

The main difference between a correction and a crash is the panic level. But it is not the absolute level of .VIX, the CBOE implied volatility meter. It is the difference between realized and implied volatility that defines a crash which defines real panic. Continue reading

Bollingerband: The search for volatility

Usually it makes no sense to fight against normal distribution. But there are setups which have got a high probability of unexpected behaviour.  Volatility can be the key to future market movements.

Bollinger bands width percentile

Bollinger Bands are a great tool to describe market volatility. And my favourite tool to measure the width of Bollinger Bands is Bollinger percentile.

Like the IV percentile indicator my Bollinger percentile indicator is a probabilistic indicator. It gives the probability of Bollinger Bands having a narrower upper band – lower band range than currently given. Continue reading

Weis Wave indicator code for Tradesignal

The Weis Wave indicator combines trend and volume information. It seems to be of some interest for timing short term market reversals. Here comes a version of this indicator for usage in Tradesignal.

The Weis Wave indicator for Tradesignal

The basic idea of the Weis Wave indicator is to sum up the traded volume, as long as the market moves in the same direction. The bullish volume wave is displayed in green. As soon as the market changes direction, a red wave is constructed. by comparing the magnitude of the Weis wave with the magnitude of the market move, valuable insights for short term market timing can be found.

More information can be found via a web search or from the page I got the idea form: https://weisonwyckoff.com/weis-wave/ Continue reading

Tradesignal Implied Volatility and IV Percentile Scanner

Implied volatility data is key in options trading. This article shows how to access free volatility data in the Tradesignal software suite.

Implied Volatility and IV Percentile

Thanks to https://www.optionstrategist.com/calculators/free-volatility-data  implied volatility and IV percentile data is available. For free on a weekly basis. Using this data and the given code the data can be loaded into Tradesignal. This enables you to do your custom market scans, combining Tradesignal technical analysis and the implied volatility data from the optionstrategist website.

Free implied volatility data

The first step to use the optionstrategist data would be to safe it into a text file. Just copy and paste the data, no additional formatting is required. The free data on the website is updated every Continue reading

IV Percentile – when to sell volatility

Volatility trading: when to buy and when to sell volatility

You got to know when to hold ’em,
Know when to fold ’em,
Know when to walk away,
And know when to run.
(Kenny Rogers)

When to sell implied volatility

Volatility is a nicely reverting time series. If it is high chances are good that it will come down again. The only problem is to find out when volatility is high, and when it is low. Unfortunately there are no absolute levels, you can’t say that 50% implied volatility is high, as this specific stock might have an implied volatility of 80% most of the time. So you can only compare the current volatility level to historic levels and so define if volatility is currently high or low. Continue reading

The Hindenburg Omen – Stock Market Crash Ahead?

The Hindenburg Omen is an indicator which is believed to forecast market crashes. Unfortunately it does not work, but the idea behind this indicator is worth to be discussed.

Market Breadth – Hindenburg Omen

The Hindenburg Omen is a market breadth indicator. It describes how correlated stocks are within a market behave.

I already had a market breadth indicator in this blog a long time ago, the percentage of stocks within a market above the 200 day average. The Hindenburg Omen does not use moving averages, it is based on the number of new highs and lows in the market.

Hindenburg Omen: idea and calculation

To get a warning signal for an upcoming stock market crash the Hindenburg Omen indicator observes the number of stocks making new 54 week highs and the number of stocks making 54 week lows. In a strong bull market you will usually see a lot of new highs but hardly any new lows, in a bear market you will see new lows, but no new highs. Continue reading