Strategy vault / Mean reversion
Internal Bar Strength Indicator Reversion system
It looks like you're using Pine Script to set up a trading strategy with conditions based on the Internal Bar Strength (IBS) indicator. To explain the code: 1. Strategy Settings: The strategy defined here is named…
It looks like you're using Pine Script to set up a trading strategy with conditions based on the Internal Bar Strength (IBS) indicator.
To explain the code:
Strategy Settings: The strategy defined here is named "IBS", it has an initial capital of $10,000, no overlay, allows up to 5 entries in the same direction, and each trade consists of a quantity of 100 units.
Calculation of IBS: The script calculates the IBS as a percentage of the current bar's range that's made up by the difference between the close and the low. Notice that the indicator ranges between 0 and 100%.
Long Entry conditions: It enters a long trade when the IBS falls below 5.
Short Entry conditions: It enters a short trade when the IBS rises above 99.
Exit conditions: The trading strategy then exits either position after either a profit of 10% or a loss of 2%.
They have also included commented out codes (with '//') for direction.allowed for strategy risk and another shortCondition.
Note: This script indicates a mean reversion strategy. It assumes that the price will return to its mean and trades based on this assumption. However, please spend enough time testing this strategy to make sure it works well with your specific use case.
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-07 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
// strategy("IBS", initial_capital=10000, overlay=false, pyramiding=5, default_qty_value=100, currency="USD")
//strategy.risk.allow_entry_in(strategy.direction.long)
src = close
ibs = (close - low) / (high - low) * 100
longCondition = ibs <5
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
//shortCondition = close > high[1]
shortCondition = ibs > 99
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
p = close * 0.01 * 10
strategy.exit("exit", "My Long Entry Id",profit = 10, loss=2)
strategy.exit("exit", "My Short Entry Id",profit = 10, loss=2)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-08. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Internal-Bar-Strength-Indicator-Reversion-system.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- A Trend Reversal Strategy Based on Moving Averages Price Patterns and VolumePine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Adaptive Moving Average Tracking StrategyPine Script · Mean reversion · 1d