
이 전략은 혼합된 양적 분석 방법을 사용하여 두 가지 분산 모델과 회귀 분석을 결합하여 다른 시장 상태를 식별합니다. 전략은 먼저 간단한 이동 평균 (SMA) 및 브린 밴드 (BB) 지표를 계산하고, 그 다음 역사적인 수익에 대한 평균과 표준 차이를 기반으로 Z 스코어를 계산합니다. Z 스코어가 하위 하락값보다 낮고 가격이 하락값보다 낮으면 전략은 더 많은 위치를 열고, Z 스코어가 상위 하락값보다 높고 가격이 상위 하락값보다 높으면 전략은 평소합니다.
이 전략의 핵심 원칙은 Z 점수를 사용하여 현재 수익을 역사적 수익 분포의 위치와 관련하여 측정하는 것입니다. Z 점수의 계산 공식은 다음과 같습니다. Z 점수가 높을수록 현재 수익이 극단적 인 경우 초과할 가능성이 높습니다. Z 점수가 낮을수록 현재 수익이 극단적 인 경우 초과할 가능성이 높습니다.
혼성 쌍방향 Z 점수 계량화 전략은 통계학적인 원리에 기반한 계량화 거래 전략으로, 현재 수익과 역사적 수익 분포를 비교하여 잠재적인 오버 바이 오버 셀 기회를 식별한다. 동시에, 전략은 브린 띠 지표를 사용하여 두 번 확인하여 신호 신뢰성을 향상시킨다. 전략 규칙은 명확하고, 구현 및 최적화하기 쉽지만, 또한 파라미터 민감성, 트렌드 위험, 과잉 적합성 위험과 같은 과제에 직면한다.
/*backtest
start: 2023-05-22 00:00:00
end: 2024-05-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estratégia Híbrida Quantitativa", overlay=true)
// Definição de parâmetros
sma_length = input.int(20, title="Período da SMA")
threshold_high = input.float(1.5, title="Threshold Alto")
threshold_low = input.float(-1.5, title="Threshold Baixo")
lookback_period = input.int(252, title="Período de Retorno Histórico (dias)")
// Funções auxiliares
f_sma(source, length) =>
ta.sma(source, length)
f_bollinger_band(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
[basis + dev, basis - dev]
// Cálculo dos indicadores
sma = f_sma(close, sma_length)
[upper_band, lower_band] = f_bollinger_band(close, sma_length, 2)
// Regime de Mercado: Binomial
retornos = ta.change(close, 1)
media_retornos = ta.sma(retornos, lookback_period)
desvio_padrao_retornos = ta.stdev(retornos, lookback_period)
// Indicador de Regime: Z-Score
z_score = (retornos - media_retornos) / desvio_padrao_retornos
// Sinal de Compra e Venda
sinal_compra = z_score < threshold_low and close < lower_band
sinal_venda = z_score > threshold_high and close > upper_band
// Execução de Ordem
if (sinal_compra)
strategy.entry("Long", strategy.long)
if (sinal_venda)
strategy.close("Long")
// Plotagem dos Indicadores
plot(sma, title="SMA", color=color.blue)
plot(upper_band, title="Upper Bollinger Band", color=color.red)
plot(lower_band, title="Lower Bollinger Band", color=color.green)
hline(threshold_high, "Threshold Alto", color=color.red, linestyle=hline.style_dashed)
hline(threshold_low, "Threshold Baixo", color=color.green, linestyle=hline.style_dashed)
plot(z_score, title="Z-Score", color=color.purple)