This strategy combines the 8-period and 21-period Exponential Moving Averages (EMAs) with the Parabolic SAR indicator to capture trends and manage risk. The strategy aims to open and close positions based on specific crossover and price action conditions, with defined exit rules including a fixed stop-loss and a mandatory exit at a specific time.
The strategy uses two EMAs with different periods (8-period and 21-period) and the Parabolic SAR indicator to determine entry and exit conditions. When the short-term EMA crosses above the long-term EMA and the closing price is above the SAR, the strategy opens a long position. When the short-term EMA crosses below the long-term EMA and the closing price is below the SAR, the strategy opens a short position. Long positions are closed when the closing price falls below the SAR, while short positions are closed when the closing price rises above the SAR. The strategy also sets a fixed stop-loss in points to control the risk of each trade. Additionally, the strategy requires all positions to be closed at 15:15 on each trading day.
The EMA and Parabolic SAR Combination Strategy attempts to capture trends and control risk by combining two commonly used technical indicators. The strategy is simple and easy to understand, making it suitable for beginners to learn and use. However, the strategy also has some limitations, such as insufficient adaptability to market volatility and a lack of consideration for market sentiment and fundamental factors. Therefore, in practical applications, the strategy needs to be optimized and improved based on specific markets and trading instruments to enhance its stability and profitability.
/*backtest start: 2024-05-01 00:00:00 end: 2024-05-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA and Parabolic SAR Strategy", overlay=true) // Input parameters for EMAs and Parabolic SAR emaShortPeriod = input.int(8, title="Short EMA Period") emaLongPeriod = input.int(21, title="Long EMA Period") sarStart = input.float(0.02, title="Parabolic SAR Start") sarIncrement = input.float(0.02, title="Parabolic SAR Increment") sarMaximum = input.float(0.2, title="Parabolic SAR Maximum") fixedSL = input.int(83, title="Fixed Stop Loss (pts)") // Calculate EMAs and Parabolic SAR emaShort = ta.ema(close, emaShortPeriod) emaLong = ta.ema(close, emaLongPeriod) sar = ta.sar(sarStart, sarIncrement, sarMaximum) // Entry conditions longCondition = ta.crossover(emaShort, emaLong) and close > sar shortCondition = ta.crossunder(emaShort, emaLong) and close < sar // Exit conditions longExitCondition = close < sar shortExitCondition = close > sar // Strategy entry and exit if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short) if (longExitCondition) strategy.close("Long") if (shortExitCondition) strategy.close("Short") // Fixed Stop Loss strategy.exit("Long Exit", "Long", stop=close - fixedSL * syminfo.mintick) strategy.exit("Short Exit", "Short", stop=close + fixedSL * syminfo.mintick) // Exit all positions at 15:15 exitHour = 15 exitMinute = 15 exitTime = timestamp(year(timenow), month(timenow), dayofmonth(timenow), exitHour, exitMinute) if (timenow >= exitTime) strategy.close_all() // Plot EMAs and Parabolic SAR plot(emaShort, color=color.blue, title="8 EMA") plot(emaLong, color=color.red, title="21 EMA") plot(sar, style=plot.style_cross, color=color.green, title="Parabolic SAR")