
이 전략은 특정 주식이나 디지털 화폐에서 잠재적인 돌파 기회를 찾기 위해 쌍평선 시스템을 사용합니다. 기본 원칙은 단기평선이 장기평선에서 아래로 회수 할 때 주식이나 디지털 화폐를 구입하는 것입니다. 가격이 장기평선을 다시 테스트 할 때 주식이나 디지털 화폐를 판매하는 것입니다.
이 전략은 두 개의 다른 주기의 간단한 이동 평균 ((SMA) 을 거래 신호로 사용한다. 첫 번째 SMA 주기는 길고, 전체적인 경향 방향을 나타낸다. 두 번째 SMA 주기는 짧고, 단기 가격 변동을 포착하기 위해 사용된다.
단기 SMA가 아래에서 장기 SMA를 입었을 때, 가격은 전체적으로 상승 추세에 있음을 나타냅니다. 따라서 전략은 다단계 포지션을 열습니다. 가격이 떨어지면 장기 SMA를 다시 테스트하면 단기 pullback이 끝나는 것을 예고합니다. 이 때 전략은 손실을 중지하거나 이익을 취하고 포지션을 종료합니다.
또한, 전략은 극단적인 경우의 거래를 피하기 위해 과매매와 과매매 조건을 설정합니다. 쌍평평선 교차와 합리적인 가치 조건이 동시에 충족되면만 포지션을 열 수 있습니다.
이 전략에는 더 많은 최적화 가능성이 있습니다:
이 전략은 트렌드 추적과 리 거래의 장점을 통합하고, 쌍평선 시스템을 사용하여 기회의 출현을 판단한다. 동시에, 특정 과매매 과매매 조건을 내장하여 불필요한 포지션을 열 수 있다. 이것은 매우 실용적인 양적 거래 전략이며, 깊이 연구하고 최적화할 가치가 있다.
/*backtest
start: 2023-02-20 00:00:00
end: 2024-02-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=5
strategy("Profitable Pullback Trading Strategy", overlay=true,initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Inputs
ma_length1 = input.int(280,'MA length 1', step = 10,group = 'Moving Avg. Parameters', inline = 'MA')
ma_length2 = input.int(13,'MA length 2', step = 1,group = 'Moving Avg. Parameters', inline = 'MA')
sl = input.float(title="Stop Loss (%)", defval=0.07, step=0.1, group="Moving Avg. Parameters")
too_deep = input.float(title="Too Deep (%)", defval=0.27, step=0.01, group="Too Deep and Thin conditions", inline = 'Too')
too_thin = input.float(title="Too Thin (%)", defval=0.03, step=0.01, group="Too Deep and Thin conditions", inline = 'Too')
// Calculations
ma1 = ta.sma(close,ma_length1)
ma2 = ta.sma(close,ma_length2)
too_deep2 = (ma2/ma1-1) < too_deep
too_thin2 = (ma2/ma1-1) > too_thin
// Entry and close condtions
var float buy_price = 0
buy_condition = (close > ma1) and (close < ma2) and strategy.position_size == 0 and too_deep2 and too_thin2
close_condition1 = (close > ma2) and strategy.position_size > 0 and (close < low[1])
stop_distance = strategy.position_size > 0 ? ((buy_price - close) / close) : na
close_condition2 = strategy.position_size > 0 and stop_distance > sl
stop_price = strategy.position_size > 0 ? buy_price - (buy_price * sl) : na
// Entry and close orders
if buy_condition
strategy.entry('Long',strategy.long)
if buy_condition[1]
buy_price := open
if close_condition1 or close_condition2
strategy.close('Long',comment="Exit" + (close_condition2 ? "SL=true" : ""))
buy_price := na
plot(ma1,color = color.blue)
plot(ma2,color = color.orange)