ビットコイン多要素取引戦略

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

概要

これは,ビットコインおよび他の暗号通貨の15分間の取引のために設計された包括的な取引戦略である.これは,トリプル指数関数移動平均値 (TEMA),平均真数範囲 (ATR),ハイキン・アシのキャンドルを含む複数の指標を組み合わせて,利益とストップ損失などのリスク管理機能を生成する.

戦略の論理

戦略は以下の指標を利用する.

  • トリプル指数関数移動平均 (TEMA):それぞれ高値,低値,近値に基づいて,異なる長さと源を持つ3つのTEMA線.

  • 平均真差 (ATR): 波動性を測定するためのEMAスムーズ化によるカスタムATR計算.

  • 超トレンド:ATRとトレンド指向を決定する倍数を使用して計算される.

  • シンプル・ムービング・アベア (SMA): 短いTEMA線に適用され,値が平らになる.

  • ハイキン・アシ・クローズ: 傾向の追加確認に使用される.

ロングエントリー信号は,ショートTEMAが両方のロングTEMAライン以上,スーパートレンドが上昇し,ショートTEMAがSMA以上,ハイキン・アシ・ストロークが前回のストロークより高くなったときに起動します.

逆の条件を満たすときにショートエントリー信号が起動します.

収益とストップロスは,エントリー価格の1%と3%で設定されます.また,手数料も考慮されます.

利点分析

  • 精度 を 向上 さ せる 多種 の 要因 トレンド,波動,パターン指標を組み合わせることで 精度が向上し 誤った信号を回避できます

  • 合理的なストップ・ロスト/テイク・プロフィート制御リスク 利回りや損失を制限します 利回りや損失を制限します

  • 大きいパラメータ最適化空間 インディケーターのパラメータは 変化する市場に適応するために 柔軟に調整できます

  • コミッションを考慮すると より現実的になります バックテストの結果はライブパフォーマンスに近い.

リスク分析

  • 過剰な最適化による判断の誤りのリスク 過剰な指標の組み合わせも判断に誤りをもたらす可能性があります.有効性は評価する必要があります.

  • 短期取引でリスクが高い 長い時間枠と比較して 15分は突然の出来事やリスクに より敏感です

  • 戦略の安定性はさらなる検証を必要としています 信頼性を確保するために,長い歴史と市場を巡る より広範なテストが必要です.

  • 複数のパラメータで長い最適化 導入された多くのパラメータは,すべてのパラメータ組み合わせを最適化するための長いプロセスにつながります.

改善 の 方向

  • 各指標の実際の効果を評価する バックテストは,各指標の実質的な増益を検証し,冗長性を回避します.

  • 安定性を最適化しテストする テスト最適化結果は より多くの市場で 信頼性を確保します

  • ストップ・ロスの戦略を組み込む トレイリングストップやブランケットオーダーストップなどで リスクをさらにコントロールします

  • 費用 を 引き起こす より 多く の 要因 を 考慮 し て ください バックテストをライブパフォーマンスに 近づけるため

概要

この戦略は15分間のビットコイン取引に合わせた複数の指標とリスク管理技術を組み合わせている.パラメータを最適化し,指標の有効性を評価し,広範な市場安定性テストを行い,マルチファクターアプローチ内で最適な組み合わせを見つけるためにより多くの現実世界の要因を導入するために,大きな空間が残っています.継続的な最適化と検証により,暗号高周波取引のための効果的なツールになることができます.


