시장 감정에 기반한 이치모쿠의 브레이크업 전략

저자:차오장, 날짜: 2024-02-04 14:46:22
태그:

img

전반적인 설명

이 전략은 이치모쿠 클라우드 지표를 결합하여 시장 정서를 측정하고 잠재적인 브레이크아웃 기회를 식별합니다. 이치모쿠 기반 트렌드 필터링, ATR/퍼센트 트레일링 스톱 및 선택적 인 수익 취득 메커니즘이 있습니다.

전략 논리

두 가지 핵심 요소가 있습니다. 상승/하락 모멘텀을 결정하는 이치모쿠 클라우드 신호와 잠재적인 브레이크를 포착하는 강도 폭발 신호입니다.

트렌드 신호는 상승 추세를 표시하기 위해 컨버전션 라인이 베이스 라인의 위를 넘어야 하며, 가격 막대 위에 있는 라그 스판은 강력한 추진력을 나타내고, 이치모쿠 클라우드 상단에서 가격 경류가 필요합니다.

추가 진입 기회에 대한 강도 폭발 신호는 클라우드의 최근 최저와 최고치를 깨고 초강도 및 전환/기본선 상승에 동의하는 가격을 요구합니다.

롱 엔트리는 신호가 발사되면 시작됩니다. 출구는 ATR, 비율 또는 이치모쿠 규칙을 기반으로 수익을 확보합니다.

이점 분석

가장 큰 이점은 이치모쿠 클라우드를 트렌드 분석과 모멘텀 분석을 위해 사용함으로써 이동평균과 같은 단독 지표보다 신호가 더 정확해집니다.

ATR/퍼센트 트레일링 스톱의 위험 관리 또한 거래당 손실을 작게 유지합니다. 선택적 인 이익 취득은 보상 일관성을 더욱 향상시킵니다.

위험 분석

이치모쿠 클라우드는 몇 가지 문제점이 있습니다. 강도 신호는 또한 추진력을 쫓는 가능성을 증가시킵니다.

후퇴 위험을 해결하기 위해 클라우드 더 빠른 설정을 최적화합니다. 모멘텀 위험을 위해, 더 긴 후속 스톱은 역행에 더 빠르게 반응합니다.

최적화 방향

가능한 개선 사항은 다음과 같습니다.

  1. 더 많은 시장 데이터를 통해 안정성을 테스트합니다.

  2. 특정 도구에 대한 클라우드 매개 변수를 최적화합니다.

  3. 더 나은 신호 등급을 얻기 위해 LSTM처럼 ML를 시도해보세요.

  4. 부피 분석을 추가해서 황소 함정을 피합니다.

결론

이치모쿠 시스템은 트렌드 트레이딩에 대한 시장 정서를 효과적으로 측정합니다. 추진력을 잡고 위험을 관리하는 데 균형 잡힌 초점을 맞추는 것도 실용적입니다. 개선할 여지가 있지만 전반적으로 견고한 트렌드 다음 프레임워크입니다.


