This strategy is a simple trend following strategy based on EMA crossover. It uses two EMA lines with different parameters, a short-term EMA line and a long-term EMA line. When the short-term EMA line crosses above the long-term EMA line, go long. When the short-term EMA line crosses below the long-term EMA line, close position. With stop loss and take profit to manage risk.
EMA indicator is a trend following indicator which exponentially smoothes price. The short-term EMA line responds faster to price changes, reflecting recent trend. The long-term EMA line responds slower, reflecting long term trend. When short EMA crosses above long EMA, it indicates the recent upward momentum is stronger than the long term trend, can go long. Vice versa, when short EMA crosses below long EMA, it indicates the recent downward momentum is stronger, should close long position.
This strategy sets 9 period and 21 period EMA lines. Use the crossover of 9 period short EMA and 21 period long EMA as trading signals:
Risk Solutions:
The strategy capitalizes on EMA crossover of two EMAs to follow trends. Its advantage is simple logic, medium trading frequency, catching mid-to-long term trends. However EMA has lagging effect. Adding more indicators for filtration and optimising dynamic stop loss can reduce risk further. Overall, EMA Crossover is effective from seizing mid-to-long term trends.
/*backtest start: 2023-01-25 00:00:00 end: 2024-01-31 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("EMA Crossover Strategy", overlay=true) // Input parameters shortPeriod = input(9, title="Short EMA Period") longPeriod = input(21, title="Long EMA Period") stopLossPercent = input(1, title="Stop Loss (%)") / 100 takeProfitMultiplier = input(2, title="Take Profit Multiplier") // Calculate EMAs emaShort = ema(close, shortPeriod) emaLong = ema(close, longPeriod) // Plot EMAs plot(emaShort, color=color.blue, title="Short EMA") plot(emaLong, color=color.red, title="Long EMA") // Strategy logic strategy.entry("Buy", strategy.long, when=crossover(emaShort, emaLong)) strategy.close("Buy", when=crossunder(emaShort, emaLong)) // Risk management atrValue = atr(14) stopLossLevel = close * (1 - stopLossPercent) takeProfitLevel = close * takeProfitMultiplier strategy.exit("Take Profit/Stop Loss", from_entry="Buy", loss=stopLossLevel, profit=takeProfitLevel)