/*backtest
start: 2023-08-25 00:00:00
end: 2023-09-09 00:00:00
period: 10m
basePeriod: 1m
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/
// © deperp
//@version=5
strategy('3kilos', shorttitle='3kilos BTC 15m', overlay=true, initial_capital=100000, max_bars_back=5000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.07, pyramiding=0)

short = input.int(50, minval=1)
srcShort = input(high, title='TEMA short')

long = input.int(100, minval=1)
srcLong = input(low, title='TEMA long 2')

long2 = input.int(350, minval=1)
srcLong2 = input(close, title='TEMA long 3')

atrLength = input.int(550, title='ATR Length', minval=1)
mult = input.float(3, title="Multiplier", minval=0.5, step=1)

smaPeriod = input.int(100, title="SMA Period", minval=1)

takeProfitPercent = input.float(1, title="Take Profit (%)", minval=0.1) / 100
stopLossPercent = input.float(3, title="Stop Loss (%)", minval=0.1) / 100


tema(src, length) =>
    ema1 = ta.ema(src, length)
    ema2 = ta.ema(ema1, length)
    ema3 = ta.ema(ema2, length)
    3 * (ema1 - ema2) + ema3

tema1 = tema(srcShort, short)
plot(tema1, color=color.new(color.red, 0), linewidth=2)

tema2 = tema(srcLong, long)
plot(tema2, color=color.new(color.blue, 0), linewidth=2)

tema3 = tema(srcLong2, long2)
plot(tema3, color=color.new(color.green, 0), linewidth=2)

// Custom ATR calculation with EMA smoothing
atr_ema(src, length) =>
    trueRange = math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
    emaTrueRange = ta.ema(trueRange, length)
    emaTrueRange

// Calculate ATR with EMA smoothing
atr = atr_ema(close, atrLength)

// Calculate Supertrend
var float up = na
var float dn = na
var bool uptrend = na
up := na(up[1]) ? hl2 - (mult * atr) : uptrend[1] ? math.max(hl2 - (mult * atr), up[1]) : hl2 - (mult * atr)
dn := na(dn[1]) ? hl2 + (mult * atr) : uptrend[1] ? hl2 + (mult * atr) : math.min(hl2 + (mult * atr), dn[1])
uptrend := na(uptrend[1]) ? true : close[1] > dn[1] ? true : close[1] < up[1] ? false : uptrend[1]

// Calculate SMA
sma = ta.sma(tema1, smaPeriod)

// Heikin-Ashi Close
haTicker = ticker.heikinashi(syminfo.tickerid)
haClose = request.security(haTicker, timeframe.period, close)


// Trend determination using Heikin-Ashi Close
longC = tema1 > tema2 and tema1 > tema3 and uptrend and tema1 > sma and haClose > haClose[1]
shortC = tema1 < tema2 and tema1 < tema3 and not uptrend and tema1 < sma and haClose < haClose[1]


alertlong = longC and not longC[1]
alertshort = shortC and not shortC[1]

useDateFilter = input.bool(true, title="Begin Backtest at Start Date",
     group="Backtest Time Period")
backtestStartDate = input(timestamp("1 Jan 2023"), 
     title="Start Date", group="Backtest Time Period",
     tooltip="This start date is in the time zone of the exchange " + 
     "where the chart's instrument trades. It doesn't use the time " + 
     "zone of the chart or of your computer.")

inTradeWindow = true

stopLossLevelLong = close - atr * mult
stopLossLevelShort = close + atr * mult
longTakeProfitLevel = close * (1 + takeProfitPercent)
longStopLossLevel = close * (1 - stopLossPercent)
shortTakeProfitLevel = close * (1 - takeProfitPercent)
shortStopLossLevel = close * (1 + stopLossPercent)



if inTradeWindow and longC
    strategy.entry('Long', strategy.long, comment='Long')
    strategy.exit("TP Long", "Long", limit=longTakeProfitLevel, stop=longStopLossLevel, comment="TP/SL Long")

if inTradeWindow and shortC
    strategy.entry('Short', strategy.short, comment='Short')
    strategy.exit("TP Short", "Short", limit=shortTakeProfitLevel, stop=shortStopLossLevel, comment="TP/SL Short")

// Alerts

alertcondition(longC, title='Long', message=' Buy Signal ')
alertcondition(shortC, title='Short', message=' Sell Signal ')

もっと