0bps

Strategy vault / Breakout

High Low Breakout Trend Following Strategy

This strategy is named "High-Low Breakout Trend Following Strategy". It identifies new price highs and lows to determine trend direction, and trades breakouts of latest high/low points to follow trends. The specific…

Author
ChaoZhang
Complexity
Starter · 43 lines
Parameters
4
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

This strategy is named "High-Low Breakout Trend Following Strategy". It identifies new price highs and lows to determine trend direction, and trades breakouts of latest high/low points to follow trends.

The specific logic is:

  1. Calculate the highest high and lowest low over a certain period (e.g. 22 days).

  2. When price breaks above the latest 1-day high, a buy signal is generated, flagging an uptrend.

  3. When price breaks below the latest 1-day low, a sell signal is generated, flagging a downtrend.

  4. Trend direction is checked to filter false signals. For example, new high price with bearish divergence is ignored for buying.

  5. Only when indicators align with price trend will trades be taken on breakouts of the latest high/low points.

The advantage is capturing pivotal breakout timing, which often accompanies trend start or acceleration. But over-trading in ranging markets should be prevented.

In summary, watching key price area breakouts is essential in trend following. But confirmation with other indicators and parameter tuning based on actual conditions are needed to maximize the strategy's utility.

Parameters

NameDefaultWhat it controls
v_input_1_hlc30price: hlc3 | high | low | open | hl2 | close | hlcc4 | ohlc4
v_input_222LookBack
v_input_314length
v_input_42length2

Source Pine Script

/*backtest
start: 2023-08-13 00:00:00
end: 2023-09-12 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=1
strategy(title="HIGHER HIGH LOWER LOW STRATEGY", shorttitle="HH LL STRATEGY", overlay=true, calc_on_order_fills=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, currency="USD", default_qty_value=100)

////


//Higher High or Lower Low Entry Inputs
price = input(hlc3)
LookBack = input(22)
Highest = highest(LookBack)
Lowest = lowest(LookBack)

long = price > Highest[1] 
short = price < Lowest[1]




//Divergence Check Inputs
length = input(14)
High_Guard = highest(length)
Low_Guard = lowest(length)

length2 = input(2)

long1 = long == 1 and Highest[1] > High_Guard[length2]
short1 = short == 1 and Lowest[1] < Low_Guard[length2]


plot(long and long[1], color=green, style=line)
plot(short and short[1], color=red, style=line)

strategy.entry("Long", strategy.long, when=long1)
strategy.entry("Short", strategy.short, when=short1)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-13. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/High-Low-Breakout-Trend-Following-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open