トレンド振動ターニングポイントシステム


作成日: 2023-10-23 17:18:28 最終変更日: 2023-10-23 17:18:28
コピー: 0 クリック数: 744
1
フォロー
1617
フォロワー

トレンド振動ターニングポイントシステム

概要

トレンド・シェイクター・ターニング・ポイント・システムは,移動平均,CCI指数,超トレンド指数を用いてトレンドを識別し,逆戻り時に入場するトレンド追跡戦略である.それはトレンドの方向を確認し,逆戻り時に入場シグナルを提供する.

戦略原則

この戦略は,21周期のEMAを短期移動平均として,55周期のEMAを長期移動平均として使用する. 55日EMAの上の21日EMAは,現在上昇傾向にあることを示し,55日EMAの下の21日EMAは,現在下降傾向にあることを示している.

CCI指標は,価格が極端なレベルに達しているかどうかを示すことができます.CCIがデフォルトの100または-100に達すると,レベル1の信号,140/-140はレベル2の信号,180/-180はレベル3の信号になります.これは,現在,オーバーバイまたはオーバーセール状態にあることを示しています.

超トレンド指数は,特定のトレンドの方向を判断することができる.それは,平均実際の波動幅を組み合わせて,上昇傾向と下降傾向のストップポイントとエントリーポイントを判断する.

21日EMAが55日EMAより上であり,CCIが低位に達したときに,多入場を行うことができます. 21日EMAが55日EMAより下であり,CCIが高位に達したときに,空き入場を行うことができます. 入場後のストップロスはスーパートレンド指標のストップロスとして設定され,ストップロスは固定400ポイントの利益として設定されます.

優位分析

この戦略は,複数の指標を組み合わせてトレンドを判断し,超買い超売り状況を効果的にフィルターし,偽の突破を行うことができます.固定ストップを使用すると,安定したリスクと報酬の比率を得ることができます.トレンドの取引に従うことで,高い勝率を得ることができます.CCI指標の超買い超売り信号を利用すると,トレンドの揺れ期により良い入場機会を得ることができます.

リスク分析

この戦略は,取引品種のパラメータを最適化する必要がある.異なる品種のパラメータ設定は,戦略の効果に影響を与える.止損設定は,比較的粗放であり,異なる市場に対応して調整することはできません.固定ストップは,市場の波動程度に応じて利益・損失比率を調整することはできません.CCI指標は,偽信号を生じることがあります.トレンドの波動の強さをさらに判断し,揺れ動いているトレンドで繰り返し取引を避ける必要があります.

最適化の方向

異なる取引品種のパラメータ設定をテストし,移動平均周期,ATR周期,ATR倍数などのパラメータを最適化できます. 市場変動に対応するために,ストップをATRストップまたはトレーリングストップに変更することを検討できます. ストップを波動ストップに変更して,ATR値に基づいて目標利益を設定することをテストできます. フィルタリング条件を追加して,CCI信号が表示されたときにトレンドの強さを判断し,震動市場での被套を避けることができます. 定量的トレンドの強さを判断する指標を増加させ,誤ったトレンドの判断を避けることができます.

要約する

トレンド・ショッキング・ターニング・ポイント・システムは,移動平均,CCI指標,スーパートレンドを統合して,トレンドの方向性を認識し,トレンドが逆転したときに超買い・超売りを起こすために介入する.高い安定性と勝率を持つが,戦略のパラメータを異なる品種と市場環境に適応させるため,戦略のパラメータをさらに最適化する必要がある.全体的に,この戦略は,複数の指標を簡単に直接的に組み合わせて,トレンドの機会を捉えるため,さらなる研究と応用に値する.

