
이 전략은 여러 이동 평균과 상대적으로 약한 지수 (RSI) 를 결합하여 거래 신호를 생성합니다. 그것은 9, 21, 25, 99 일간의 4 개의 다른 주기 이동 평균을 사용하여 그 사이의 교차로 트렌드의 방향을 판단합니다. 동시에, 이 전략은 RSI 지표를 보조 판단으로 도입하여 시장이 과매매 또는 과매매 할 때 추가 거래 신호를 제공합니다.
이 전략의 주요 아이디어는 시장의 주요 추세를 판단하기 위해 다양한 주기적인 이동 평균의 추세 특성을 활용하는 것입니다. 단기 평균이 장기 평균을 상향으로 가로질러 상승하는 것은 낙관적 신호로 간주되며 반대로 하향 신호로 간주됩니다. RSI 지표는 시장의 정서를 판단하여 시장이 과매매되거나 과매매 될 때 반전을 제공합니다.
이 전략은 다양한 주기의 이동 평균과 RSI 지표를 결합하여 트렌드 추적과 감정 판단의 거래 전략을 형성한다. 이 전략의 장점은 논리적으로 명확하고 적응력이 강하며, 다평선 조합을 통해 시장 추세를 더 잘 파악할 수 있다. 그러나 동시에 파라미터 민감성, 트렌드 식별 지연, 변동 시장의 열악한 성능과 같은 위험이 존재한다. 향후 파라미터 최적화, 신호 필터링, 포지션 관리, 스톱 로즈 등의 측면에서 개선하여 전략의 성능과 안정성을 더욱 향상시킬 수 있다.
/*backtest
start: 2023-04-24 00:00:00
end: 2024-04-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estratégia de Médias Móveis e RSI (por Svitorino_trade)", shorttitle="Estratégia-Médias Móveis", overlay=true)
len1 = input.int(9, minval=1, title="Length 1")
len2 = input.int(21, minval=1, title="Length 2")
len3 = input.int(25, minval=1, title="Length 3")
len4 = input.int(99, minval=1, title="Length 4")
rsi_length = input.int(14, minval=1, title="RSI Length")
rsi_oversold = input.float(30, minval=0, maxval=100, title="RSI Oversold Level")
rsi_overbought = input.float(70, minval=0, maxval=100, title="RSI Overbought Level")
src = input(close, title="Source")
ama(src, length) =>
sum = 0.0
for i = 0 to length - 1
sum := sum + src[i]
sum / length
avg1 = ama(src, len1)
avg2 = ama(src, len2)
avg3 = ama(src, len3)
avg4 = ama(src, len4)
rsi_value = ta.rsi(src, rsi_length)
// Condições de entrada e saída para períodos de 9 e 21
cruzamento_9_21_acima = avg1 > avg2 and avg1[1] <= avg2[1]
cruzamento_9_21_abaixo = avg1 < avg2 and avg1[1] >= avg2[1]
// Condições de entrada e saída para períodos de 25 e 99
cruzamento_25_99_acima = avg3 > avg4 and avg3[1] <= avg4[1]
cruzamento_25_99_abaixo = avg3 < avg4 and avg3[1] >= avg4[1]
// Plotando os sinais de entrada e saída
plotshape(series=cruzamento_9_21_acima, style=shape.triangleup, color=color.green, size=size.small, location=location.belowbar)
plotshape(series=cruzamento_9_21_abaixo, style=shape.triangledown, color=color.red, size=size.small, location=location.abovebar)
plotshape(series=cruzamento_25_99_acima, style=shape.triangleup, color=color.green, size=size.small, location=location.belowbar)
plotshape(series=cruzamento_25_99_abaixo, style=shape.triangledown, color=color.red, size=size.small, location=location.abovebar)
// Entradas e saídas para períodos de 9 e 21
if cruzamento_9_21_acima and rsi_value > rsi_overbought
strategy.entry("Venda Curta", strategy.short)
if cruzamento_9_21_abaixo and rsi_value < rsi_oversold
strategy.entry("Compra Curta", strategy.long)
if cruzamento_9_21_acima
strategy.close("Compra Curta")
if cruzamento_9_21_abaixo
strategy.close("Venda Curta")
// Entradas e saídas para períodos de 25 e 99
if cruzamento_25_99_acima and rsi_value > rsi_overbought
strategy.entry("Compra Forte", strategy.long)
if cruzamento_25_99_abaixo and rsi_value < rsi_oversold
strategy.entry("Venda Forte", strategy.short)
if cruzamento_25_99_acima
strategy.close("Venda Forte")
if cruzamento_25_99_abaixo
strategy.close("Compra Forte")