ZEC 트렌드 추적 지능형 추가 전략

DONCHIAN ATR Pivot STRUCTURE
생성 날짜: 2025-12-12 11:16:51 마지막으로 수정됨: 2025-12-12 11:16:51
복사: 12 클릭수: 318
avatar of ianzeng123 ianzeng123
2
집중하다
413
수행원

ZEC 트렌드 추적 지능형 추가 전략 ZEC 트렌드 추적 지능형 추가 전략

, 이 전략은 뭐하는 거야?

아세요? 이 전략은 마치 초조심한 투자 노령 운전사 같죠! 그것은 맹목적으로 추락을 쫓는 것이 아니라, “망원경” (다중 시간 프레임 시장 구조 분석) 을 사용하여 큰 추세를 관찰하고, 방향이 괜찮은 것을 확인한 후에, 둥근 통로 돌파구를 진입 신호로 사용합니다. 간단히 말해서: 큰 방향을 보고, 작은 돌파구를 잡습니다!

가장 흥미로운 것은, 그것은 또한 “배열로 창고”를 만들 것입니다. 그것은 마치 당신이 음식을 사서 먼저 맛보고, 맛있게 먹기 위해 몇 개를 더 구입하는 것과 같습니다. 가격이 유리한 방향으로 움직일 때, 그것은 ATR (평균 실제 파동) 에 따라 지능적으로 창고를 추가하여 수익을 더 많이 얻을 수 있습니다!

🔍 코어 하이라이트 해독

비중을 맞추세요!이 전략은 세 가지 측면에서 매우 강력합니다.

1. 다중 시간 프레임 구조 필터링 🕐 운전하기 전에 내비게이션을 통해 큰 방향을 확인하는 것처럼, 전략은 먼저 더 큰 주기의 시장 구조를 분석합니다. 큰 추세가 상승할 때만 더 많이하고, 큰 추세가 하락할 때 비어있을 때만 비어 있습니다.

2. ATR 다이내믹 가저 시스템 📊 전통적 전략은 을 사용하거나 고정 입장을 취한다. 이 전략은 더 똑똑하다! 그것은 시장의 변동성 (ATR) 에 따라 입금 시기와 손실 위치를 결정한다. 시장의 변동성이 큰 경우, 더 많은 공간을 제공합니다. 변동 시간, 더 엄격한 제어.

3. 반전 신호 평지 🔄 가장 멋있는 것은 평준화 논리입니다. 정지 또는 고정 목표를 기다리는 것이 아니라 역입입 신호가 발생했을 때 완전히 평준화하십시오.

매개 변수 설정 스티커