ストラテジーソースコード
/*backtest
start: 2022-10-16 00:00:00
end: 2023-01-08 00:00:00
period: 1d
basePeriod: 1h
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/
// © greenmask9

//@version=4
strategy("Oath", overlay=true)

// 21 EMA
emalength = input(21, title="Short EMA")
emashort = ema(close, emalength)

// 55 EMA
emalength2 = input(55, title="Long EMA")
ema = ema(close, emalength2)

//CCI calculation and inputs
lengthcci = input(20, minval=1, title="Overbought/sold detector period")
src = input(close, title="Overbought/sold detector source")
ma = sma(src, lengthcci)
ccivalue = (src - ma) / (0.015 * dev(src, lengthcci))


//CCI plotting
ccioverbought = input(defval=100, title="Overbought level 1")
ccioverbought2 = input(defval=140, title="Overbought level 2")
ccioverbought3 = input(defval=180, title="Overbought level 3")

ccioversold = input(defval=-100, title="Oversold level 1")
ccioversold2 = input(defval=-140, title="Oversold level 2")
ccioversold3 = input(defval=-180, title="Oversold level 3")

//cciOB = (ccivalue >= ccioverbought and ccivalue < ccioverbought2)
//cciOS = (ccivalue <= ccioversold and ccivalue > ccioversold2)

//cciOB2 = (ccivalue >= ccioverbought2 and ccivalue < ccioverbought3)
//cciOS2 = (ccivalue <= ccioversold and ccivalue > ccioversold3)

//cciOB3 = (ccivalue >= ccioverbought3)
//cciOS3 = (ccivalue <= ccioversold3)

//Supertrend

length = input(title="ATR Period", type=input.integer, defval=55)
mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=5.0)
wicks = input(title="Take Wicks into Account ?", type=input.bool, defval=true)
illuminate = input(title="Illuminate Trend", type=input.bool, defval=false)

atr = mult * atr(length)

longStop = hl2 - atr
longStopPrev = nz(longStop[1], longStop)
longStop := (wicks ? low[1] : close[1]) > longStopPrev ? max(longStop, longStopPrev) : longStop

shortStop = hl2 + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := (wicks ? high[1] : close[1]) < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop

dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and (wicks ? high : close) > shortStopPrev ? 1 : dir == 1 and (wicks ? low : close) < longStopPrev ? -1 : dir

//entries
uptrend = emashort>ema and dir == 1
upsignal = ccivalue<=ccioversold and ccivalue>ccioversold2
upsignal2 = ccivalue<=ccioversold2 and ccivalue>ccioversold3
upsignal3 = ccivalue<=ccioversold3
downtrend = emashort<ema and dir == -1
downsignal = ccivalue>=ccioverbought and ccivalue<ccioverbought2
downsignal2 = ccivalue>=ccioverbought2 and ccivalue<ccioverbought3
downsignal3 = ccivalue>=ccioverbought3

//adapts to the current bar, I need to save the bars number when the condition for buy was true, static number is spread
spread = input (0.00020, title="Spread")
upstoploss = longStop - spread
downstoploss = shortStop + spread
strategy.initial_capital = 50000
ordersize=floor(strategy.initial_capital/close)
testlong = input(title="Test longs", type=input.bool, defval=true)
testshort = input(title="Test shorts", type=input.bool, defval=true)
//new
degree = input(title="Test level 1 overbought/sold levels", type=input.bool, defval=true)
degree2 = input(title="Test level 2 overbought/sold levels", type=input.bool, defval=false)
degree3 = input(title="Test level 3 overbought/sold levels", type=input.bool, defval=false)

statictarget = input(title="Use static target", type=input.bool, defval=true)
statictargetvalue = input(title="Static target in pips", type=input.integer, defval=400)

//timetrade = input(title="Open trades only withing specified time", type=input.bool, defval=true)
//timtrade = input()

//přidat možnost TP podle ATR a sl podle ATR
buy1 = uptrend and upsignal and strategy.opentrades==0 and testlong and degree
x1 = barssince (buy1)
if (buy1)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath1", strategy.long, ordersize)
        strategy.exit( "Oath1 Close", from_entry="Oath1" , profit=statictargetvalue,stop=upstoploss[x1])
 
buy2 = uptrend and upsignal2 and strategy.opentrades==0 and testlong and degree2
x2 = barssince (buy2)
if (buy2)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath2", strategy.long, ordersize)
        strategy.exit( "Oath2 Close", from_entry="Oath2" , profit=statictargetvalue,stop=upstoploss[x2])
  
buy3 = uptrend and upsignal3 and strategy.opentrades==0 and testlong and degree3
x3 = barssince (buy3)
if (buy3)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath3", strategy.long, ordersize)
        strategy.exit( "Oath3 Close", from_entry="Oath3" , profit=statictargetvalue,stop=upstoploss[x3])

sell1 = downtrend and downsignal and strategy.opentrades==0 and testshort and degree
y1 = barssince (sell1)
if (sell1)
    if (statictarget)
        strategy.entry("Oath1.s", strategy.short, ordersize)
        strategy.exit( "Oath1 Close", from_entry="Oath1.s" , profit=statictargetvalue,stop=downstoploss[y1])

sell2 = downtrend and downsignal2 and strategy.opentrades==0 and testshort and degree2
y2 = barssince (sell2)
if (sell2)
    if (statictarget)
        strategy.entry("Oath2.s", strategy.short, ordersize)
        strategy.exit( "Oath2 Close", from_entry="Oath2.s" , profit=statictargetvalue,stop=downstoploss[y2])

sell3 = downtrend and downsignal3 and strategy.opentrades==0 and testshort and degree3
y3 = barssince (sell3)
if (sell3)
    if (statictarget)
        strategy.entry("Oath3.s", strategy.short, ordersize)
        strategy.exit( "Oath3 Close", from_entry="Oath3.s" , profit=statictargetvalue,stop=downstoploss[y3])

plotshape(uptrend and upsignal and degree, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up")
plotshape(downtrend and downsignal and degree, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down")
plotshape(uptrend and upsignal2 and degree2, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up+")
plotshape(downtrend and downsignal2 and degree2, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down+")
plotshape(uptrend and upsignal3 and degree3, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up++")
plotshape(downtrend and downsignal3 and degree3, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down++")