Strategy vault / Trend following
Inside Bar Failure Strategy
This strategy trades based on inside bar breakdowns. If the high/low of the bar following an inside bar penetrates the prior inside bar's range, trade signals are generated. The logic is: 1. Check if the prior 2 bars…
Strategy Logic
This strategy trades based on inside bar breakdowns. If the high/low of the bar following an inside bar penetrates the prior inside bar's range, trade signals are generated.
The logic is:
Check if the prior 2 bars formed an inside bar i.e. bar 2's high/low within bar 1's range
If bar 3 high exceeds bar 2 high, and closes above bar 2 low, go long
If bar 3 low breaks bar 2 low, and closes below bar 2 high, go short
Optionally close orders X bars later (e.g. 3 bars)
It aims to capture trends emerging from inside bar consolidations. Inside bars represent short-term balances, and breakdowns can kickstart new trends.
Advantages
Inside bars easy to identify, breakdowns give clear signals
Closing orders early avoids whipsaws
Simple and intuitive rules
Risks
Need to further validate signal effectiveness
Inside bar formation and breakdowns less common
Could trade against major trend
Summary
This strategy attempts to capitalize on trends from inside bar breakdowns. But the lower frequency of trading needs evaluation of risk-reward. Combining with other factors could improve performance.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 3 | Look Forward |
Source Pine Script
/*backtest
start: 2022-09-07 00:00:00
end: 2022-10-31 00:00:00
period: 4d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("Inside Bar Failure", overlay=true)
forward = input(defval=3, title="Look Forward")
longCondition = if (high[2] > high[1] and low[2] < low[1] and low < low[1] and high < high[1] and close > low[1])
x = true
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = if (high[2] > high[1] and low[2] < low[1] and high > high[1] and low > low[1] and close < high[1])
y = true
if (shortCondition)
strategy.entry("Short", strategy.short)
if (longCondition[forward])
strategy.close("Long")
if (shortCondition[forward])
strategy.close("Short")Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-14. 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/Inside-Bar-Failure-Strategy.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
- 200 EMA VWAP MFI Trend Following StrategyPine Script · Trend following · 1d
- 4 EMA Trend StrategyPine Script · Trend following · 1d
- ADX MA and EMA Long Only Trend Tracking StrategyPine Script · Trend following · 1d
- ATR Dynamic Profit Target and Stop Loss StrategyPine Script · Trend following · 1d
- ATR Dynamic Trend Following and EMA Crossover Trading StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h