Coins: 14,099
Exchanges: 1,077
Market Cap: $2.406T 2.4%
24h Vol: $72.811B
Gas: 5 GWEI
Go Ad-free
Trading
TABLE OF CONTENTS

Internal Bar Strength (IBS) and the Adjusted Failed Bounce Strategy

5.0 | by Jackson Henning

The Internal Bar Strength (IBS) Indicator

The Internal Bar Strength (IBS) indicator is useful for short-term mean-reverting strategies. Measuring the relative position of a period’s closing price to the same period’s high and low, the IBS can be interpreted to predict a bullish signal when displaying a low value and a bearish signal when presenting a high value.  


Key Takeaways

  • The Internal Bar Strength indicator assumes that the market is mean-reverting, and is useful for short-term trading strategies. 

  • A low IBS creates a bullish signal and a high IBS a bearish one.

  • The IBS can be utilized in a number of unique trading strategies, with some producing appealing backtesting results. 


What is the Internal Bar Strength Indicator

The ceaseless alternation of legal maneuvers and regulatory challenges that characterizes the battle between the SEC and Ripple reached a momentary pause this past week. Thursday’s court ruling by Judge Analisa Torres indicated that almost all XRP sales did not constitute security transactions. Widespread positivity rang across the industry, with exchanges like Coinbase relisting XRP and many hoping this marked the unraveling of the war waged on crypto. This news galvanized many into investing, with XRP rising 63.1% over the past 7 days, causing a bullish sentiment to disseminate over many other coins in the space. Prior to this news, crypto was — and some argue still is — in the midst of a bearish winter. Many coins during this time exhibited mean-reverting tendencies, and to capitalize on this one can employ the Internal Bar Strength (IBS) indicator.

Understanding the Indicator

The Internal Bar Strength (IBS) indicator is useful in short-term mean-reverting strategies (mean reverting strategies assume that an asset’s price will eventually revert to its long-term mean or average price level). The indicator oscillates between zero and one, measuring the relative position of a period’s closing price to the same period’s high and low. Under the assumption that the market is mean-reverting, a low IBS acts as a bullish signal and a high value acts as a bearish signal. The core tenets of the IBS indicator are to buy on weakness and sell on strength — at least in the short-term. Emphasizing the short-term mean-reverting nature of this strategy serves to highlight that the markets are inundated with people and advanced computing power, meaning while the IBS has proven fruitful, most popular indicators are now ‘arbed’ away as they are widely used. Therefore, the majority of this article will pertain to a strategy that employs the IBS indicator in a unique manner. 

Calculating and Implementing the Internal Bar Strength (IBS) Indicator

The IBS indicator is simplistic in its interpretation, calculation, and implementation. While it is unavailable on GeckoTerminal as a preset, it is relatively easy to determine. Displaying the price action of a desired token on GeckoTerminal, like WETH/USDC on Uniswap, will help elucidate how the IBS is constructed. Once an asset, like WETH/USDC, is selected, one merely needs to pick a timeframe, for example ‘daily’, as shown below:

OHLC daily data

Calculating the indicator requires the OHLC data of the underlying asset. In the case of WETH, the previous day (15/07/2023) opened at $1,935.92, achieving a high and low of $1,940.55 and $1,932.18, respectively, before closing at $1,933.77. Using our example, we would calculate the IBS through the following formula:

IBS = (Close-Low)/(High-Low)

IBS = (1933.77-1932.18)/(1940.55-1932.18)

IBS = 1.59/ 8.37

IBS = 0.1897

This indicator is simple, but very intuitive. The nearer the close price to today's low, the smaller the IBS value. The nearer the close price to today's high, the bigger the IBS value. This suggests a buy signal is generated when the value is low, normally considered below 0.2, and an exit signal occurs when the IBS is high, normally above 0.8. 

Adjusted Failed Bounce Strategy

