This strategy employs a dual moving average system for trend determination and trading decisions, utilizing the relative position of fast and slow exponential moving averages (EMAs) at specific time points to identify trend initiation, continuation, or termination. The strategy checks the relationship between fast and slow EMAs at a fixed time daily, establishing long positions when the fast line is above the slow line and short positions when it’s below.
The core of the strategy is based on two EMAs with different periods for trend determination. The fast EMA (default period 10) is more sensitive to price changes, capable of capturing market movements quickly; the slow EMA (default period 50) reflects longer-term trends. The strategy checks the position relationship between these two lines at a specified time each trading day (default 9:00), using EMA crossover signals to determine market trend direction and execute trades. A long position is entered when the fast EMA crosses above the slow EMA, indicating strengthening upward momentum, while a short position is entered when the fast EMA crosses below the slow EMA, indicating strengthening downward momentum.
The strategy achieves a simple yet effective trend-following trading system by combining a dual EMA system with fixed-time check mechanisms. Its strengths lie in clear logic and high automation, though it faces limitations from moving average lag and fixed entry timing. There remains significant room for improvement through the introduction of additional technical indicators, optimization of parameter selection mechanisms, and enhanced risk control measures. Overall, this represents a practical basic strategy framework that can be further refined and optimized according to specific requirements.
/*backtest start: 2024-12-06 00:00:00 end: 2025-01-04 08:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Daily EMA Comparison Strategy", shorttitle="Daily EMA cros Comparison", overlay=true) //------------------------------------------------------------------------------ // Inputs //------------------------------------------------------------------------------ fastEmaLength = input.int(10, title="Fast EMA Length", minval=1) // Fast EMA period slowEmaLength = input.int(50, title="Slow EMA Length", minval=1) // Slow EMA period checkHour = input.int(9, title="Check Hour (24h format)", minval=0, maxval=23) // Hour to check checkMinute = input.int(0, title="Check Minute", minval=0, maxval=59) // Minute to check //------------------------------------------------------------------------------ // EMA Calculation //------------------------------------------------------------------------------ fastEMA = ta.ema(close, fastEmaLength) slowEMA = ta.ema(close, slowEmaLength) //------------------------------------------------------------------------------ // Time Check //------------------------------------------------------------------------------ // Get the current bar's time in the exchange's timezone currentTime = timestamp("GMT-0", year, month, dayofmonth, checkHour, checkMinute) // Check if the bar's time equals or passes the daily check time isCheckTime = (time >= currentTime and time < currentTime + 60 * 1000) // 1-minute tolerance //------------------------------------------------------------------------------ // Entry Conditions //------------------------------------------------------------------------------ // Buy if Fast EMA is above Slow EMA at the specified time buyCondition = isCheckTime and fastEMA > slowEMA // Sell if Fast EMA is below Slow EMA at the specified time sellCondition = isCheckTime and fastEMA < slowEMA //------------------------------------------------------------------------------ // Strategy Execution //------------------------------------------------------------------------------ // Enter Long if buyCondition strategy.entry("Long", strategy.long) // Enter Short if sellCondition strategy.entry("Short", strategy.short) //------------------------------------------------------------------------------ // Plot EMAs //------------------------------------------------------------------------------ plot(fastEMA, color=color.blue, title="Fast EMA") plot(slowEMA, color=color.orange, title="Slow EMA")