
이 전략은 가우스 분포의 생각을 적용하여, 헤이클리 의 10주기 지수 이동 평균에 기초한 Z값을 계산하고, 그 Z값의 20주기 지수 이동 평균에 임점을 설정하고, 곡선을 통과하는 상황에 따라 포지션 구축과 평점 포지션을 판단한다.
헤이클리 매각 가격의 10주기 지수 이동 평균을 계산한다.
위의 이동 평균 데이터를 기반으로 25주기 동안의 Z값을 계산한다. Z값은 데이터의 평균값에서 벗어난 표준차를 나타내고, 데이터를 정상인지 이상인지 판단한다.
Z값의 20주기 지수 이동 평균을 다시 계산하여 곡선emaScore을 얻는다. 이 곡선은 Z값의 장기적인 경향을 반영한다.
emaScore 데이터의 분포에 따라 상하의 값을 설정한다. 곡선이 일정하게 변동할 수 있다는 점을 고려하여 분포의 90%와 10%의 데이터를 값으로 선택한다.
emaScore에 중간선이나 하위을 통과할 때, 더 많이; emaScore에 하위을 통과할 때, 하위을 통과할 때, 또는 100주기 최고점을 통과할 때, 공백을 다.
가우스 분포 사상을 적용하여 Z값을 통해 정상성을 판단하고, 가짜 돌파구를 필터링할 수 있다.
이중 필터링, exeScore 곡선을 작동하여 장기 추세를 판단합니다.
합리적인 마이너스를 설정하여 잘못된 거래의 가능성을 줄여줍니다.
100주기의 최고와 최저점을 결합하여 역전 기회를 잡을 수 있다.
Z값은 이동 평균과 조합되어 사용되며, 파라미터에 민감하여 최적화가 필요합니다.
값을 설정하는 것은 합리적인 상관관계가 있으며, 너무 넓거나 너무 좁은 것은 무효가 됩니다.
백주기의 최고 최저점은 잘못된 신호를 발생시키며, 적절한 방면 조건으로 촉발한다.
하이클리 자체는 다소 뒤쳐져 있으며, 이 전략에 적합한지를 평가해야 한다.
다른 주기들의 이동 평균을 테스트하고, Z값 파라미터를 다.
워크 포워드 분석 방법을 사용하여 자동으로 최적화 매개 변수.
표준 차이의 배수와 같은 다른 임계 설정 방법을 시도하십시오.
가장 높고 가장 낮은 점 판단 논리를 개선하여 잘못된 신호를 방지합니다.
다른 종류의 이나 전형적인 가격과 같은 하이클리 의 대안을 시도하십시오.
이 전략은 고스 분포의 생각에 기반하여, 쌍 지수 이동 평균과 동적 마이너스를 설정하여, 가격 비정상성을 효과적으로 판단하고 거래 신호를 생성한다. 주요 장점은 필터링 가능한 가짜 돌파구이며, 반전을 잡는다. 그러나 파라미터 설정과 조합 사용은 결과에 큰 영향을 미치며, 여전히 테스트 및 최적화가 계속되어 최적의 파라미터 및 조합 방법을 찾는다.
/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-02 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jensenvilhelm
// Here is an attempt to create a robust strategy for BTCUSD on a 5 minute chart
// I can't seem to get this code to work the way i want.... if you want to give it a try, please let me know -
// how it goes in comment section.
//@version=5
// Define the strategy settings
strategy("The Z-score", shorttitle="TZS", overlay=true)
// User can set the start date for the strategy
startDate = timestamp("2023 06 01")
// Heikin-Ashi Open, Close, High and Low calculation
haClose = ohlc4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(nz(haOpen, high), nz(haClose, high), high)
haLow = math.min(nz(haOpen, low), nz(haClose, low), low)
// Function to calculate the Z-Score
z_score(_series, _length) =>
_mean = ta.sma(_series, _length)
_stddev = ta.stdev(_series, _length)
(_series - _mean) / _stddev
// Compute the score and its EMA
score = z_score(ta.ema(haClose, 10), 25)
emaScore = ta.ema(score, 20)
// Calculate lower and upper thresholds using percentiles of EMA
lowerBlue = ta.percentile_linear_interpolation(emaScore, 50, 10)
upperBlue = ta.percentile_linear_interpolation(emaScore, 50, 90)
// Calculate the middle line as 50th percentile
middleLine = ta.percentile_linear_interpolation(emaScore, 50, 50)
// Plot the EMA of the score and the thresholds
plot(emaScore,"The White Line", color=color.white, linewidth=2)
plot(lowerBlue,"Lower Blue Line", linewidth=2)
plot(upperBlue, "Upper Blue Line", linewidth=2)
plot(middleLine, "Middle Yellow Line", linewidth=2, color=color.yellow)
plot(score,"The Z-Score Mixed With EMA 10", color=color.green)
// Calculate highest and lowest EMA score over 100 bars period
highest = ta.highest(emaScore, 100)
lowest = ta.lowest(emaScore, 100)
// Plot highest and lowest EMA score lines
plot(highest, "Highest of emaScore", color=color.red, linewidth=2)
plot(lowest, "Lowest of emaScore", color=color.red, linewidth=2)
// Define entry and exit conditions for long and short positions
longCon = ta.crossover(score, lowerBlue) or ta.crossover(emaScore, middleLine)
addOn = ta.crossover(score, highest)
shortCon = ta.crossunder(emaScore, upperBlue) or ta.crossunder(emaScore, lowerBlue) or ta.crossunder(emaScore, highest)
// Execute trading logic based on conditions and after the start date
if (time >= startDate)
if longCon
strategy.entry("Long", strategy.long)
if shortCon
strategy.close("Long")
if addOn
strategy.entry("LongNR2", strategy.long)
if shortCon
strategy.close("LongNR2")
if shortCon
strategy.entry("Short", strategy.short)
if longCon
strategy.close("Short")