マルチテイク・プロフィートとストップ・ロスの波 トレンド 戦略をフォローする

作者: リン・ハーンチャオチャン, 日付: 2023-12-01 18:09:12
タグ:

img

概要

この戦略は,LazyBearのオリジナルのWaveTrend戦略をベースに,セカンドリーストップ損失,マルチテイク・プロフィートレベル,高タイムフレームEMAフィルターなどの追加機能があります.これは,取引後の自動的なトレンド管理のためのEMAフィルターとストップ損失/テイクプロフィート管理を組み合わせて,トレード信号を生成するためにWaveTrendインジケーターを使用します.

戦略の論理

この戦略の核心指標は WaveTrendで,3つの要素で構成されています.

  1. AP: 平均価格 = (最高値 + 最低値 + 閉じる) /3

  2. エスE: APの n 期間の EMA

  3. CI: (AP-ESA) / (AP-ESA) の絶対値の (0.015 * N1期間の EMA)

  4. TCI: CI の n 期間の EMA,また WaveTrend Line 1 (WT1) と呼ばれる

  5. WT2:WT1の4期SMA

WT1が WT2 (黄金十字) の上を横切るとロングポジションが開かれ,WT1が WT2 (死十字) の下を横切ると閉じる.

さらに,誤った信号を避けるため,高タイムフレームEMAフィルタが実装されており,価格がEMA以上,ショートトレードがEMA以下である場合にのみロングトレードが行われます.

利点

  1. 手動判断なしでWaveTrendを使用してトレンドを自動的にフォローします

  2. 2次停止損失は,単一の取引損失を効果的に制限します.

  3. 複数の取利益レベルは利益獲得を最大化します

  4. EMAフィルターは誤った信号を回避することで勝利率を向上させます

リスク と 改善

  1. 傾向の逆転を検出できず,損失を引き起こす可能性があります.

  2. パラメータの調節が不十分で 取引が過剰になる

  3. 最適化のために異なるパラメータセットをテストすることができます

  4. 逆転検出のための追加の指標を検討する

結論

この戦略は,トレンドトレンドの自動トレンド検出,EMAフィルターによるトレンドフォロー,リスク制御,利益最大化を包括的に組み込み,効率を向上させ,トレンド取引とリスク管理をバランスさせるストップ損失/収益管理を行う.これは効率的で安定したトレンドフォローシステムである.さらなるパラメータ最適化と逆転メカニズムは戦略の適用性を向上させることができる.


/*backtest
start: 2023-10-31 00:00:00
end: 2023-11-30 00:00:00
period: 1h
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/
// © undacovacobra

//@version=4
strategy("WaveTrend Strategy [LazyBear] with Secondary Stop Loss", overlay=true)

// Input parameters
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
obLevel1 = input(60, "Over Bought Level 1")
obLevel2 = input(53, "Over Bought Level 2")
osLevel1 = input(-60, "Over Sold Level 1")
osLevel2 = input(-53, "Over Sold Level 2")
useEmaFilter = input(false, "Use EMA Filter")
emaLength = input(50, "EMA Length")
emaTimeFrame = input("60", "EMA Time Frame")
tradeMode = input("Both", "Trade Mode", options=["Long Only", "Short Only", "Both"])
useSecondarySL = input(false, "Use Secondary Stop Loss")
slPercentage = input(5.0, "Stop Loss Percentage (%)")

// WaveTrend Indicator Calculations
ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
wt1 = tci
wt2 = sma(wt1, 4)

// EMA Calculation with Selected Time Frame
getEma(timeFrame) =>
    security(syminfo.tickerid, timeFrame, ema(close, emaLength))

emaFilter = getEma(emaTimeFrame)

// Secondary Stop Loss Calculation
longStopPrice = strategy.position_avg_price * (1 - slPercentage / 100)
shortStopPrice = strategy.position_avg_price * (1 + slPercentage / 100)

// Long Entry and Exit Conditions with EMA Filter and Trade Mode
longEntry = crossover(wt1, wt2) and wt2 < osLevel1 and (not useEmaFilter or close > emaFilter) and (tradeMode == "Long Only" or tradeMode == "Both")
if (longEntry)
    strategy.entry("Long", strategy.long)
longExit = crossunder(wt1, wt2) and wt2 > obLevel1
if (longExit)
    strategy.close("Long")
if (useSecondarySL and strategy.position_size > 0 and low < longStopPrice)
    strategy.close("Long", comment="SL Hit")

// Short Entry and Exit Conditions with EMA Filter and Trade Mode
shortEntry = crossunder(wt1, wt2) and wt2 > obLevel1 and (not useEmaFilter or close < emaFilter) and (tradeMode == "Short Only" or tradeMode == "Both")
if (shortEntry)
    strategy.entry("Short", strategy.short)
shortExit = crossover(wt1, wt2) and wt2 < osLevel1
if (shortExit)
    strategy.close("Short")
if (useSecondarySL and strategy.position_size < 0 and high > shortStopPrice)
    strategy.close("Short", comment="SL Hit")

// Plotting
plot(0, color=color.gray)
plot(obLevel1, color=color.red)
plot(osLevel1, color=color.green)
plot(obLevel2, color=color.red, style=plot.style_cross)
plot(osLevel2, color=color.green, style=plot.style_cross)
plot(wt1, color=color.green)
plot(wt2, color=color.red, style=plot.style_cross)
plot(wt1-wt2, color=color.blue, style=plot.style_area, transp=80)
plot(emaFilter, color=color.blue)



もっと