臨時地帯戦略

作者: リン・ハーンチャオチャン開催日:2023年12月29日 17:03:27
タグ:

img

概要

トランジエントゾーン戦略は,価格変動ゾーンをベースとした短期的取引戦略である.特定の期間中に価格によって形成された変動ゾーンを使用して,市場の動向を判断し,ゾーンが突入するとポジションをとる.

戦略の論理

この戦略は,過去Nのキャンドルストイックの最高値と最低値を計算し,価格変動ゾーンを構築する.最新のキャンドルストイックはこのゾーンに浸透すると,トレンド逆転が発生したと判断し,取引信号を生成する.

特に,この戦略は,最後のN個のキャンドルスタイルの最高値と最低値 (調整可能なパラメータN) を継続的に追跡し,次の場合:

  • 最低価格 = 過去のN個のキャンドルスタイルの最低点
  • 最高価格 = 過去N個のキャンドルスタイルの最高点

これは価格変動ゾーンを構成します

最新のキャンドルスタイルの閉じる価格がゾーンの最高価格よりも高くなった場合,ゾーンが侵入されたことを示し,ロング信号を生成します.閉じる価格がゾーンの最低価格よりも低い場合,ゾーンが侵入されたことを示し,ショート信号を生成します.

また,この戦略には色とボディフィルターも組み込まれています.色フィルターはキャンドルスティックの色に基づいてシグナルをフィルターします.ボディフィルターはキャンドルスティックのサイズに基づいてシグナルをフィルターします.これはいくつかの偽信号をフィルタリングするのに役立ちます.

利点

この戦略には以下の利点があります.

  1. 価格ゾーンを把握し,正確な長/短エントリのためのトレンド逆転点を決定します.
  2. 色 と 身体 の フィルター は 偽 の 信号 を フィルタリング する
  3. シンプルで明快な戦略論理,分かりやすくパラメータを調整
  4. 多くの調整可能なパラメータにより戦略を最適化できます

リスク

この戦略にはいくつかのリスクもあります:

  1. 不適切なパラメータ設定は,過剰な取引と高い手数料を引き起こす可能性があります.
  2. 誤ったゾーン範囲の設定は,誤ったブレイクアウト信号を多く生成する可能性があります.
  3. 激しい市場変動時の価格ゾーン予測能力の低下
  4. 価格格差に対処できない

ゾーンパラメータを調整し,シグナルフィルターを最適化することで これらのリスクを軽減できます.

オプティマイゼーションの方向性

戦略はいくつかの方向で最適化することができます.

  1. 固定Nキャンドルスタイルの代わりに価格ゾーンの範囲を動的に調整します.
  2. 損失を制限するためにストップ・ロスの論理を組み込む
  3. シグナル品質を改善するためにフィルターパラメータを最適化
  4. 価格格差を処理する論理を追加
  5. 信号を判断し,罠を避けるために複数の時間枠を組み合わせる

結論

トランジエントゾーン戦略は,一般的に使いやすい短期的取引戦略である. 価格ゾーンを通じてトレンド逆転点を決定し,市場の機会を迅速に活用することができる. また,注意すべきいくつかのリスクもあります. 利潤性を高めるためにパラメータ調整と最適化によってさらなる改善ができます.


/*backtest
start: 2023-11-28 00:00:00
end: 2023-12-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy("Noro's Transient Zones Strategy v1.0", shorttitle = "TZ str 1.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)

//Settings 
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")

usecol = input(true, defval = true, title = "Use Color-Filter")
usebod = input(true, defval = true, title = "Use Body-Filter")

h_left = input(title = "H left", defval = 10)
h_right = -1
sample_period = input(title = "Sample bars for % TZ",  defval = 5000)
show_ptz = input(title = "Show PTZ", type = bool, defval = true)
show_channel = input(title = "Show channel", type = bool, defval = true)

fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//By Jurij w/ TZ percent occurrence by SPYderCrusher

//barCount = nz(barCount[1]) + 1
//check history and realtime PTZ
h_left_low = lowest(h_left)
h_left_high = highest(h_left)
newlow = low <= h_left_low
newhigh = high >= h_left_high
plotshape(newlow and show_ptz, style=shape.triangledown, location=location.belowbar, color=red)
plotshape(newhigh and show_ptz, style=shape.triangleup, location=location.abovebar, color=green)
channel_high = plot(show_channel ? h_left_low : 0, color=silver)
channel_low = plot (show_channel ? h_left_high : 0, color=silver)

//check true TZ back in history
central_bar_low = low[h_right + 1]
central_bar_high = high[h_right + 1]
full_zone_low = lowest(h_left + h_right + 1)
full_zone_high = highest(h_left + h_right + 1)
central_bar_is_highest = central_bar_high >= full_zone_high
central_bar_is_lowest = central_bar_low <= full_zone_low
plotarrow(central_bar_is_highest ? -1 : 0, offset=-h_right-1)
plotarrow(central_bar_is_lowest ? 1 : 0, offset=-h_right-1)

//Color Filter
bar = close > open ? 1 : close < open ? -1 : 0

//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false

//Signals
up1 = central_bar_is_lowest and body and (bar == -1 or usecol == false)
dn1 = central_bar_is_highest and body and (bar == 1 or usecol == false)
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body

//Trading
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 : lot[1]

if up1
    if strategy.position_size < 0
        strategy.close_all()
        
    strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if dn1
    if strategy.position_size > 0
        strategy.close_all()
        
    strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
    
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
    strategy.close_all()

もっと