This strategy uses the Exponential Moving Average (EMA) and Awesome Oscillator (AO) to determine the market trend direction and utilizes candlestick patterns to confirm buy signals. When the EMA indicates an upward market trend, the AO is positive, and a bullish engulfing pattern appears, the strategy generates a buy signal. This strategy only takes long positions and does not short sell. Additionally, the strategy sets a stop-loss point to manage risk.
The core principle of this strategy is to use the EMA and AO indicators to determine the market trend direction and utilize candlestick patterns to confirm buy signals. Specifically:
This strategy uses EMA, AO, and candlestick patterns to determine trends and generate trading signals. It has the characteristics of clear logic and easy implementation. At the same time, the strategy sets a stop-loss point to control risk. However, this strategy also has some limitations, such as only being suitable for trending markets and being sensitive to parameter selection. In the future, the strategy’s performance can be further improved by adding more technical indicators, optimizing the stop-loss strategy, introducing position sizing, and other methods.
/*backtest start: 2023-05-23 00:00:00 end: 2024-05-28 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA & K-Pattern Trend Trading (Long Only)", overlay=true) // 输入参数 emaLength = input.int(50, title="EMA长度") aoShortLength = input.int(5, title="AO短期长度") aoLongLength = input.int(34, title="AO长期长度") stopLossPct = input.float(2, title="止损百分比") / 100 // 止损百分比 // 计算EMA和AO指标 ema = ta.ema(close, emaLength) ao = ta.sma(high, aoShortLength) - ta.sma(low, aoLongLength) // 定义趋势方向 isBullish = close > ema // 定义K线形态 bullishK = close > open and close[1] < open[1] and open < close[1] and close > high[1] // 看涨吞没形态 // 定义买入信号 longCondition = bullishK and isBullish and ao > 0 // 绘制EMA plot(ema, title="EMA", color=color.blue) // 计算止损点 stopLossLevelLong = close * (1 - stopLossPct) // 策略执行并标注信号 if (longCondition) strategy.entry("做多", strategy.long) label.new(bar_index, high, text="买入", style=label.style_label_up, color=color.green, textcolor=color.white) strategy.exit("止损", from_entry="做多", stop=stopLossLevelLong)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6