모멘텀 TD 반전 거래 전략

저자:차오장, 날짜: 2023-12-18 17:40:10
태그:

img

전반적인 설명

모멘텀 TD 리버설 트레이딩 전략 (Momentum TD Reversal Trading Strategy) 은 가격 리버설 신호를 식별하기 위해 TD 연속 지표를 활용하는 양적 거래 전략이다. 이 전략은 모멘텀 분석을 기반으로 하며 가격 리버설 신호를 확인한 후 긴 또는 짧은 포지션을 취한다.

전략 논리

이 전략은 TD 연속 지표를 사용하여 가격 변동을 분석하고 9 개의 연속 촛불 이후 가격 반전 패턴을 식별합니다. 구체적으로, 9 개의 연속 상승 촛불 후에 하락 촛불을 감지하면 전략은 짧은 기회로 결정합니다. 반대로, 9 개의 연속 하락 촛불 후에 상승 촛불을 식별하면 전략은 장기 기회로 간주합니다.

TD 연속 지표의 장점을 활용함으로써 전략은 시장보다 앞서 가격 반전 신호를 포착 할 수 있습니다. 이 전략의 추격 상승-살인-하락 메커니즘과 함께 반전 신호를 확인 한 후 장기 또는 단위 포지션을 적시에 설정하여 가격 반전의 초기 단계에서 상대적으로 더 나은 진입 기회를 얻을 수 있습니다.

장점 분석

  • TD 순차 지표를 사용하여 사전에 가격 반전 기회를 식별합니다.
  • 가격 반전을 보다 신속히 확인하기 위해 추격 상승-살인 하락 메커니즘을 구축
  • 상대적으로 더 나은 입점점을 얻기 위해 반전 단계의 형성 단계에서 포지션을 입력합니다.

위험 분석

  • TD 순서적 표시기에는 잘못된 파업이있을 수 있습니다. 신호를 확인하려면 다른 요인이 필요합니다.
  • 적당히 위험을 완화하기 위해 포지션 크기와 보유 기간을 제어합니다.

최적화 방향

  • 다른 지표를 포함하여 반전 신호를 검증하여 거짓 파업 위험을 피합니다.
  • 단일 거래 손실을 통제하기 위한 스톱 로스 메커니즘을 구축
  • 수익 규모와 위험 관리 균형을 맞추기 위해 포지션 크기와 보유 기간을 최적화

결론

모멘텀 TD 리버설 트레이딩 전략 (Momentum TD Reversal Trading Strategy) 은 사전에 가격 반전을 판단하고 확인 후 신속하게 포지션을 설정하기 위해 TD 순차 지표를 활용하여 모멘텀 트레이더에게 매우 적합합니다. 이 전략은 반전 기회를 식별하는 장점이 있지만 여전히 가짜 브레이크로 인한 막대한 손실을 피하기 위해 적절한 위험 통제를 요구합니다. 추가 최적화로 위험-상금 비율에 대한 균형 잡힌 전략이 될 수 있습니다.


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

//@version=4
//This strategy is based on TD sequential study from glaz. 
//I made some improvement and modification to comply with pine script version 4.
//Basically, it is a strategy based on proce action, supports and resistance.

strategy("Sequential Up/Down", overlay=true )
source = input(close)
BarsCount = input(9, "Count of consecutive bars")
useLinearRegression = input(false)
LR_length = input(13,"Linear Regression length")
SR = input(true,"Shows Supports and Resistance lines")
Barcolor = input(true,"Color bars when there is a signal")
transp = input(0, "Transparency of triangle Up or Downs")
Numbers = input(true,"Plot triangle Up or Downs at signal")

//Calculation
src=useLinearRegression?linreg(source,LR_length,0):source
UP = 0
DW = 0
UP := src > src[4] ? nz(UP[1]) + 1 : 0
DW := src < src[4] ? nz(DW[1]) + 1 : 0

UPUp = UP - valuewhen(UP < UP[1], UP, 1)
DWDn = DW - valuewhen(DW < DW[1], DW, 1)

plotshape(Numbers ? UPUp == BarsCount ? true : na : na, style=shape.triangledown, text="", color=color.green, location=location.abovebar, transp=transp)
plotshape(Numbers ? DWDn == BarsCount ? true : na : na, style=shape.triangleup, text="", color=color.red, location=location.belowbar, transp=transp)


// S/R Code By johan.gradin
//------------//
// Sell Setup //
//------------//
priceflip = barssince(src < src[4])
sellsetup = src > src[4] and priceflip
sell = sellsetup and barssince(priceflip != BarsCount)
sellovershoot = sellsetup and barssince(priceflip != BarsCount+4)
sellovershoot1 = sellsetup and barssince(priceflip != BarsCount+5)
sellovershoot2 = sellsetup and barssince(priceflip != BarsCount+6)
sellovershoot3 = sellsetup and barssince(priceflip != BarsCount+7)

//----------//
// Buy setup//
//----------//
priceflip1 = barssince(src > src[4])
buysetup = src < src[4] and priceflip1
buy = buysetup and barssince(priceflip1 != BarsCount)
buyovershoot = barssince(priceflip1 != BarsCount+4) and buysetup
buyovershoot1 = barssince(priceflip1 != BarsCount+5) and buysetup
buyovershoot2 = barssince(priceflip1 != BarsCount+6) and buysetup
buyovershoot3 = barssince(priceflip1 != BarsCount+7) and buysetup

//----------//
// TD lines //
//----------//
TDbuyh = valuewhen(buy, high, 0)
TDbuyl = valuewhen(buy, low, 0)
TDsellh = valuewhen(sell, high, 0)
TDselll = valuewhen(sell, low, 0)

//----------//
//   Plots  //
//----------//

plot(SR ? TDbuyh ? TDbuyl : na : na, style=plot.style_circles, linewidth=1, color=color.red)
plot(SR ? TDselll ? TDsellh : na : na, style=plot.style_circles, linewidth=1, color=color.lime)
barcolor(Barcolor ? sell ? #FF0000 : buy ? #00FF00 : sellovershoot ? #FF66A3 : sellovershoot1 ? #FF3385 : sellovershoot2 ? #FF0066 : sellovershoot3 ? #CC0052 : buyovershoot ? #D6FF5C : buyovershoot1 ? #D1FF47 : buyovershoot2 ? #B8E62E : buyovershoot3 ? #8FB224 : na : na)

//  Strategy: (Thanks to JayRogers)
// === STRATEGY RELATED INPUTS ===
//tradeInvert     = input(defval = false, title = "Invert Trade Direction?")
// the risk management inputs
inpTakeProfit   = input(defval = 0, title = "Take Profit Points", minval = 0)
inpStopLoss     = input(defval = 0, title = "Stop Loss Points", minval = 0)
inpTrailStop    = input(defval = 100, title = "Trailing Stop Loss Points", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset Points", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => buy or buyovershoot or buyovershoot1 or buyovershoot2 or buyovershoot3// functions can be used to wrap up and work out complex conditions
//exitLong() => oscillator <= 0
strategy.entry(id = "Buy", long = true, when = enterLong() )// use function or simple condition to decide when to get in
//strategy.close(id = "Buy", when = exitLong() )// ...and when to get out

// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => sell or sellovershoot or sellovershoot2 or sellovershoot3
//exitShort() => oscillator >= 0
strategy.entry(id = "Sell", long = false, when = enterShort())
//strategy.close(id = "Sell", when = exitShort() )

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)



더 많은