
This strategy is a multi-level confirmation trading system that combines EMA crossover, RSI momentum indicator, and ATR volatility indicator. The strategy uses 9-period and 21-period exponential moving averages (EMA) as the primary trend determination basis, combined with RSI for momentum confirmation and ATR for dynamic position sizing and stop-loss/take-profit placement. Through the coordination of multiple technical indicators, the strategy effectively filters false signals and improves trading reliability.
The core logic of the strategy is based on the following levels: 1. Trend Determination Layer: Uses the crossover of fast EMA (9-period) and slow EMA (21-period) to determine market trend direction. Long signals are generated when the fast line crosses above the slow line, and short signals when the fast line crosses below. 2. Momentum Confirmation Layer: Uses 14-period RSI to filter trend signals. Executes longs only when RSI is below 70 and shorts only when RSI is above 30, avoiding positions in overbought or oversold areas. 3. Risk Management Layer: Uses 14-period ATR for dynamic stop-loss and take-profit placement. Stop-loss is set at 1.5x ATR and take-profit at 3x ATR, ensuring a good risk-reward ratio. ATR is also used to calculate appropriate position size based on 1% account equity risk.
The strategy builds a robust trading system through the coordination of EMA crossover, RSI momentum, and ATR volatility in three dimensions. Its strengths lie in its complete multi-level confirmation mechanism and dynamic risk management system, though it may face higher risks in ranging markets. Performance can be improved through additions like market environment filtering and parameter adaptation optimization. Overall, this is a logically clear and practical trading strategy.
/*backtest
start: 2025-02-13 00:00:00
end: 2025-02-20 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("BTC Scalping Strategy", overlay=true, margin_long=100, margin_short=100, pyramiding=1)
// Inputs
emaFastLength = input.int(9, "Fast EMA Length")
emaSlowLength = input.int(21, "Slow EMA Length")
rsiLength = input.int(14, "RSI Length")
rsiOverbought = input.int(70, "RSI Overbought")
rsiOversold = input.int(30, "RSI Oversold")
atrLength = input.int(14, "ATR Length")
riskPercent = input.float(1, "Risk Percentage", step=0.5)
// Calculate Indicators
emaFast = ta.ema(close, emaFastLength)
emaSlow = ta.ema(close, emaSlowLength)
rsi = ta.rsi(close, rsiLength)
atr = ta.atr(atrLength)
// Entry Conditions
longCondition = ta.crossover(emaFast, emaSlow) and rsi < rsiOverbought
shortCondition = ta.crossunder(emaFast, emaSlow) and rsi > rsiOversold
// Exit Conditions
takeProfitLevelLong = close + (atr * 3)
stopLossLevelLong = close - (atr * 1.5)
takeProfitLevelShort = close - (atr * 3)
stopLossLevelShort = close + (atr * 1.5)
// Position Sizing
equity = strategy.equity
riskAmount = equity * (riskPercent / 100)
positionSizeLong = riskAmount / (close - stopLossLevelLong)
positionSizeShort = riskAmount / (stopLossLevelShort - close)
// Strategy Execution
if (longCondition)
strategy.entry("Long", strategy.long, qty=positionSizeLong)
strategy.exit("Exit Long", "Long", limit=takeProfitLevelLong, stop=stopLossLevelLong)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=positionSizeShort)
strategy.exit("Exit Short", "Short", limit=takeProfitLevelShort, stop=stopLossLevelShort)
// Plotting
plot(emaFast, color=color.new(color.blue, 0), linewidth=2)
plot(emaSlow, color=color.new(color.red, 0), linewidth=2)
hline(rsiOverbought, "RSI OB", color=color.new(color.red, 50))
hline(rsiOversold, "RSI OS", color=color.new(color.green, 50))
// Alerts
alertcondition(longCondition, "Long Signal", "Potential Long Entry")
alertcondition(shortCondition, "Short Signal", "Potential Short Entry")