
この戦略は,取引シグナルとして月相周期をベースに,RSI,MACD,OBVなどの複数の指標を組み合わせて,ビットコインなどのデジタル通貨の取引機会を識別する.この戦略の主要な利点は,月相のこの外部要因を取引誘発シグナルとして利用することであり,技術指標のみに依存するほとんどの戦略とは異なり,市場操作を一定程度に回避することができる.
この戦略の核心的な論理は,月相周期の異なる段階に基づいて,多行または空行条件に適合するかどうかを判断することである.月相計算の公式は:
月相周期の長さ=29.5305882日 既知の満月の時間から,その満月の始まりから現在の時間までの日数を計算できます. 月相年数 = 既知の満月の日の% 月相周期の長さ 月相値= ((1 + cos ((月相年齢/月相周期長さ*2*π))/2
月の相値の大きさに基づいて,現在の月相が判断できる.月相は0から1の間で変化し,値が大きいほど満月より近いことを示し,値が小さいほど新月より近いことを示している.
策略は月相値が多値または空値条件に適合するか判断する.月相値が多値 (>0.51のデフォルト) であれば多値のチャンスがある.月相値が空値 (>0.49のデフォルト) よりも小さい場合は空値のチャンスがある.
さらに,戦略は,取引量,RSI,MACDなどの指標を組み合わせて,理想的でない状況で取引シグナルを発信することを避ける.取引量が大きくなり,RSIとMACDが条件を満たす場合にのみ,ポジションを開きます.
この戦略の利点は以下の通りです.
全体として,この戦略は,月相の独特の優位性を最大限に活用し,高確率の取引機会を識別するために複数の技術指標を併用し,リスク管理手段によって取引リスクを効果的に制御します.
この戦略には以下のリスクがあります.
これらのリスクを制御するために,以下の措置を講じることができます.
パラメータ最適化と総合指標の適用により,取引リスクを大幅に回避できます.
この戦略をさらに改善する余地がある:
この戦略は,月相に特異な取引信号を用い,主流の技術指標と連携し,高効率のビットコイン取引を実現している.単一指標戦略に比べて,この戦略は,市場操作のリスクに対してより優れた防御力を備えて,独特な優位性を持っている.リスク予防と最適化パラメータを停止することによって,安定してより良い収益を得ることができる.この戦略は,さらに向上し,大きな応用見通しがある.
/*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")