
이 전략은 거래 신호로 달의 위상 주기를 기반으로 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")