Returning to the strategy mentioned earlier, an amended version of Rob Hanna’s Failed Bounce Strategy illuminates the functionality of the IBS indicator. The strategy focuses on instances where the price action is declining, as indicated by the bearish sentiment of the IBS (>0.6), but there are still brief recoveries in the price (hence failed bounce) — essentially, a dead cat bounce. This long strategy is founded on the following four parameters:

  1. The IBS yesterday was at least 0.6 or higher.

  2. The low yesterday was lower than the lowest low during the five days before.

  3. The close today is lower than yesterday’s close.

  4. Exit when the close is higher than the highest high during the five days before.

This will be coded in python, hence one can utilize pandas, which is useful for data manipulation and analysis, numpy, which is handy when dealing with arrays, and matplotlib.pyplot, which will be used to visualize our findings.

Import data

Fetching Historical Data

The CoinGecko API provides comprehensive RESTful JSON endpoints to extract data from. Illustrated below is how to pull the OHLC ETH/USD data for the past 30 days and reorganize that data into a pandas dataframe. Given the granularity of the CoinGecko historical data, the API affords 4-hour intervals of OHLC data for 30-day periods. I will refer to these periods as “today” and “yesterday”, as these merely constitute the present and previous period — to avoid repeatedly writing “previous period” and “present period,” which is far more confusing. 

Fetch historical data

Applying Strategy

For code reusability, one can develop a StrategyAnalyzer class. The _init_ method is automatically called when an object — an instance — of this class is created. In the below code, the _init_ method initializes the object of the StrategyAnalyzer class by assigning the previously constructed dataframe, df, to the self.df attribute. Therefore, the dataframe can be accessed by other methods within the class, allowing for the data to be reused efficiently.Apply strategyThe previously mentioned IBS equation will help in constructing the next method. The only input parameter of the IBS method below is self, as it calls upon the aforementioned initializer to utilize the dataframe. Then the method uses the same formula as before to determine the IBS at each instance of the OHLC data provided for the past 30 days. determine ibsAfter developing the indicator, one can employ the previously laid out trading rules in the manner shown below. To reiterate, the signal starts at 0, indicating neither a long nor short signal, and only changes once the previous IBS value is above 0.6, yesterday’s low is lower than the lowest low of the previous 5 days, the close today is lower than yesterday's close, and the signal is not already 1 (a long signal). When a long signal (=1) is achieved, the corresponding next day open price is appended to the LongPrice list, while nothing is added to the ShortPrice list. The exit signal is indicated once today's close is higher than the highest high of the previous 5 days and the signal is currently 1 (meaning a trader is in a long position). Then the corresponding ShortPrice will be appended to the ShortPrice list. If neither condition is true no price will be appended to the LongPrice or ShortPrice list. Lastly, the signal value will be returned to 0 after a short signal is indicated. 

Long and short signals

In order to visualize these lists, the below code appends three new series to the existing dataframe, allowing for simplified code readability. 

Long and short signals readability

Visualizing Signals

Conceptualizing these signals and the equity curve of the strategy can be done through exercising the code below. The returns of this strategy are determined by taking the product of the percentage change in the close price and the shifted value of the ‘Signal’ series (1 for long signals, -1 for short signals, and 0 for no signal). By applying the shift(1) pandas function, the values of the ‘Signal’ column are shifted one position forward, allowing the index value at position ‘i’  to correspond to the signal that was generated at the index position ‘i-1.’ This permits the trading signal to correspond with its appropriate returns. Meaning, it allows the returns to be based on the previous signal, which reflects the action taken in that period to generate those returns. The rest of the code simply uses matplotlib.pyplot to display the trade signals and the equity curve.  Plot signals

Evaluating Strategy

To properly scrutinize a strategy, many traders look at the maximum drawdown and the maximum drawdown duration. The maximum drawdown (MDD) is the difference between the local maximum and local minimum of the equity curve, following the occurrence of the local maximum; it is the greatest observed loss between a peak and trough of the equity curve over a time period. The maximum drawdown duration is the longest it has taken for the equity curve to recover losses

Drawdowns are useful to determine one’s risk tolerance. Specifically, drawdowns increase the chance of behavioral mistakes. In the event a drawdown occurs, a traders risk tolerance will determine if they are faithful to their strategy. Hence the importance in determining the max drawdown (MDD) and the max drawdown duration. The extent to which a trader is willing to squirm without abandoning faith in their strategy can depend on their willingness to endure a drawdown.  

