Files
strategies/ZZ-4价格通道突破策略ZZ-4-Price-Channel-Breakout-Strategy.md
2024-03-03 22:27:55 +08:00

7.4 KiB

Name

ZZ-4价格通道突破策略ZZ-4-Price-Channel-Breakout-Strategy

Author

ChaoZhang

Strategy Description

[trans]

概述

本策略基于ZZ指标的价格通道进行交易,利用价格向上突破通道上限或向下跌破通道下限的信号来建立多头或空头仓位。该策略试图捕捉价格通道范围外的趋势爆发。

策略原理

  1. 计算价格通道的上下限
  2. 当价格上涨突破上限时做多
  3. 当价格下跌突破下限时做空
  4. 设置起止交易时间
  5. 每日收市前清仓

具体来说,该策略通过ZZ指标计算出价格通道的上下限。当价格从下方突破上限时,做多入场;从上方突破下限时,做空入场。做多做空后均采用止损单,以价格通道上下限作为止损位。同时设置日期时间范围,在该范围内交易,每日收市前清仓以避免隔夜风险。

优势分析

  1. 利用价格通道判断潜在趋势突破点,具有一定的趋势识别能力
  2. 交易信号简单直观容易判断
  3. 可自定义通道周期参数,适应不同品种和周期
  4. 设置日期范围和每日清仓有助于风险控制
  5. 采用止损单,可限制单笔亏损

风险分析

  1. 价格通道范围内波动可能导致多次止损
  2. 需适时调整参数,否则通道范围可能不准确
  3. 突破有可能是假突破,存在被套风险
  4. 潜在盈利受限制于价格通道范围
  5. 未充分利用趋势行情的利润空间

可通过放宽通道区间、优化止损策略、判断趋势实力等方式来降低上述风险。

优化方向

  1. 测试不同参数找出最佳组合
  2. 放宽价格通道范围以捕捉更大行情
  3. 引入趋势判断指标避免假突破
  4. 优化止损策略,防止被套
  5. 加大持仓比例以最大化突破获利
  6. 评估不同日期范围的收益率

总结

本策略基于价格通道判断趋势爆发点进行交易。优点是交易信号简单,止损清晰,易于操作;缺点是存在频繁跳空和未充分利用趋势两方面。通过参数优化、策略组合等方式可以在保持优势的同时克服上述缺点。该策略可助力交易者掌握价格通道的应用技巧。

||

Overview

This strategy trades based on the price channel of the ZZ indicator, taking long/short positions when price breaks out above/below the channel bands. It aims to capture trend outbreak moves outside the channel range.

Strategy Logic

  1. Calculate price channel upper/lower bands
  2. Go long when price breaks out above upper band
  3. Go short when price breaks down below lower band
  4. Set trading time range
  5. Clear positions before daily close

Specifically, it uses the ZZ indicator to calculate the price channel bands. When price breaks out upward from the lower band, go long. When price breaks down from the upper band, go short. Stop loss orders are used with the channel bands as stop loss levels. Trading hours are also defined to avoid overnight risks.

Advantage Analysis

  1. Price channel identifies potential trend breakouts
  2. Simple and clear trading signals
  3. Customizable channel period fits different products and cycles
  4. Trading hours and daily exit manage risks
  5. Stop loss limits single trade loss

Risk Analysis

  1. Whipsaws inside channel may repeatedly hit stop loss
  2. Requires timely parameter tuning, otherwise channel range may be inaccurate
  3. Breakouts can be false, risks of being trapped
  4. Profit potential is limited by channel range
  5. Fails to fully capitalize on trend moves

Risks can be reduced by widening channel range, optimizing stop loss, gauging trend strength etc.

Optimization Directions

  1. Test different parameter combinations for best setup
  2. Widen price channel to capture larger moves
  3. Add trend indicator to avoid false breakouts
  4. Optimize stop loss to prevent being trapped
  5. Increase position size to maximize breakout profits
  6. Evaluate profitability across different date ranges

Summary

This strategy trades price channel breakouts to identify trend outbreaks. Pros are simple clear signals and easy operation; Cons are whipsaws and failure to ride trends. Parameter optimization and strategy combination can overcome the cons while retaining pros. It helps traders master applying price channel techniques.

[/trans]

Strategy Arguments

Argument Default Description
v_input_1 true Long
v_input_2 true Short
v_input_3 100 Capital, %
v_input_4 7 Length
v_input_5 true Show Levels
v_input_6 false Show Background
v_input_7 false Show Price Channel
v_input_8 1900 From Year
v_input_9 2100 To Year
v_input_10 true From Month
v_input_11 12 To Month
v_input_12 true From day
v_input_13 31 To day

Source (PineScript)

/*backtest
start: 2022-09-14 00:00:00
end: 2023-09-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2019

//@version=4
strategy(title = "Noro's ZZ-4 Strategy", shorttitle = "Noro's ZZ-4 Strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
len = input(7, minval = 1, title = "Length")
showll = input(true, defval = true, title = "Show Levels")
showbg = input(false, defval = false, title = "Show Background")
showpc = input(false, defval = false, title = "Show Price Channel")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//Price channel
h = highest(ohlc4, len)
l = lowest(ohlc4, len)
pccol = showpc ? color.blue : na
plot(h, color = pccol, transp = 0)
plot(l, color = pccol, transp = 0)

//Levels
ml = 0
ml := l > l[1] ? 1 : l < l[1] ? -1 : ml[1]
ll = 0.0
ll := ml == 1 and ml[1] == -1 ? l[1] : ll[1]
mh = 0
mh := h > h[1] ? 1 : h < h[1] ? -1 : mh[1]
hl = 0.0
hl := mh == -1 and mh[1] == 1 ? h[1] : hl[1]

//Lines
colorh = showll and hl == hl[1] ? color.lime : na
colorl = showll and ll == ll[1] ? color.red : na
plot(hl, color = colorh, linewidth = 2, transp = 0, title = "Long")
plot(ll, color = colorl, linewidth = 2, transp = 0, title = "Short")

//Background
size = strategy.position_size
trend = 0
trend := size > 0 ? 1 : size < 0 ? -1 : high >= hl ? 1 : low <= ll ? -1 : trend[1]
bgcol = showbg == false ? na : trend == 1 ? color.lime : trend == -1 ? color.red : na
bgcolor(bgcol, transp = 80)

//Trading
truetime = time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)
lot = 0.0
lot := size != size[1] ? strategy.equity / close * capital / 100 : lot[1]
if ll > 0 and hl > 0
    strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, stop = hl, when=(truetime))
    strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, stop = ll, when=(truetime))
if time > timestamp(toyear, tomonth, today, 23, 59)
    strategy.close_all()
    strategy.cancel("Long")
    strategy.cancel("Short")

Detail

https://www.fmz.com/strategy/427450

Last Modified

2023-09-21 10:59:55