What is The Internal Bar Strength Trading Strategy?
Coding and Back-testing the IBS Strategy in TradingView
Algorithmic trading strategies can also be simple. This article presents one and back-tests it in TradingView.
Introduction to the IBS
Technical indicators are tools used in technical analysis to analyze and predict future price movements in financial markets, such as stocks, commodities, or currencies. These indicators are based on mathematical calculations derived from historical price and volume data. Traders and analysts use these indicators to gain insights into market trends, identify potential entry or exit points, and make informed trading decisions.
The internal bar strength (IBS, very unfortunate name) is a very simple formula used in some algorithmic trading strategies. It follows this calculation:
On a chart, the IBS looks like a stationary indicator hovering between 0 and 1:
Obviously, the indicator is positively correlated to the price action (as can be understood from the formula and the chart). The aim now is to derive trading rules (entries and exits) to trade the S&P 500 index.
If you want to see more of my work, you can visit my website for the books catalogue by simply following this link:
Coding and Back-testing the Strategy
The rules for the IBS strategy (long-only) are as follows:
A bullish signal is generated whenever the IBS dips below 0.20.
The exit rule after the bullish signal is when the IBS surpasses 0.90.
The following shows the equity curve on daily bars (no transaction costs have been included as they are variable):
The average trade duration is around 9 days, making it a swing trading strategy.Â
The hit ratio is acceptable given a risk-reward ratio less than 2.00. The profit factor shows good profitability by being well above 1.0.Â
The number of trades may be optimized to reduce costs (when incorporated). However, the number of trades may suggest that this strategy will not outperform a simple passive strategy (buy-and-hold). But, optimization parameters may help with that.
The code used to generate the back-test is as follows:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
ibs = (close - low) / (high - low)
buy = input(defval = 0.2, title = 'Buying Level')
sell = input(defval = 0.8, title = 'Selling Target')
longCondition = ibs < buy and ibs[1] > buy
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
strategy.close('My Long Entry Id', when = ibs >= sell)
You can also check out my other newsletter The Weekly Market Sentiment Report that sends weekly directional views every weekend to highlight the important trading opportunities using a mix between sentiment analysis (COT report, put-call ratio, etc.) and rules-based technical analysis.
If you liked this article, do not hesitate to like and comment, to further the discussion!