To backtest the lunar phase trading strategy against BTC, ETH, SOL, and other altcoins, we need structured historical data, clear entry/exit rules, and performance metrics. Below is a step-by-step guide to conducting a robust backtest.
Step 1: Data Collection
Required Data
-
Historical Price Data (Daily & Hourly)
-
Lunar Phase Dates
-
Technical Indicators
- EMA (50, 200)
- RSI (14-period)
- Bollinger Bands (20,2)
Step 2: Define Backtest Rules
Entry Conditions
| Lunar Phase | Bias | Entry Signal |
|---|
| New Moon | Bullish | Price > 50 EMA, RSI < 70, Bullish candle pattern |
| Full Moon | Bearish | Price < 200 EMA, RSI > 30, Bearish candle pattern |
| First/Last Quarter | Neutral | Bollinger Band squeeze (BB Width < 1.2) |
Exit Conditions
- Take Profit (TP): 2:1 or 3:1 risk-reward
- Stop Loss (SL): 2% below entry (long) / 2% above entry (short)
- Time Exit: Close trade after 3 days if TP/SL not hit
Step 3: Backtesting Methodology
Tools for Backtesting
-
Python (Best for Custom Analysis)
- Libraries:
pandas (Data handling)
ccxt (Fetch historical data)
backtrader or vectorbt (Backtesting framework)
- Example script:
import pandas as pd
import vectorbt as vbt
# Load BTC data
btc_data = pd.read_csv('BTC-USD-1h.csv', parse_dates=['timestamp'])
btc_data.set_index('timestamp', inplace=True)
# Define strategy
entries = (btc_data['close'] > btc_data['ema_50']) & (btc_data['rsi'] < 70)
exits = (btc_data['close'] >= btc_data['close'] * 1.02) # 2% TP
# Run backtest
pf = vbt.Portfolio.from_signals(btc_data['close'], entries, exits, fees=0.001)
pf.stats()
-
TradingView (Manual Backtesting)
- Use Strategy Tester with Pine Script.
- Example Pine Script:
//@version=5
strategy("Lunar Phase Strategy", overlay=true)
// Lunar phase detection (simplified)
isNewMoon = month == 1 and dayofmonth == 1 // Example: Jan 1 = New Moon
isFullMoon = month == 1 and dayofmonth == 15 // Example: Jan 15 = Full Moon
// Entry conditions
longCondition = isNewMoon and close > ta.ema(close, 50) and ta.rsi(close, 14) < 70
shortCondition = isFullMoon and close < ta.ema(close, 200) and ta.rsi(close, 14) > 30
// Execute trades
strategy.entry("Long", strategy.long, when=longCondition)
strategy.entry("Short", strategy.short, when=shortCondition)
// Exit conditions
strategy.exit("TP/SL", "Long", profit=2, loss=1) // 2:1 RR
strategy.exit("TP/SL", "Short", profit=2, loss=1)
-
Excel/Google Sheets (For Manual Checks)
- Download historical data + lunar phases.
- Apply filters for entry/exit signals.
Step 4: Performance Metrics
| Metric | Formula | Target |
|---|
| Win Rate | (Winning Trades / Total Trades) | >55% |
| Risk-Reward Ratio | (Avg Profit / Avg Loss) | ≥2:1 |
| Sharpe Ratio | (Return - Risk-Free Rate) / Volatility | >1.5 |
| Max Drawdown | Largest peak-to-trough decline | <20% |
| Profit Factor | (Gross Profit / Gross Loss) | >1.5 |
Step 5: Expected Results (Hypothetical)
| Coin | Win Rate | Avg Return per Trade | Max Drawdown |
|---|
| BTC | 58% | +3.2% | -12% |
| ETH | 56% | +2.8% | -15% |
| SOL | 60% | +4.1% | -18% |
| AVAX | 54% | +2.5% | -20% |
(Note: These are hypothetical results; real backtesting may vary.)
Step 6: Optimizing the Strategy
- Adjust Timeframes (Test 4H vs. 1D vs. Weekly).
- Tweak Indicators (Try EMA 100 instead of 50).
- Add Filters (Only trade when volume > 20% of 30-day avg).
- Walk-Forward Testing (Validate on unseen data).
Conclusion
- Lunar phases alone are not enough—combine with technicals for edge.
- BTC & ETH likely perform best due to higher liquidity.
- Altcoins (SOL, AVAX) may have higher returns but higher risk.
- Always use strict risk management (1-2% per trade).
Next Steps:
✅ Run backtests on BTC (2018-2024) to validate.
✅ Compare against buy-and-hold benchmark.
✅ Refine entry/exit rules for higher win rate.
Would you like a sample backtest report for BTC? 🚀