
この策略は,高氏分布の考え方を適用し,ヘークリーの10周期指数移動平均に基づいてZ値を計算し,そのZ値の20周期指数移動平均に値を設定し,曲線を通過する状況に応じて,ポジションを建てるか平仓を判断する.
ヘイクリーの閉盘価格の10周期指数移動平均を計算する.
上記の移動平均データに基づいて,25周期間のZ値を計算する。Z値は,データの平均値からの偏差の標準差を反映し,データが正常か異常かを判断する。
Z値の20周期指数移動平均は再び計算され,曲線emaScoreが得られる.この曲線は,Z値の長期的傾向を反映する.
emaScoreデータ分布の状況に応じて,上下値を設定する.曲線が一定波動することを考慮して,ここで分布の90%と10%のデータを値として選択する.
emaScoreで中線や下位を突破するときは,多めに;emaScoreの下位,下位,または100サイクル内の最高点を突破するときは,空っぽに.
ゴース分布の考え方を適用し,Z値によって常態性を判断し,偽突破をフィルターすることができる.
双層フィルター,exeScore曲線を操作し,長期トレンドを判断するEXTENSIVE511.
合理的な値を設定し,誤った取引の確率を減らす.
百回転の最高・最低点を組み合わせて,逆転のチャンスを掴むことができる.
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")