/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mikul_se
//@version=5
strategy("mikul's Ichimoku Cloud Strategy v 2.0", shorttitle="mikul's Ichi strat", overlay=true, margin_long=100, margin_short=100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

// Strategy settings
strategySettingsGroup = "Strategy settings"
trailSource         = input.string(title="Trail Source", defval="Lows/Highs", options=["Lows/Highs", "Close", "Open"], confirm=true, group=strategySettingsGroup)
trailMethod         = input.string(title="Trail Method", defval="ATR", options=["ATR", "Percent", "Ichi exit"], confirm=true, tooltip="Ichi rules means it follows the rules of the Ichimoku cloud for exiting the trade.", group=strategySettingsGroup)
trailPercent        = input.float(title="Trail Percent", defval=10, minval=0.1, confirm=true, group=strategySettingsGroup)
swingLookback       = input.int(title="Lookback", defval=7, confirm=true, group=strategySettingsGroup)
atrPeriod           = input.int(title="ATR Period", defval=14, confirm=true, group=strategySettingsGroup)
atrMultiplier       = input.float(title="ATR Multiplier", defval=1.0, confirm=true, group=strategySettingsGroup)
addIchiExit         = input.bool(false, "Add Ichimoku exit", "You can use this to add Ichimoku cloud exit signals on top of Percent or ATR", group=strategySettingsGroup)
useTakeProfit       = input.bool(false, "Use Take Profit", confirm=true, group=strategySettingsGroup)
takeProfitPercent   = input.float(title="Take Profit Percentage", defval=5, minval=0.1, confirm=true, group=strategySettingsGroup)

// Ichimoku settings
ichimokuSettingsGroup = "Ichimoku settings"
conversionPeriods       = input.int(9, minval=1, title="Conversion Line Length", group=ichimokuSettingsGroup)
basePeriods             = input.int(26, minval=1, title="Base Line Length", group=ichimokuSettingsGroup)
laggingSpan2Periods     = input.int(52, minval=1, title="Leading Span B Length", group=ichimokuSettingsGroup)
displacement            = input.int(26, minval=1, title="Lagging Span", group=ichimokuSettingsGroup)
delta                   = input.int(26, minval=1, title="Delta", group=ichimokuSettingsGroup)

donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine       = donchian(basePeriods)
leadLine1      = math.avg(conversionLine, baseLine)
leadLine2      = donchian(laggingSpan2Periods)

uppercloud     = leadLine1[displacement-1]
bottomcloud    = leadLine2[displacement-1]

// Ichi exit variables and calculations 
delta2 = delta-3
average(len) => math.avg(ta.lowest(len), ta.highest(len))

conversion_line = average(conversionPeriods)
base_line       = average(basePeriods)
lead_line_a     = math.avg(conversion_line, base_line)
lead_line_b     = average(laggingSpan2Periods)
lagging_span    = close
lead_line_a_delta = lead_line_a[delta]
lead_line_b_delta = lead_line_b[delta]
lagging_span_delta = lagging_span[delta]
prisgris = hlc3[delta]
prisgris2 = hlc3[delta2]

// Declare trailing price variable (stores our trail stop value)
var float trailPrice    = na
float next_trailPrice   = na

// Get required trailing stop variables
atrValue       = ta.atr(atrPeriod) * atrMultiplier
swingLow       = ta.lowest(low, swingLookback)
swingHigh      = ta.highest(high, swingLookback)

// Ichi plotting
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset=-displacement + 1, color=#43A047, title="Lagging Span")
p1 = plot(leadLine1, offset=displacement - 1, color=#A5D6A7, title="Leading Span A")
p2 = plot(leadLine2, offset=displacement - 1, color=#EF9A9A, title="Leading Span B")
fill(p1, p2, color=leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))

// Plotting ichi crossover signals
ichiup = ta.crossover(conversionLine, baseLine)
ichidown = ta.crossover(baseLine, conversionLine)

plotshape(ichiup ? conversionLine : na, 'Ichi long 1', style=shape.circle, location=location.absolute, offset=0, color=#00ff00b0, size=size.tiny)
plotshape(ichidown ? conversionLine : na, 'Ichi short 1', style=shape.circle, location=location.absolute, offset=0, color=#ff1100c7, size=size.tiny)

// Pamp signal
signal5 = close > bottomcloud[displacement] and close > uppercloud[displacement] and close > high[displacement]
signal5b = close[1] <= bottomcloud[displacement+1] or close[1] <= uppercloud[displacement+1] or close <= high[displacement+1]
signal6 = close > bottomcloud and close > uppercloud and close > open
signal6b = close[1] <= bottomcloud[1] or close[1] <= uppercloud[1]
signal7 = leadLine1 > leadLine2
signal7b = leadLine1[1] <= leadLine2[1]
signal8 = conversionLine > baseLine

pamp = signal5 and signal6 and signal7 and signal8 and strategy.position_size == 0 and (signal5b or signal6b or signal7b)

// Trend signal
nsignal5 = close > close[displacement]
nsignal6 = close > bottomcloud and close > uppercloud and close > open
nsignal8 = ta.crossover(conversionLine, baseLine) and conversionLine > bottomcloud and conversionLine > uppercloud and baseLine > bottomcloud and baseLine > uppercloud

trend = nsignal5 and nsignal6 and nsignal8 and strategy.position_size == 0

plotshape(trend, style=shape.triangleup, location=location.belowbar, color=color.green)

if (trend or pamp)
    trailPrice := na
    strategy.entry(trend ? "Trend" : "Pamp", direction = strategy.long)

// Get trailing stop price
if trailMethod == "ATR"
    next_trailPrice := switch trailSource
        "Close" => strategy.position_size > 0 ? close - atrValue : close + atrValue
        "Open" => strategy.position_size > 0 ? open - atrValue : open + atrValue
        => strategy.position_size > 0 ? swingLow - atrValue : swingHigh + atrValue
else if trailMethod == "Percent"
    float percentMulti = strategy.position_size > 0 ? (100 - trailPercent) / 100 : (100 + trailPercent) / 100
    next_trailPrice := switch trailSource
        "Close" => close * percentMulti
        "Open" => open * percentMulti
        => strategy.position_size > 0 ? swingLow * percentMulti : swingHigh * percentMulti
else
    short_signal = (ta.crossunder(lagging_span, prisgris)) or ta.crossover(base_line, conversion_line) and ((close)) < ((lead_line_a)) or ta.crossunder(lagging_span, prisgris) or (ta.crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b)))

    if short_signal
        strategy.close("Trend", "Ichi trend over")
        strategy.close("Pamp", "Ichi pamp over")
        alert("Sell")

if (addIchiExit)
    short_signal = (ta.crossunder(lagging_span, prisgris)) or ta.crossover(base_line, conversion_line) and ((close)) < ((lead_line_a)) or ta.crossunder(lagging_span, prisgris) or (ta.crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b)))

    if short_signal
        strategy.close("Trend", "Ichi trend over")
        strategy.close("Pamp", "Ichi pamp over")
        alert("Sell")

// Check for trailing stop update
if strategy.position_size != 0 and barstate.isconfirmed
    if (next_trailPrice > trailPrice or na(trailPrice)) and strategy.position_size > 0
        trailPrice := next_trailPrice
        alert(message="Trailing Stop updated for " + syminfo.tickerid + ": " + str.tostring(trailPrice, "#.#####"), freq=alert.freq_once_per_bar_close)

    if (next_trailPrice < trailPrice or na(trailPrice)) and strategy.position_size < 0
        trailPrice := next_trailPrice
        alert(message="Trailing Stop updated for " + syminfo.tickerid + ": " + str.tostring(trailPrice, "#.#####"), freq=alert.freq_once_per_bar_close)

// Draw data to chart
plot(strategy.position_size != 0 ? trailPrice : na, color=color.red, title="Trailing Stop")

// Take Profit
float profitTarget = strategy.position_avg_price * (1 + takeProfitPercent / 100)

// Exit trade if stop is hit
strategy.exit(id="trend Exit", from_entry="Trend", stop=trailPrice, limit=useTakeProfit ? profitTarget : na)
strategy.exit(id="pamp Exit", from_entry="Pamp", stop=trailPrice, limit=useTakeProfit ? profitTarget : na)

if strategy.position_size == 0
    trailPrice = 0


더 많은