Three Line Breakout Strategy
This strategy is based on a modified three line break chart. Two lines made of closing prices form a "cloud" shape. Breakout below the cloud signals a new bearish trend. Breakout above the cloud signals a new bullish…
Overview
This strategy is based on a modified three line break chart. Two lines made of closing prices form a "cloud" shape. Breakout below the cloud signals a new bearish trend. Breakout above the cloud signals a new bullish trend. It is a price action strategy that can be combined with trend filters like SuperTrend.
Strategy Logic
Define current price xu, xu1, xu2, xu3 for plotting three lines.
Update xu1, xu2, xu3 based on price as upper/lower band.
xu breaking xu3 starts a short trend, breaking xu1 starts a long trend.
Plot cloud band using xu and xu3.
Option to trade in reverse direction.
Enter on cloud breakouts, exit on returning inside cloud.
Advantage Analysis
The advantages of this strategy are:
Based purely on price action, unaffected by indicators.
Clear and intuitive three line pattern.
Flexibility to trade reversals.
Easy to combine with trends and other indicators.
Easy backtesting and visualization for refinement.
Risk Analysis
The main risks of this strategy are:
Price patterns prone to false breakouts from events.
No stop loss exposes to large losses.
Ignores trading costs.
Fixed parameters may not suit different products.
Doesn't account for consecutive breakouts.
Reversal trading risky against major trends.
Optimization Directions
The strategy can be improved by:
Adding stop loss and optimizing stops.
Accounting for trading costs.
Testing parameters for different products.
Improving breakout logic for consecutive breaks.
Adding trend filter to avoid counter-trend trades.
Controlling position sizing.
Expanding backtest period for robustness.
Summary
The three line breakout strategy provides intuitive signals based on price patterns. It can be strengthened by adding trends, indicators, stops, optimized logic and parameters, and position sizing. This can transform it into a robust short-term trading system.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2022-09-22 00:00:00
end: 2023-09-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 31/05/2019
// This is a modified version of the three line break price representation.
// It is composed with 2 lines made of Close price values forming a "cloud".
// If the trend is bullish and the price breach the lower level of the green
// cloud, a new bearish trend is taking place.
// If the current trend is bearish and the price breakout the upper band of
// the cloud, a new bullish trend is forming.
// This is a "price action" indicator, signals may be filtered by long term trend
// analysis with other indicators such as Supertrend for instance.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Three Line Break", overlay = true)
reverse = input(false, title="Trade reverse")
xtrend = 1
xu = close
xu1 = close
xu2 = close
xu3 = close
if xtrend[1] == 1
if close > xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := 1
else
if close < xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := -1
else
xtrend := 1
else
if close > xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := 1
else
if close < xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := -1
else
xtrend := -1
colorm = xtrend == -1 ? red: xtrend == 1 ? green : blue
possig = iff(reverse and xtrend == 1, -1,
iff(reverse and xtrend == -1, 1, xtrend))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
p1 = plot(xu, color=colorm)
p2 = plot(xu3, color=colorm)
fill(p1, p2, color=colorm)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-23. 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/Three-Line-Breakout-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
- Momentum Breakout Trading Strategy 440964Pine Script · Breakout · 5m
- Momentum Strategy Based on Double Bottom Breakout ModelPine Script · Breakout · 1m
- Quantitative Trading Strategy Based on Ichimoku with Multiple SignalsPine Script · Breakout · 1h
- Beyond The Clouds StrategyPine Script · Breakout · 1h
- Moonshot Dual Triangle Breakout StrategyPine Script · Breakout · 10m
- Dual MA Indicator Oscillating Price Tracking StrategyPine Script · Breakout · 2h