구덩이 안내서가 왔어요!

  • 입학 통로 주기 ((20)“미국 정부에 대한 두려움은 너무 크다”
  • 출전 통로 주기 ((10)“그때의 주식시장에서는 주식시장보다 주식시장 주가가 더 낮아서 주식시장에 더 민감하게 접근할 수 있습니다.
  • ATR 배수 ((2.0 정지, 0.5 상장)이 비율은 매우 중요합니다. 손실을 줄이려면 충분한 공간을 줘야 하고, 주식을 적당히 늘려야 합니다.
  • 최대 단위 2“위험을 통제하고, 탐욕을 피하라!”

실전 응용 시나리오

이 전략은 언제 가장 적합할까요?

가장 좋은 사용 시나리오:

  • 트렌디한 품종 (예를 들어, 암호화폐, 상품 선물)
  • 명확한 방향성 시장 환경
  • 그리고 그 다음에는, 당신은 당신의 신호에 대해 더 많은 정보를 얻을 것입니다.

이 문서는 다음과 같습니다.

  • 시장을 뒤흔들어 놓은 횡단보도 ()
  • 뉴스가 자주 바뀌는 시기
  • 그리고, 만약 여러분이 HF 거래를 하고 싶다면

기억하세요: 이것은 ‘작게 일해서 잘 사는’ 전략입니다. 하루아침에 부자가 되는 도구가 아니라, 트렌드 속에서 돈을 안정적으로 벌 수 있도록 도와주는 좋은 조력자입니다!

전략 소스 코드
/*backtest
start: 2025-11-11 00:00:00
end: 2025-12-10 08:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"ZEC_USDT"}]
*/

//@version=6
strategy("Trend $ZEC", shorttitle="$ZEC 1/15m", overlay=true, 
         initial_capital=10000, 
         default_qty_type=strategy.cash, 
         default_qty_value=5000, 
         commission_type=strategy.commission.percent, 
         commission_value=0.06,
         slippage=0,
         max_lines_count=500,
         max_labels_count=500)

// ========== 參數設定 ==========
// 唐奇安通道參數
entry_period = input.int(20, "進場通道週期", minval=1, group="通道設定")
exit_period = input.int(10, "出場通道週期", minval=1, group="通道設定")

// ATR 參數
atr_period = input.int(20, "ATR 週期", minval=1, group="ATR 設定")
atr_stop_mult = input.float(2.0, "止損 ATR 倍數", minval=0.1, step=0.1, group="ATR 設定")
atr_add_mult = input.float(0.5, "加倉 ATR 倍數", minval=0.1, step=0.1, group="ATR 設定")

// 多空結構參數 - 加入多時間框架
swing_length = input.int(160, "結構擺動長度", minval=1, group="📊 多空結構過濾")
structure_timeframe = input.timeframe("1", "結構時間框架", group="📊 多空結構過濾", tooltip="選擇結構判斷的時間週期,空白=當前圖表,D=日線,W=週線")
show_structure_lines = input.bool(false, "顯示結構線", group="📊 多空結構過濾")
show_structure_labels = input.bool(false, "顯示結構標籤", group="📊 多空結構過濾")

// 加倉設定
max_units = input.int(2, "最大單位數(含首次)", minval=1, maxval=10, group="倉位管理")
position_size = input.int(5000, "每單位資金(USD)", minval=100, group="倉位管理", tooltip="10000U本金分2次進場,每次5000U")

// 顯示設定
show_channels = input.bool(false, "顯示通道", group="顯示設定")
show_atr_lines = input.bool(false, "顯示 ATR 線", group="顯示設定")
show_labels = input.bool(true, "顯示標籤", group="顯示設定")
show_table = input.bool(false, "顯示資訊面板", group="顯示設定")
label_distance = input.float(2.5, "標籤距離 K 棒倍數", minval=0.1, step=0.1, group="顯示設定", tooltip="標籤距離K棒的ATR倍數")
show_label_lines = input.bool(false, "顯示標籤連線", group="顯示設定")

// ========== 計算唐奇安通道 ==========
entry_upper = ta.highest(high, entry_period)
entry_lower = ta.lowest(low, entry_period)
exit_upper = ta.highest(high, exit_period)
exit_lower = ta.lowest(low, exit_period)

// ========== 計算 ATR (N值) ==========
N = ta.atr(atr_period)

// ========== 多時間框架多空結構判斷 ==========
// 計算結構的函數
f_calculate_structure() =>
    var int trend = 0
    var float lastHigh = na
    var float lastLow = na
    
    swingHigh = ta.pivothigh(high, swing_length, swing_length)
    swingLow = ta.pivotlow(low, swing_length, swing_length)
    
    if not na(swingHigh)
        lastHigh := swingHigh
    
    if not na(swingLow)
        lastLow := swingLow
    
    if not na(lastHigh) and close > lastHigh and trend != 1
        trend := 1
    
    if not na(lastLow) and close < lastLow and trend != -1
        trend := -1
    
    [trend, lastHigh, lastLow]

// 獲取指定時間框架的結構
[structure_trend_mtf, last_structure_high_mtf, last_structure_low_mtf] = request.security(syminfo.tickerid, structure_timeframe, f_calculate_structure(), lookahead=barmerge.lookahead_off)

// 使用多時間框架的結構趨勢
structure_trend = structure_trend_mtf
last_structure_high = last_structure_high_mtf
last_structure_low = last_structure_low_mtf

// 檢測結構變化(用於繪製標籤)
var int prev_structure_trend = 0
bool bull_break = structure_trend == 1 and prev_structure_trend != 1
bool bear_break = structure_trend == -1 and prev_structure_trend != -1
prev_structure_trend := structure_trend

// 繪製結構突破標籤
if show_structure_labels
    if bull_break
        label.new(bar_index, low, "多方結構", style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.white, size=size.small)
    
    if bear_break
        label.new(bar_index, high, "空方結構", style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white, size=size.small)

// ========== 持倉狀態追蹤 ==========
var float entry_price = na
var float[] add_prices = array.new_float(0)
var int position = 0
var int units = 0
var float stop_loss = na

// ========== 進場訊號 (加入結構過濾) ==========
long_entry_signal = close > entry_upper[1] and structure_trend == 1
short_entry_signal = close < entry_lower[1] and structure_trend == -1

long_entry = long_entry_signal and position != 1
short_entry = short_entry_signal and position != -1

// ========== 加倉訊號 ==========
long_add = false
short_add = false

if position == 1 and units < max_units
    if array.size(add_prices) > 0
        last_add_price = array.get(add_prices, array.size(add_prices) - 1)
        long_add := close >= last_add_price + (atr_add_mult * N)
    else
        long_add := close >= entry_price + (atr_add_mult * N)

if position == -1 and units < max_units
    if array.size(add_prices) > 0
        last_add_price = array.get(add_prices, array.size(add_prices) - 1)
        short_add := close <= last_add_price - (atr_add_mult * N)
    else
        short_add := close <= entry_price - (atr_add_mult * N)

// ========== 出場訊號 (改為反向訊號出場) ==========
// 多單出場:當空單進場訊號觸發時
long_exit = (position == 1) and short_entry_signal

// 空單出場:當多單進場訊號觸發時
short_exit = (position == -1) and long_entry_signal

// ========== 更新持倉狀態 ==========
if long_entry
    position := 1
    units := 1
    entry_price := close
    array.clear(add_prices)
    array.push(add_prices, close)
    stop_loss := close - (atr_stop_mult * N)
    alert_msg = timeframe.period + " 做多 EP:" + str.tostring(close, "#.##")
    strategy.entry("多單1", strategy.long, qty=position_size/close, comment=alert_msg, alert_message=alert_msg)
    
else if short_entry
    position := -1
    units := 1
    entry_price := close
    array.clear(add_prices)
    array.push(add_prices, close)
    stop_loss := close + (atr_stop_mult * N)
    alert_msg = timeframe.period + " 做空 EP:" + str.tostring(close, "#.##")
    strategy.entry("空單1", strategy.short, qty=position_size/close, comment=alert_msg, alert_message=alert_msg)
    
else if long_add
    units := units + 1
    array.push(add_prices, close)
    stop_loss := close - (atr_stop_mult * N)
    alert_msg = timeframe.period + " 加倉多 " + str.tostring(units) + "/" + str.tostring(max_units) + " EP:" + str.tostring(close, "#.##")
    strategy.entry("多單" + str.tostring(units), strategy.long, qty=position_size/close, comment=alert_msg, alert_message=alert_msg)
    
else if short_add
    units := units + 1
    array.push(add_prices, close)
    stop_loss := close + (atr_stop_mult * N)
    alert_msg = timeframe.period + " 加倉空 " + str.tostring(units) + "/" + str.tostring(max_units) + " EP:" + str.tostring(close, "#.##")
    strategy.entry("空單" + str.tostring(units), strategy.short, qty=position_size/close, comment=alert_msg, alert_message=alert_msg)
    
else if long_exit or short_exit
    if long_exit
        alert_msg = timeframe.period + " 平多 反向訊號"
        strategy.close_all(comment=alert_msg, alert_message=alert_msg)
    if short_exit
        alert_msg = timeframe.period + " 平空 反向訊號"
        strategy.close_all(comment=alert_msg, alert_message=alert_msg)
    
    position := 0
    units := 0
    entry_price := na
    array.clear(add_prices)
    stop_loss := na

// ========== 繪製通道 ==========
plot(show_channels ? entry_upper : na, "進場上軌", color=color.new(color.red, 0), linewidth=2)
plot(show_channels ? entry_lower : na, "進場下軌", color=color.new(color.green, 0), linewidth=2)
plot(show_channels ? exit_upper : na, "出場上軌", color=color.new(color.orange, 50), linewidth=1, style=plot.style_circles)
plot(show_channels ? exit_lower : na, "出場下軌", color=color.new(color.blue, 50), linewidth=1, style=plot.style_circles)

// 繪製結構高低點
plot(show_structure_lines ? last_structure_high : na, "結構高點", color=color.new(color.red, 70), linewidth=2, style=plot.style_stepline)
plot(show_structure_lines ? last_structure_low : na, "結構低點", color=color.new(color.green, 70), linewidth=2, style=plot.style_stepline)

// ========== 繪製 ATR 線 ==========
plot(show_atr_lines and position != 0 ? stop_loss : na, "止損線", color=color.new(color.red, 0), linewidth=2, style=plot.style_cross)

var float next_add_long = na
if position == 1 and units < max_units
    next_add_long := array.size(add_prices) > 0 ? array.get(add_prices, array.size(add_prices) - 1) + (atr_add_mult * N) : entry_price + (atr_add_mult * N)
else
    next_add_long := na

plot(show_atr_lines and position == 1 and units < max_units ? next_add_long : na, "下次加倉(多)", color=color.new(color.yellow, 30), linewidth=1, style=plot.style_stepline)

var float next_add_short = na
if position == -1 and units < max_units
    next_add_short := array.size(add_prices) > 0 ? array.get(add_prices, array.size(add_prices) - 1) - (atr_add_mult * N) : entry_price - (atr_add_mult * N)
else
    next_add_short := na

plot(show_atr_lines and position == -1 and units < max_units ? next_add_short : na, "下次加倉(空)", color=color.new(color.yellow, 30), linewidth=1, style=plot.style_stepline)