月相に基づくビットコイン取引戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-15 12:31:06
タグ:

img

概要

この戦略は,RSI,MACD,OBVなどの指標と組み合わせて,月の相周期を取引信号として利用し,ビットコインなどの仮想通貨の取引機会を特定する.この戦略の主要な利点は,技術指標のみに依存するほとんどの戦略とは異なり,外的要因である月の相を取引トリガーとして利用することで,ある程度市場操作を回避することができます.

戦略の論理

この戦略の主な論理は,月の相周期の異なる段階に基づいて,長期または短期的な機会を決定することです.月相は以下のように計算されます.

月相周期長さ = 29.5305882 日 その満月から現在の時間までの日数を計算できます
月齢 = 既知の満月の日から数日 % 月相周期長さ 月相値 = (1 + cos(月齢/月相周期長さ * 2 * π)) / 2

月相値は0~1の間で変動する.値が大きいほど満月に近い,より小さい値が新月に近いという意味です.

この戦略は,月相の値に基づいて,長または短の機会を判断する.月相値が長値 (デフォルト0.51) より大きい場合,ロングに行くチャンスがあります.月相値が短値 (デフォルト0.49) より小さい場合,ショートに行くチャンスがあります.

さらに,この戦略は,不利な状況下で取引信号を避けるために,取引量,RSI,MACDなどの指標を組み合わせます. 取引量が急上昇し,RSIとMACD信号が一致するときにのみポジションを開きます.

利点分析

この戦略の主な利点は:

  1. 独特の月相取引信号を利用し,ある程度市場操作を避ける
  2. 市場状況を判断するために指標を組み合わせ,不利な環境での取引を避ける
  3. 合理的なポジションサイズを計算するために ATR を使用し,取引毎の最大損失を効果的に制御する
  4. 巨額の損失を防ぐために引き下げストップ損失を設定します
  5. OBVで資金の流れの方向を判断し,トレンドに反する取引を避ける
  6. 利益をロックするために後続ストップ損失を設定します

要するに,この戦略は月相のユニークな利点を充分利用し,複数の技術指標を組み合わせて,高い確率の取引機会を特定し,同時にリスク管理メカニズムを利用して取引リスクを効果的に定義します.

リスク分析

この戦略の主なリスクは以下のとおりです.

  1. 月相と市場の動きは 時々失敗する可能性があります
  2. 不適切な引き上げストップ損失は,戦略を早めに停止させる可能性があります.
  3. MACD,RSIからの誤った信号の確率
  4. 不適切なストップ損失は,戦略がより大きな利益を見逃す可能性があります.

これらのリスクを制御するために,次の措置が講じられます.

  1. 月相の値を調整し,有効な月信号を確保する
  2. 複数の引き下げストップ損失パラメータをテストし,最適を選択
  3. 効率的な信号生成のためにMACDとRSIパラメータを調整する
  4. 最大利益を得るため,複数のセットのストップ損失パラメータをテストする.

パラメータの最適化と指標の組み合わせによって,取引リスクは大幅に軽減できます.

オプティマイゼーションの方向性

この戦略をさらに最適化できる余地があります.

  1. 適正な限界値を見つけるために異なる月のパラメータをテストします
  2. 複数の指標を組み合わせることで 効率を向上させてください
  3. ストップ・ロスのメカニズムのパラメータを最適化し,リスクと収益をバランスさせる
  4. 一般化能力をテストするために,より多くの取引資産に拡大

結論

この戦略は,メインストリーム技術指標と組み合わせたユニークな月相取引信号を通じて効率的なビットコイン取引を実現する.単一指標戦略と比較して,この戦略は市場操作リスクに対してより良くヘッジすることができ,ユニークな利点があります.リスクを防ぐストップロスを活用し,パラメータの最適化により,安定して安定した良いリターンを得ることができます.この戦略の改善にはまだ大きな余地があり,有望な応用見通しがあります.


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