The ‘for loop’ in the code below checks if the drawdown at the current index is equal to 0, indicating the end of a drawdown period. If the duration is greater than 0 — meaning it has already been tracking a downward period — the code appends the duration to the durations list. If the drawdown at the current index is not 0, duration is incremented by 1, suggesting the continuation of an existing drawdown period.

Max drawdown duration

Displaying the results of the strategy is largely founded upon the previously written code. As demonstrated below, if a buy signal is indicated (=1) the corresponding open price is recorded. Similarly, if a sell signal has been generated the commensurate closing price is recorded. The difference between the two prices equates to profit, and the number of wins is determined by the number of times their difference is positive, and losses by the number of times it’s negative. All of this is then printed out, including the more comprehensive statistics of the MDD, MDD duration, Sharpe Ratio, and Avg. Trade (the profit/loss generated per trade).

strategy results ibs

Results

Following the creation of all these functions, an instance of the class is created and the methods are called.

create instance and call methods

The equity curve can also be referred to as the cumulative profit and loss curve, assuming there has been no cash infusion. Therefore, the equity curve below shows the profit a trader would have gained had they invested $1 in ETH using this strategy over the past 30 days. Any peak to trough of the curve below is a drawdown, with the max drawdown occurring in between the 2023-07-03 and 2023-07-07 date ticks. Coincidentally, the MDD duration is also at the same timeframe, from 2023-07-05 at 08:00:00 UTC  to 2023-07-06 at 12:00:00 UTC. Most would assume the MDD duration is the length of time during which the MDD occurs, but this is not always true. The MDD duration is the longest time between peaks — the longest time it takes for the equity curve to recover; therefore, it is not guaranteed to occur when the MDD does, as in this case.

Equity curveThe long signals are illustrated by the green arrows on the price action below and the sell signals are demonstrated by the red arrows. This graph helps clarify the intention of the Failed Bounce Strategy. For example, the second and third buy signals occur right after the price action hits a support level, suggesting the price will ‘bounce’ upwards—as it does momentarily— triggering a sell signal, but the overall movement of the price action during that period of time is still bearish (i.e. from 2023-06-23 to 2023-06-29).

long short signals

Lastly, the figures below demonstrate the performance of this strategy. If one were to have traded a single ETH for the past 30 days when employing this strategy, they would have obtained a profit of $88.73 USD, over 12 trades, resulting in a win rate of 83.33%. The average trade would have returned $7.39 USD. A Sharpe Ratio that high is very encouraging, but may be a cause of ‘overfitting’ the equity curve or data-snooping complications. The max drawdown is 1.66%, as shown by the equity curve above, which, again, shows the return had one invested $1. The corresponding MDD duration, which overlapped the MDD, was 8 periods or 32 hours. 

adjusted failed bounce strategy results

This “Adjusted Failed Bounce Strategy” provided interesting backtesting results for ETH over the past 30 days. While seeming profitable, independently backtesting this strategy will help traders determine its profitability given different parameters and individual circumstances. This strategy accentuates the performance of the IBS in short-term mean-reverting time periods. 

All information and examples in this article are provided for informational purposes only, and should not be taken as financial advice. 


Find Out More About the CoinGecko API

Traders who are interested in replicating the above backtesting results can check out the CoinGecko Analyst API plan. The CoinGecko API currently has 50+ endpoints, tracks 10,000+ coins across 700+ exchanges and 3,000+ NFT collections serving billions of API calls each month.

If you are looking for a custom solution, you can fill up the form below to get in touch with our API sales team: 

CoinGecko's Content Editorial Guidelines
CoinGecko’s content aims to demystify the crypto industry. While certain posts you see may be sponsored, we strive to uphold the highest standards of editorial quality and integrity, and do not publish any content that has not been vetted by our editors.
Learn more
Tell us how much you like this article!
Vote count: 3
Jackson Henning
Jackson Henning

