
트렌드 흔들림 전환점 시스템은 이동 평균, CCI 지표, 그리고 슈퍼 트렌드 지표를 사용하여 트렌드를 식별하고, 회전할 때 진입하는 트렌드 추적 전략이다. 그것은 트렌드 방향을 확인하고, 회전할 때 진입 신호를 제공한다.
이 전략은 21주기 EMA를 단기 이동 평균으로, 55주기 EMA를 장기 이동 평균으로 사용한다. 21일 EMA는 55일 EMA 위를 가리키며 현재 상승 추세에 있으며, 21일 EMA는 55일 EMA 아래를 가리키며 현재 하락 추세에 있다.
CCI 지표는 가격이 극단적 인 수준에 도달했는지 여부를 표시 할 수 있습니다. CCI가 기본 100 또는 -100에 도달하면 1 차 신호, 140/-140은 2 차 신호, 180/-180은 3 차 신호입니다. 이는 현재 과매도 또는 과매도 상태가 될 수 있음을 나타냅니다.
슈퍼 트렌드 지표는 특정 트렌드 방향을 판단할 수 있다. 그것은 평균 실제 변동의 폭과 결합하여 상승 추세와 하향 추세의 중지 지점과 입구를 판단한다.
21일 EMA가 55일 EMA 위에 있고, CCI가 낮은 곳에 도달했을 때, 추가 입장을 할 수 있습니다. 21일 EMA가 55일 EMA 아래 있고, CCI가 높은 곳에 도달했을 때, 현재 초상가 지역에 있음을 나타냅니다.
이 전략은 트렌드를 판단하는 여러 지표와 오버 바이 오버 세를 결합하여 가짜 브레이크를 효과적으로 필터링 할 수 있습니다. 고정 스톱을 사용하면 안정적인 리스크 수익률을 얻을 수 있습니다. 트렌드를 따르는 거래는 높은 승률을 얻을 수 있습니다. 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++")