
이 전략은 지수 이동 평균 ((EMA) 와 평균 진동 지표 ((AO) 를 기반으로 시장 추세 방향을 판단하고, K선 형태를 사용하여 구매 신호를 확인한다. EMA가 시장이 상승 추세에 있다는 것을 지시하고, AO 지표가 긍정적이며, 투기꾼이 삼켜버리는 형태가 나타나면, 전략은 구매 신호를 발생시킨다. 이 전략은 더 많이 하고, 공백을 하지 않는다. 동시에, 전략은 위험을 제어하기 위해 손해 중지 지점을 설정한다.
이 전략의 핵심 원칙은 EMA와 AO 지표를 사용하여 시장 추세 방향을 판단하고 K 선 형태를 사용하여 구매 신호를 확인하는 것입니다. 구체적으로:
이 전략은 EMA, AO 및 K 라인 형태를 통해 트렌드를 판단하고 거래 신호를 생성하며, 논리적으로 명확하고 구현하기 쉬운 특징을 가지고 있다. 동시에, 전략은 위험을 제어하기 위해 중지 지점을 설정한다. 그러나, 이 전략은 또한 일부 제한이 있다. 예를 들어, 트렌디 시장에만 적용되며, 파라미터 선택에 민감하다.
/*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)