Jackson Henning has a background in economics and has spent 3 years in crypto, primarily ensconced in NFTs and DeFi. He is especially intrigued by the perpetual ingenuity common to crypto trading, along with the employment of technical analysis and the ability of DeFi to push the bounds of traditional finance. Follow the author on Twitter @Henninng

More Articles

coingecko
Continue in app
Track prices in real-time
Open App
Select Currency
Suggested Currencies
USD
US Dollar
IDR
Indonesian Rupiah
TWD
New Taiwan Dollar
EUR
Euro
KRW
South Korean Won
JPY
Japanese Yen
RUB
Russian Ruble
CNY
Chinese Yuan
Fiat Currencies
AED
United Arab Emirates Dirham
ARS
Argentine Peso
AUD
Australian Dollar
BDT
Bangladeshi Taka
BHD
Bahraini Dinar
BMD
Bermudian Dollar
BRL
Brazil Real
CAD
Canadian Dollar
CHF
Swiss Franc
CLP
Chilean Peso
CZK
Czech Koruna
DKK
Danish Krone
GBP
British Pound Sterling
GEL
Georgian Lari
HKD
Hong Kong Dollar
HUF
Hungarian Forint
ILS
Israeli New Shekel
INR
Indian Rupee
KWD
Kuwaiti Dinar
LKR
Sri Lankan Rupee
MMK
Burmese Kyat
MXN
Mexican Peso
MYR
Malaysian Ringgit
NGN
Nigerian Naira
NOK
Norwegian Krone
NZD
New Zealand Dollar
PHP
Philippine Peso
PKR
Pakistani Rupee
PLN
Polish Zloty
SAR
Saudi Riyal
SEK
Swedish Krona
SGD
Singapore Dollar
THB
Thai Baht
TRY
Turkish Lira
UAH
Ukrainian hryvnia
VEF
Venezuelan bolívar fuerte
VND
Vietnamese đồng
ZAR
South African Rand
XDR
IMF Special Drawing Rights
Cryptocurrencies
BTC
Bitcoin
ETH
Ether
LTC
Litecoin
BCH
Bitcoin Cash
BNB
Binance Coin
EOS
EOS
XRP
XRP
XLM
Lumens
LINK
Chainlink
DOT
Polkadot
YFI
Yearn.finance
Bitcoin Units
BITS
Bits
SATS
Satoshi
Commodities
XAG
Silver - Troy Ounce
XAU
Gold - Troy Ounce
Select Language
Popular Languages
EN
English
RU
Русский
DE
Deutsch
PL
język polski
ES
Español
VI
Tiếng việt
FR
Français
PT
Português
All Languages
AR
العربية
BG
български
CS
čeština
DA
dansk
EL
Ελληνικά
FI
suomen kieli
HE
עִבְרִית
HI
हिंदी
HR
hrvatski
HU
Magyar nyelv
ID
Bahasa Indonesia
IT
Italiano
JA
日本語
KO
한국어
LT
lietuvių kalba
NL
Nederlands
NO
norsk
RO
Limba română
SK
slovenský jazyk
SL
slovenski jezik
SV
Svenska
TH
ภาษาไทย
TR
Türkçe
UK
украї́нська мо́ва
ZH
简体中文
ZH-TW
繁體中文
Login to track your favorite coin easily 🚀
By continuing, you agree to CoinGecko Terms of Service and acknowledge you’ve read our Privacy Policy
or
Forgot your password?
Didn't receive confirmation instructions?
Resend confirmation instructions
IT'S FREE! Track your favorite coin easily with CoinGecko 🚀
By continuing, you agree to CoinGecko Terms of Service and acknowledge you’ve read our Privacy Policy
or
Password must contain at least 8 characters including 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character
Didn't receive confirmation instructions?
Resend confirmation instructions
Forgot your password?
You will receive an email with instructions on how to reset your password in a few minutes.
Resend confirmation instructions
You will receive an email with instructions for how to confirm your email address in a few minutes.
Get the CoinGecko app.
Scan this QR code to download the app now App QR Code Or check it out in the app stores