
이 전략은 TEMA 지표의 다중 시간 프레임 크로스업을 기반으로 시장의 경향 방향을 식별하고, 더 낮은 시간 프레임의 TEMA 지표 크로스업을 결합하여 특정 상장 및 출장 시기를 찾습니다. 이 전략은 그냥 더하고, 그냥 공백하거나 양방향 거래를 할 수 있습니다.
전략은 두 개의 TEMA 지표, 5과 15주기 빠른 느린 선을 기반으로 한 하나, 그리고 일선이나 주위선과 같은 사용자 지정된 고주기 시간 프레임에 기반한 다른 것을 사용합니다. 높은 주기 TEMA 지표는 전체적인 트렌드 방향을 결정하고, 빠른 선에서 느린 선을 통과 할 때 위세를 보며, 하향으로 내려가며, 낮은 주기 TEMA 지표는 특정 진입 및 출구 시기를 찾기 위해 사용됩니다.
고주기 TEMA 단선에서 느린 선을 통과하면, 저주기 TEMA 단선에서 느린 선을 통과하면 더 많은 진출이 가능하며, 저주기 TEMA 단선에서 느린 선을 통과하면 출전해야 한다. 마찬가지로, 고주기 TEMA 단선에서 느린 선을 통과하면, 저주기 TEMA 단선에서 느린 선을 통과하면 진출이 가능하며, 빠른 선에서 느린 선을 통과하면 출전해야 한다.
위험 해결 방법:
이 전략의 전체적인 개념은 명확하고 이해하기 쉽으며, TEMA 지표의 다중 시간 프레임 크로스 기준으로 트렌드 방향을 판단하고, 낮은 주기 크로스와 결합하여 진입 시기를 찾습니다. 특정 장점이 있지만, 일부 개선의 여지가 있습니다.
/*backtest
start: 2023-01-01 00:00:00
end: 2023-12-24 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/
// © Seltzer_
//@version=4
strategy(title="TEMA Cross +HTF Backtest", shorttitle="TEMA_X_+HTF_BT", overlay=true)
orderType = input("Longs+Shorts",title="What type of Orders", options=["Longs+Shorts","LongsOnly","ShortsOnly"])
isLong = (orderType != "ShortsOnly")
isShort = (orderType != "LongsOnly")
// Backtest Section {
// Backtest inputs
FromMonth = input(defval=1, title="From Month", minval=1, maxval=12)
FromDay = input(defval=1, title="From Day", minval=1, maxval=31)
FromYear = input(defval=2020, title="From Year", minval=2010)
ToMonth = input(defval=1, title="To Month", minval=1, maxval=12)
ToDay = input(defval=1, title="To Day", minval=1, maxval=31)
ToYear = input(defval=9999, title="To Year", minval=2017)
// Define backtest timewindow
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => true
// }
//TEMA Section {
//LTF Section
xLength = input(20, minval=1, title="Fast Length")
xPrice = close
xEMA1 = ema(xPrice, xLength)
xEMA2 = ema(xEMA1, xLength)
xEMA3 = ema(xEMA2, xLength)
xnRes = (3 * xEMA1) - (3 * xEMA2) + xEMA3
xnResP = plot(xnRes, color=color.green, linewidth=2, title="TEMA1")
yLength = input(60, minval=1, title="Slow Length")
yPrice = close
yEMA1 = ema(yPrice, yLength)
yEMA2 = ema(yEMA1, yLength)
yEMA3 = ema(yEMA2, yLength)
ynRes = (3 * yEMA1) - (3 * yEMA2) + yEMA3
ynResP = plot(ynRes, color=color.red, linewidth=2, title="TEMA2")
fill(xnResP, ynResP, color=xnRes > ynRes ? color.green : color.red, transp=65, editable=true)
//HTF Section
HTFres = input(defval="D", type=input.resolution, title="HTF Resolution")
HTFxLength = input(5, minval=1, title="HTF Fast Length")
HTFxPrice = close
HTFxEMA1 = security(syminfo.tickerid, HTFres, ema(HTFxPrice, HTFxLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFxEMA2 = security(syminfo.tickerid, HTFres, ema(HTFxEMA1, HTFxLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFxEMA3 = security(syminfo.tickerid, HTFres, ema(HTFxEMA2, HTFxLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFxnRes = (3 * HTFxEMA1) - (3 * HTFxEMA2) + HTFxEMA3
HTFxnResP = plot(HTFxnRes, color=color.yellow, linewidth=1,transp=30, title="TEMA1")
HTFyLength = input(15, minval=1, title="HTF Slow Length")
HTFyPrice = close
HTFyEMA1 = security(syminfo.tickerid, HTFres, ema(HTFyPrice, HTFyLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFyEMA2 = security(syminfo.tickerid, HTFres, ema(HTFyEMA1, HTFyLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFyEMA3 = security(syminfo.tickerid, HTFres, ema(HTFyEMA2, HTFyLength), barmerge.gaps_off, barmerge.lookahead_on)
HTFynRes = (3 * HTFyEMA1) - (3 * HTFyEMA2) + HTFyEMA3
HTFynResP = plot(HTFynRes, color=color.purple, linewidth=1, transp=30, title="TEMA2")
fill(HTFxnResP, HTFynResP, color=HTFxnRes > HTFynRes ? color.yellow : color.purple, transp=90, editable=true)
bgcolor(HTFxnRes > HTFynRes ? color.yellow : na, transp=90, editable=true)
bgcolor(HTFxnRes < HTFynRes ? color.purple : na, transp=90, editable=true)
// }
// Buy and Sell Triggers
LongEntryAlert = xnRes > ynRes and HTFxnRes > HTFynRes and window()
LongCloseAlert = xnRes < ynRes and window()
ShortEntryAlert = xnRes < ynRes and HTFxnRes < HTFynRes and window()
ShortCloseAlert = xnRes > ynRes
// Entry & Exit signals
if isLong
strategy.entry("Long", strategy.long, when = LongEntryAlert)
strategy.close("Long", when = LongCloseAlert)
if isShort
strategy.entry("Short", strategy.short, when = ShortEntryAlert)
strategy.close("Short", when = ShortCloseAlert)