Swing Points Breakout Trading Strategy
This strategy identifies swing highs and lows in price to trade breakouts in the trending direction. It is a trend-following strategy that aims to capture price swings during sustained trends. Strategy Logic: 1…
This strategy identifies swing highs and lows in price to trade breakouts in the trending direction. It is a trend-following strategy that aims to capture price swings during sustained trends.
Strategy Logic:
Identify swing highs and lows over a specified period.
Go long when price breaks above swing high.
Go short when price breaks below swing low.
Set stop loss at previous swing low (for long) or swing high (for short) to control risk.
If price reverses below stop loss, exit the position.
Advantages:
Swing points effectively identify trends. Trend trading has high win rate.
Breaking swing points accelerates price behaviors, good for trend following.
Stops at key support/resistance levels manage risk.
Risks:
Swing points often lag, risk missing best entry timing.
Stops being too tight get hit by market noise. Consider widening range.
Breakouts prone to head fakes. Need stops to defend pullbacks.
In summary, the swing points breakout strategy follows medium/long-term trends using trend-based breakout trading. It can achieve high win rate but requires careful entry timing and stop loss placement to optimize performance. Investors should consider its risks and apply appropriate money management for long-term steady gains.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | leftBars |
| v_input_2 | true | rightBars |
Source Pine Script
/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("Swing Points", overlay=true)
leftBars = input(1)
rightBars=input(1)
sl = pivotlow(low, leftBars, rightBars)
sh = pivothigh(high, leftBars, rightBars)
last_sh=na
last_sh:= sh!=0 ? sh : nz(last_sh[1])
last_sl=na
last_sl:= sl!=0 ? sl : nz(last_sl[1])
EMA = ema(close,55)
longCondition = sh and high > EMA
shortCondition = sl and close < EMA
exitLongCondition = sl < sh[1]
exitShortCondition = sh > sl[1]
if longCondition
strategy.entry("swinghigh", strategy.long, stop=last_sh)
if shortCondition
strategy.entry("swinglow", strategy.short, stop=last_sl)
if exitLongCondition
strategy.exit("stoplong", "swinghigh", stop = last_sl )
if exitShortCondition
strategy.exit("stopshort", "swinglow", stop = last_sh )
plot(EMA,linewidth = 4)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-12. 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/Swing-Points-Breakout-Trading-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
- Exponential Moving Average Candle Stop Trading StrategyPine Script · Breakout · 1d
- Kana Candle Breakout Strategy Based on Moving Average and Support ResistancePine Script · Breakout · 1h
- Momentum Breakout Moving Average StrategyPine Script · Breakout · 1d
- Momentum Breakout Trading Strategy 435896Pine Script · Breakout · 1d
- Moving Average Crossover and Upper Rail Breakthrough Impulse StrategyPine Script · Breakout · 1m
- Multi Indicator Short Term Algorithmic Trading StrategyPine Script · Breakout · 4h