
이 전략은 이동 평균을 기반으로 한 트렌드 추적 거래 전략이다. 14일 간단한 이동 평균을 사용하여 시장의 추세를 판단하고 가격이 이동 평균에 가까워지면 구매 또는 판매한다.
이 전략의 핵심 논리는 다음과 같습니다.
이 전략은 트렌드 추적 전략에 속하며, 이동 평균을 통해 시장의 전반적인 움직임을 판단하고, 과매매 시점에 개입하고, 큰 추세에 따라 중지 손실을 실행한다.
이 전략의 주요 장점은 다음과 같습니다.
이 전략에는 몇 가지 위험도 있습니다.
일부 위험을 피할 수 있는 방법은 적절한 입시 조건의 완화, 스톱 로즈 위치의 조정 등이다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
이 전략은 전체적으로 간단하고 실용적인 트렌드 추적 전략이다. 이동 평균을 사용하여 트렌드 방향을 판단하고, 오버셀 포인트에서 개입하고, 합리적인 스톱 로스를 설정하여 위험을 효과적으로 제어할 수 있다. 특정 최적화 및 조합을 통해 더 많은 시장 상황에 적응할 수 있으며, 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.
/*backtest
start: 2024-01-26 00:00:00
end: 2024-02-25 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estrategia MA - mejor", overlay=true)
// Parámetros de la estrategia
initialCapital = 1000 // Inversión inicial
riskPerTrade = 0.02 // Riesgo por operación (2% del capital por operación)
lengthMA = 14 // Período de la media móvil
pipValue = 20 / 10 // Valor de un pip (30 euros / 10 pips)
// Apalancamiento
leverage = 10
// Cálculo de la media móvil en el marco temporal de 30 minutos
ma = request.security(syminfo.tickerid, "30", ta.sma(close, lengthMA))
// Condiciones de Entrada en Sobreventa
entryCondition = close < ma * 0.99 // Ejemplo: 1% por debajo de la MA
// Lógica de entrada y salida
if entryCondition
riskAmount = initialCapital * riskPerTrade // Cantidad de euros a arriesgar por operación
size = 1 // Tamaño de la posición con apalancamiento
strategy.entry("Long", strategy.long, qty=size)
stopLossPrice = close - (10 * pipValue / size)
takeProfitPrice = close + (60 * pipValue / size)
strategy.exit("Exit Long", "Long", stop=stopLossPrice, limit=takeProfitPrice)
// Gráficos
plot(ma, color=color.blue, title="Media Móvil")
plotshape(series=entryCondition, title="Entrada en Sobreventa", location=location.belowbar, color=color.green, style=shape.labelup, text="↑ Compra")