//@version=5
strategy("Lunar Phase Strategy by Symphoenix", overlay=true)

// Input parameters
start_year = input(2023, title="Start year")
end_year = input(2023, title="End year")
longPhaseThreshold = input(0.51, title="Long Phase Threshold")
shortPhaseThreshold = input(0.49, title="Short Phase Threshold")
riskPerTrade = input(0.05, title="Risk Per Trade (as a % of Equity)")
stopLossPerc = input(0.01, title="Stop Loss Percentage")
atrLength = input(21, title="ATR Length for Volatility")
trailPerc = input(0.1, title="Trailing Stop Percentage")
maxDrawdownPerc = input(0.1, title="Maximum Drawdown Percentage")
volumeLength = input(7, title="Volume MA Length")

// Constants for lunar phase calculation and ATR
atr = ta.atr(atrLength)
volMA = ta.sma(volume, volumeLength) // Volume moving average

// Improved Lunar Phase Calculation
calculateLunarPhase() =>
    moonCycleLength = 29.5305882
    daysSinceKnownFullMoon = (time - timestamp("2019-12-12T05:12:00")) / (24 * 60 * 60 * 1000)
    lunarAge = daysSinceKnownFullMoon % moonCycleLength
    phase = ((1 + math.cos(lunarAge / moonCycleLength * 2 * math.pi)) / 2)
    phase

lunarPhase = calculateLunarPhase()

// Advanced Volume Analysis
priceChange = ta.change(close)
obv = ta.cum(priceChange > 0 ? volume : priceChange < 0 ? -volume : 0)

// Additional Technical Indicators
rsi = ta.rsi(close, 14)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)

// Calculate Position Size based on Volatility and Account Equity
calculatePositionSize() =>
    equity = strategy.equity
    riskAmount = equity * riskPerTrade
    positionSize = riskAmount / atr
    if positionSize > 1000000000000
        positionSize := 1000000000000
    positionSize

positionSize = calculatePositionSize()

// Maximum Drawdown Tracking
var float maxPortfolioValue = na
maxPortfolioValue := math.max(maxPortfolioValue, strategy.equity)
drawdown = (maxPortfolioValue - strategy.equity) / maxPortfolioValue

// Check for maximum drawdown
if drawdown > maxDrawdownPerc
    strategy.close_all()
    strategy.cancel_all()

// Volume Analysis
isVolumeConfirmed = volume > volMA

// Date Check for Backtesting Period
isWithinBacktestPeriod = year >= start_year and year <= end_year

// Entry and Exit Conditions
// Adjusted Entry and Exit Conditions
longCondition = lunarPhase > longPhaseThreshold and lunarPhase < 0.999 and isVolumeConfirmed and obv > obv[1] and rsi < 70 and macdLine > signalLine and isWithinBacktestPeriod
shortCondition = lunarPhase < shortPhaseThreshold and lunarPhase > 0.001 and isVolumeConfirmed and obv < obv[1] and rsi > 30 and macdLine < signalLine and isWithinBacktestPeriod

if longCondition
    if strategy.position_size < 0
        strategy.close_all()
    if strategy.position_size < positionSize
        strategy.entry("Long", strategy.long, qty=positionSize)
        strategy.exit("Exit Long", "Long", trail_offset=atr * trailPerc, trail_points=atr)

if shortCondition
    if strategy.position_size > 0
        strategy.close_all()
    if strategy.position_size > -positionSize
        strategy.entry("Short", strategy.short, qty=positionSize)
        strategy.exit("Exit Short", "Short", trail_offset=atr * trailPerc, trail_points=atr)

// Implementing Stop-Loss Logic
longStopLoss = strategy.position_avg_price * (1 - stopLossPerc)
shortStopLoss = strategy.position_avg_price * (1 + stopLossPerc)

if strategy.position_size > 0 and close < longStopLoss
    strategy.close("Long")

if strategy.position_size < 0 and close > shortStopLoss
    strategy.close("Short")


もっと