
이 전략은 프랙탈 이론과 주문 블록 분석을 기반으로 하는 적응형 거래 시스템입니다. 시장 구조에서 주요 지지선과 저항선을 식별하고 프랙탈 돌파 신호와 주문 블록 확인을 결합하여 확률이 높은 거래 기회를 포착합니다. 이 전략은 프랙탈 지표, 동적 주문 블록, 가격 돌파 확인 시스템을 포함한 여러 가지 기술 지표를 통합하여 시장 전환점을 정확하게 파악하고 거래 기회를 정확히 파악합니다.
전략의 핵심 논리는 세 가지 주요 기둥 위에 구축됩니다. 첫째, 프랙탈 계산 모듈을 통해 시장 최고가와 최저가를 지속적으로 모니터링하여 잠재적인 추세 전환 영역을 식별합니다. 둘째, 주문 블록 분석을 통해 주요 가격 수준에서 공급 및 수요 영역을 설정합니다. ; 마지막으로 Breakout 확인 시스템을 통해 가격 돌파의 유효성을 검증합니다. 가격이 상위 프랙탈을 돌파하고 유효한 것으로 확인되면 시스템은 가장 가까운 빨간색 캔들 영역에 수요 영역 주문 블록을 생성하고 롱 주문을 엽니다. 가격이 하위 프랙탈을 돌파하고 유효한 것으로 확인되면 , 시스템은 가장 가까운 녹색 캔들 영역 주문 블록에 공급 영역을 생성하고 단기 주문을 개시합니다. 이 전략에는 주문 블록 색상에 대한 동적 업데이트 기능도 포함되어 있으며, 이는 가격과 주문 블록 간의 상대적 위치 관계를 직관적으로 표시하는 데 사용됩니다.
이것은 기술 분석의 여러 차원을 통합하는 복잡한 거래 전략입니다. 그것은 프랙탈 이론과 주문 블록 분석을 핵심으로 하는 완전한 거래 시스템을 구축합니다. 이 전략의 장점은 적응성과 다양한 확인 메커니즘에 있지만, 동시에 전략 성과에 미치는 시장 환경의 영향에도 주의를 기울여야 합니다. 추천된 최적화 방향을 통해 전략의 신뢰성과 안정성이 더욱 향상될 것으로 기대됩니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Supply and Demand - Order Block Strategy", format=format.price, precision=0, overlay=true)
// Input options for customization
changeColor = input(false, title="Change Box Colors?")
breakType = input.string("Wick+Body", title="Fractal Break Type:", options=["Wick+Body", "Body"])
n = input.int(title="Periods", defval=2, minval=1, tooltip="Number of periods for fractal lookback")
if n <= 0
runtime.error("Periods input must be greater than zero.")
transGreenClr = input.color(color.new(color.green, 80), title="Bg:", inline="a_1")
greenClr = input.color(color.new(color.green, 0), title="Border:", inline="a_1")
transRedClr = input.color(color.new(color.red, 80), title="Bg:", inline="b_1")
redClr = input.color(color.new(color.red, 0), title="Border:", inline="b_1")
// --- Fractal Calculation ---
upFractal = high[n] == ta.highest(high, 2 * n + 1)
downFractal = low[n] == ta.lowest(low, 2 * n + 1)
// --- End Fractal Calculation ---
var float topValue = na
var float bottomValue = na
var int lastRedIndex = na
var float lastRedLow = na
var float lastRedHigh = na
var int lastGreenIndex = na
var float lastGreenLow = na
var float lastGreenHigh = na
var line topLine = na
var line bottomLine = na
var box demandBox = na
var box supplyBox = na
var topBreakBlock = false
var bottomBreakBlock = false
var isLongBreak = false
var isShortBreak = false
topBreakCheckSource = breakType == "Wick+Body" ? high : close
bottomBreakCheckSource = breakType == "Wick+Body" ? low : close
// Last Red Check
if close < open
lastRedIndex := bar_index
lastRedLow := low
lastRedHigh := high
// Last Green Check
if close > open
lastGreenIndex := bar_index
lastGreenLow := low
lastGreenHigh := high
// Top break
if ta.crossover(topBreakCheckSource, topValue) and not topBreakBlock
topBreakBlock := true
isLongBreak := true
// line.set_x2(topLine, bar_index)
// demandBox := box.new(lastRedIndex - 1, lastRedHigh, lastRedIndex + 1, lastRedLow, bgcolor=transGreenClr, border_color=greenClr)
if strategy.position_size <= 0
strategy.entry("Long", strategy.long)
// Bottom break
if ta.crossunder(bottomBreakCheckSource, bottomValue) and not bottomBreakBlock
bottomBreakBlock := true
isShortBreak := true
// line.set_x2(bottomLine, bar_index)
// supplyBox := box.new(lastGreenIndex - 1, lastGreenHigh, lastGreenIndex + 1, lastGreenLow, bgcolor=transRedClr, border_color=redClr)
if strategy.position_size >= 0
strategy.entry("Short", strategy.short)
// New up fractal
if upFractal
topBreakBlock := false
isLongBreak := false
topValue := high[n]
// topLine := line.new(bar_index[n], topValue, bar_index, topValue, color=color.teal, style=line.style_dotted, width=2)
// if not isLongBreak[1]
// line.delete(topLine[1])
// New down fractal
if downFractal
bottomBreakBlock := false
isShortBreak := false
bottomValue := low[n]
// bottomLine := line.new(bar_index[n], bottomValue, bar_index, bottomValue, color=color.maroon, style=line.style_dotted, width=2)
// if not isShortBreak[1]
// line.delete(bottomLine[1])
// Box state update
// activeBoxes = box.all
// if array.size(activeBoxes) > 0 and changeColor
// for i = 0 to array.size(activeBoxes) - 1
// boxId = array.get(activeBoxes, i)
// bVal = box.get_bottom(boxId)
// tVal = box.get_top(boxId)
// if close < bVal
// box.set_bgcolor(boxId, transRedClr)
// box.set_border_color(boxId, redClr)
// if close > tVal
// box.set_bgcolor(boxId, transGreenClr)
// box.set_border_color(boxId, greenClr)
//PLOTS
plotshape(downFractal ,style=shape.triangleup, location=location.belowbar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
plotshape(upFractal, style=shape.triangledown, location=location.abovebar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
// --- Checklist Table ---
// var table checklistTable = table.new(position.bottom_right, 2, 8, bgcolor=color.new(color.gray, 80), border_width=1)
// if barstate.islast
// table.cell(checklistTable, 0, 0, "Condition", text_color=color.white, text_size=size.small, bgcolor=color.teal)
// table.cell(checklistTable, 1, 0, "Status", text_color=color.white, text_size=size.small, bgcolor=color.teal)
// table.cell(checklistTable, 0, 1, "Up Fractal", text_size=size.small)
// table.cell(checklistTable, 1, 1, upFractal ? "✅" : "❌", text_color=upFractal ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 2, "Down Fractal", text_size=size.small)
// table.cell(checklistTable, 1, 2, downFractal ? "✅" : "❌", text_color=downFractal ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 3, "Top Break", text_size=size.small)
// table.cell(checklistTable, 1, 3, isLongBreak ? "✅" : "❌", text_color=isLongBreak ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 4, "Bottom Break", text_size=size.small)
// table.cell(checklistTable, 1, 4, isShortBreak ? "✅" : "❌", text_color=isShortBreak ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 5, "Last Red Candle", text_size=size.small)
// table.cell(checklistTable, 1, 5, close < open ? "✅" : "❌", text_color=close < open ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 6, "Last Green Candle", text_size=size.small)
// table.cell(checklistTable, 1, 6, close > open ? "✅" : "❌", text_color=close > open ? color.green : color.red, text_size=size.small)
// table.cell(checklistTable, 0, 7, "Box Color Change Active", text_size=size.small)
// table.cell(checklistTable, 1, 7, changeColor ? "✅" : "❌", text_color=changeColor ? color.green : color.red, text_size=size.small)