
이것은 지지를 저항점의 돌파와 재측정을 기반으로 한 양적 거래 전략이다. 전략은 중요한 가격의 지지점과 저항점을 식별하여 가격 돌파 이후의 재측정 확인 지점에 거래한다. 이 전략은 좌우로 돌아가는 바 수동 위치의 핵심 지점을 채택하고, 재측정 용량 차와 결합하여 가짜 돌파를 통과하여 거래의 정확성과 안정성을 향상시킨다.
이 전략은 다음과 같은 핵심 논리를 포함하고 있습니다.
이 전략은 고전적인 지지 저항 이론과 돌파 회수 논리를 통해 구성되어 있으며, 좋은 이론적 기반을 가지고 있다. 매개 변수 최적화 및 위험 통제를 통해 안정적인 거래 효과를 얻을 수 있다. 전략 코드 구조는 명확하고, 이해하기 쉽고 확장할 수 있으며, 강력한 실용적 가치를 가지고 있다. 실제 거래에서 시장 상황과 개인 위험 선호를 결합한 적절한 매개 변수 조정을 권장한다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("SR Breakout & Retest Strategy (4hr)", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// ===== USER INPUTS =====
leftBars = input.int(3, "Left Pivot Bars", minval=1)
rightBars = input.int(3, "Right Pivot Bars", minval=1)
tolerance = input.float(0.005, "Retest Tolerance (Fraction)", step=0.001)
// ===== PIVOT CALCULATION =====
pLow = ta.pivotlow(low, leftBars, rightBars)
pHigh = ta.pivothigh(high, leftBars, rightBars)
// ===== STATE VARIABLES FOR CANDIDATE LEVELS =====
var float candidateSupport = na
var bool supportBroken = false
var bool supportRetested = false
var float candidateResistance = na
var bool resistanceBroken = false
var bool resistanceRetested = false
// ===== UPDATE CANDIDATE LEVELS =====
if not na(pLow)
candidateSupport := pLow
supportBroken := false
supportRetested := false
if not na(pHigh)
candidateResistance := pHigh
resistanceBroken := false
resistanceRetested := false
// ===== CHECK FOR BREAKOUT & RETEST =====
// -- Support: Price breaks below candidate support and then retests it --
if not na(candidateSupport)
if not supportBroken and low < candidateSupport
supportBroken := true
if supportBroken and not supportRetested and close >= candidateSupport and math.abs(low - candidateSupport) <= candidateSupport * tolerance
supportRetested := true
label.new(bar_index, candidateSupport, "Support Retest",
style=label.style_label_up, color=color.green, textcolor=color.white, size=size.tiny)
// Example trading logic: Enter a long position on support retest
strategy.entry("Long_Support", strategy.long)
// -- Resistance: Price breaks above candidate resistance and then retests it --
if not na(candidateResistance)
if not resistanceBroken and high > candidateResistance
resistanceBroken := true
if resistanceBroken and not resistanceRetested and close <= candidateResistance and math.abs(high - candidateResistance) <= candidateResistance * tolerance
resistanceRetested := true
label.new(bar_index, candidateResistance, "Resistance Retest",
style=label.style_label_down, color=color.red, textcolor=color.white, size=size.tiny)
// Example trading logic: Enter a short position on resistance retest
strategy.entry("Short_Resistance", strategy.short)
// ===== PLOTTING =====
plot(pLow, title="Pivot Low (Support)", style=plot.style_circles, color=color.green, linewidth=2)
plot(pHigh, title="Pivot High (Resistance)", style=plot.style_circles, color=color.red, linewidth=2)