
이 전략은 가격의 주문 블록을 식별하여 파격적인 가격 범위를 찾고, 매매 신호가 발생했을 때 시장에 진입합니다. 주문 블록은 기관이 참여하는 지역을 표시하며, 시장의 더 큰 힘을 나타냅니다. 따라서 주문 블록 신호가 발생했을 때 유행적인 가격 변화가 발생할 확률이 높습니다.
주문 블록은 여러 개의 주문 블록과 빈 주문 블록으로 나다. 여러 개의 주문 블록은 아래로 K선 ((붉은 K선) 에 따라 여러 개의 상향 K선 ((녹색 K선) 에 따라 붙어있다. 빈 주문 블록은 위로 K선 ((녹색 K선) 에 따라 여러 개의 하향 K선 (붉은 K선) 에 따라 붙어있다.
주문 블록을 식별하기 위해서는 다음과 같은 몇 가지 조건이 동시에 충족되어야 합니다.
K선 색깔의 전환: K선 색깔이 이전 K선에서 현재 K선으로 전환되었다 (예를 들어, 빨간색에서 녹색으로, 또는 녹색에서 빨간색으로). 이것은 기관이 새로운 트렌드를 시작하기 위해 종료되기 전에 트렌드를 나타낼 수 있습니다.
후속 K선 색상 방향이 일치한다: 매개 변수 periods에 지정된 루트 수를 달성한 후, 후속 K선은 동일한 색상 방향을 유지한다 ((예를 들어, 다중 순서 블록 뒤에 모두 녹색 K선이다). 이것은 새로운 트렌드가 강화되고 확인되었다는 것을 나타낸다.
마이너스가 마이너스를 초과한다: 주문 블록의 개시 가격에서 후속 K 라인 종료 가격의 마이너스가 파라미터 threshold의 설정을 초과한다 (설정값은 0). 이것은 새로운 트렌드가 충분한 강도와 영향력을 가질 수 있도록 보장한다.
위의 세 가지 조건이 동시에 충족되면, 주문 블록 신호를 식별할 수 있다.
여러 개의 오더 블록이 확인되면 구매 신호가 발생하고, 빈 오더 블록이 확인되면 판매 신호가 발생한다.
주문 블록 신호의 불확실성과 가능한 재 테스트를 고려하여, 전략은 주문 블록 신호가 발생했을 때 직접 시장에 진입하지 않고, 그림 선, 경보 등의 방법으로 거래자에게 경고합니다. 거래자는 주문 블록 가격 영역 근처에 적절한 제한 가격을 배치하고, 가격이 촉발된 후에 트렌드에 진입하는 것을 선택할 수 있습니다.
주문 블록은 기관 자금과 대규모 거래량의 참여를 상징하며 시장의 힘을 나타냅니다. 따라서 주문 블록 신호는 잠재적인 돌파구 방향을 미리 잡을 수 있는 예측성과 정확성을 가지고 있습니다. 이것은 추세를 타기위한 유리한 위치와 타이밍을 제공합니다.
전략의 매개 변수들은 역사 K선 수, 돌파동력의 폭 등이 수요를 통해 조정될 수 있으며, 이를 통해 서로 다른 시장 환경과 거래자의 스타일에 맞게 최적화하여 전략의 적응성을 높일 수 있다.
전략은 주문 블록 신호가 발생했을 때 실제 시장에 진입하지 않고, 경보를 설정하고, 외장 제한 가격 표를 통해 포지션을 구축한다. 이 방법은 거래자가 구체적인 진입 포인트와 위험을 제어할 수 있게 한다. 주문 블록 신호가 잘못 판단되더라도 제한 가격 표가 발동되지 않는 데로 이어질 뿐이며, 위험을 제어할 수 있다.
주문 블록은 한 영역을 표시하기 때문에, 후속 가격이 그 영역을 다시 조정할 확률이 높습니다. 따라서 주문 블록 신호는 표준 진입 신호로 간주되지 않고, 사전 경고 정보로 사용되며, 거래자는 진입 시간을 추가로 판단해야합니다.
주문 블록의 파라미터 설정 (역사 K선 수, 폭 하락 등) 이 부적절하면 정상적인 사이드웨이즈 간격에서 가짜 신호를 발생시킬 수 있다. 이것은 거래자가 시장에 대한 민감성과 판단력을 가지고 파라미터를 맹목적으로 최적화하지 않도록 한다.
주문 블록 신호는 100% 신뢰할 수 없기 때문에, 거래자는 신호를 획득할 때 현재의 신호의 신뢰성을 판단하는 데 추가 분석을 필요로 하며, 이는 일정한 인적 작업량을 증가시킨다. 신호 품질에 대한 다른 판단은 거래 성과에 차이를 초래할 수도 있다.
주문 블록 신호가 나타날 때, 다른 지표와 결합하여 트렌드 방향과 강도를 판단 할 수 있습니다. 예를 들어 MACD, RSI 등과 결합하여, 매개 변수 설정으로 인한 잘못된 신호를 필터링하여 신호의 정확성을 향상시킵니다.
다른 시장과 다른 거래 품종은 K 라인 수, 상승/하락 마이너스 등과 같은 매개 변수를 테스트하고 최적화하여 현재 시장 환경에 더 적합하게 만들 수 있습니다. 또한 매개 변수의 자율 적응 기능을 설정하여 시장의 변동성과 위험 선호도에 따라 자동으로 조정할 수 있습니다.
현재 전략은 신호提示 도구로만 사용되며, 트레이더가 직접 진입시기를 판단할 필요가 있다. 우리는 주문 블록 가격 범위를 대상으로 자동 주문 메커니즘을 개발할 수 있으며, 특정 조건이 충족되면 자동 진입한다. 그리고 스톱로스 등의 방법을 결합하여 탈퇴 논리를 설정하여, 인적 판단의 요구 사항을 줄이고, 전략의 자동화 정도를 높일 수 있다.
이 전략은 오더 트래픽 집적된 가격대를 효과적으로 식별하고 시장에 숨겨진 동적 정보를 파헤치며 트렌드를 타고 가격 돌파구를 잡는 데 유리한 위치와 타이밍을 제공합니다. 단순한 트렌드를 추적하는 방법에 비해 오더 블록 전략은 약간의 머리 인식 능력과 주도성을 가지고 있습니다. 파라미터 최적화, 풍선 제어 방법과 결합하여 사용할 때 효과적인 트렌드 전략이 될 수 있습니다. 그러나 거래자는 잘못된 신호의 발생에 주의를 기울이고 신호의 품질에 대한 각 판단을해야합니다.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
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/
// © TradingSecrets and wugamlo
// This experimental Indicator helps identifying instituational Order Blocks.
// Often these blocks signal the beginning of a strong move, but there is a significant probability that these price levels will be revisited at a later point in time again.
// Therefore these are interesting levels to place limit orders (Buy Orders for Bullish OB / Sell Orders for Bearish OB).
//
// A Bullish Order block is defined as the last down candle before a sequence of up candles. (Relevant price range "Open" to "Low" is marked) / Optionally full range "High" to "Low"
// A Bearish Order Block is defined as the last up candle before a sequence of down candles. (Relevant price range "Open" to "High" is marked) / Optionally full range "High" to "Low"
//
// In the settings the number of required sequential candles can be adjusted.
// Furthermore a %-threshold can be entered. It defines which %-change the sequential move needs to achieve in order to identify a relevant Order Block.
// Channels for the last Bullish/Bearish Block can be shown/hidden.
//
// In addition to the upper/lower limits of each Order Block, also the equlibrium (average value) is marked as this is an interesting area for price interaction.
//
// Alerts added: Alerts fire when an Order Block is detected. The delay is based on the "Relevant Periods" input. Means with the default setting "5" the alert will trigger after the
// number of consecutive candles is reached.
//@version=4
strategy("[Backtest] Order Block Finder", overlay = true)
colors = input(title = "Color Scheme", defval="DARK", options=["DARK", "BRIGHT"])
periods = input(5, "Relevant Periods to identify OB") // Required number of subsequent candles in the same direction to identify Order Block
threshold = input(0.0, "Min. Percent move to identify OB", step = 0.1) // Required minimum % move (from potential OB close to last subsequent candle to identify Order Block)
usewicks = input(false, "Use whole range [High/Low] for OB marking?" ) // Display High/Low range for each OB instead of Open/Low for Bullish / Open/High for Bearish
showbull = input(false, "Show latest Bullish Channel?") // Show Channel for latest Bullish OB?
showbear = input(false, "Show latest Bearish Channel?") // Show Channel for latest Bearish OB?
showdocu = input(false, "Show Label for documentation tooltip?") // Show Label which shows documentation as tooltip?
info_pan = input(false, "Show Latest OB Panel?") // Show Info Panel with latest OB Stats
//strategy inputs
plot_offset = input( type=input.bool,defval = false, title = 'Plot Offset?')
stoploss_percent = input(type=input.float, defval = 1, title = 'Stop Loss [%]')
takeprofit_percent = input(type=input.float, defval = 2, title = 'Take Profit [%]')
pyramiding = input( type=input.bool,defval = true, title = 'Pyramiding')
ob_period = periods + 1 // Identify location of relevant Order Block candle
absmove = ((abs(close[ob_period] - close[1]))/close[ob_period]) * 100 // Calculate absolute percent move from potential OB to last candle of subsequent candles
relmove = absmove >= threshold // Identify "Relevant move" by comparing the absolute move to the threshold
// Color Scheme
bullcolor = colors == "DARK"? color.white : color.green
bearcolor = colors == "DARK"? color.blue : color.red
// Bullish Order Block Identification
bullishOB = close[ob_period] < open[ob_period] // Determine potential Bullish OB candle (red candle)
int upcandles = 0
for i = 1 to periods
upcandles := upcandles + (close[i] > open[i]? 1 : 0) // Determine color of subsequent candles (must all be green to identify a valid Bearish OB)
OB_bull = bullishOB and (upcandles == (periods)) and relmove // Identification logic (red OB candle & subsequent green candles)
OB_bull_high = OB_bull? usewicks? high[ob_period] : open[ob_period] : na // Determine OB upper limit (Open or High depending on input)
OB_bull_low = OB_bull? low[ob_period] : na // Determine OB lower limit (Low)
OB_bull_avg = (OB_bull_high + OB_bull_low)/2 // Determine OB middle line
// Bearish Order Block Identification
bearishOB = close[ob_period] > open[ob_period] // Determine potential Bearish OB candle (green candle)
int downcandles = 0
for i = 1 to periods
downcandles := downcandles + (close[i] < open[i]? 1 : 0) // Determine color of subsequent candles (must all be red to identify a valid Bearish OB)
OB_bear = bearishOB and (downcandles == (periods)) and relmove // Identification logic (green OB candle & subsequent green candles)
OB_bear_high = OB_bear? high[ob_period] : na // Determine OB upper limit (High)
OB_bear_low = OB_bear? usewicks? low[ob_period] : open[ob_period] : na // Determine OB lower limit (Open or Low depending on input)
OB_bear_avg = (OB_bear_low + OB_bear_high)/2 // Determine OB middle line
//@TradingSecrets: Option to disable the offset in order to allign signals with Backtest
if not plot_offset
ob_period := 0
// Plotting
plotshape(OB_bull, title="Bullish OB", style = shape.triangleup, color = bullcolor, textcolor = bullcolor, size = size.tiny, location = location.belowbar, offset = -ob_period, text = "Bullish OB") // Bullish OB Indicator
bull1 = plot(OB_bull_high, title="Bullish OB High", style = plot.style_linebr, color = bullcolor, offset = -ob_period, linewidth = 3) // Bullish OB Upper Limit
bull2 = plot(OB_bull_low, title="Bullish OB Low", style = plot.style_linebr, color = bullcolor, offset = -ob_period, linewidth = 3) // Bullish OB Lower Limit
fill(bull1, bull2, color=bullcolor, transp = 0, title = "Bullish OB fill") // Fill Bullish OB
plotshape(OB_bull_avg, title="Bullish OB Average", style = shape.cross, color = bullcolor, size = size.normal, location = location.absolute, offset = -ob_period) // Bullish OB Average
plotshape(OB_bear, title="Bearish OB", style = shape.triangledown, color = bearcolor, textcolor = bearcolor, size = size.tiny, location = location.abovebar, offset = -ob_period, text = "Bearish OB") // Bearish OB Indicator
bear1 = plot(OB_bear_low, title="Bearish OB Low", style = plot.style_linebr, color = bearcolor, offset = -ob_period, linewidth = 3) // Bearish OB Lower Limit
bear2 = plot(OB_bear_high, title="Bearish OB High", style = plot.style_linebr, color = bearcolor, offset = -ob_period, linewidth = 3) // Bearish OB Upper Limit
fill(bear1, bear2, color=bearcolor, transp = 0, title = "Bearish OB fill") // Fill Bearish OB
plotshape(OB_bear_avg, title="Bearish OB Average", style = shape.cross, color = bearcolor, size = size.normal, location = location.absolute, offset = -ob_period) // Bullish OB Average
var line linebull1 = na // Bullish OB average
var line linebull2 = na // Bullish OB open
var line linebull3 = na // Bullish OB low
var line linebear1 = na // Bearish OB average
var line linebear2 = na // Bearish OB high
var line linebear3 = na // Bearish OB open
if OB_bull and showbull
line.delete(linebull1)
linebull1 := line.new(x1 = bar_index, y1 = OB_bull_avg, x2 = bar_index - 1, y2 = OB_bull_avg, extend = extend.left, color = bullcolor, style = line.style_solid, width = 1)
line.delete(linebull2)
linebull2 := line.new(x1 = bar_index, y1 = OB_bull_high, x2 = bar_index - 1, y2 = OB_bull_high, extend = extend.left, color = bullcolor, style = line.style_dashed, width = 1)
line.delete(linebull3)
linebull3 := line.new(x1 = bar_index, y1 = OB_bull_low, x2 = bar_index - 1, y2 = OB_bull_low, extend = extend.left, color = bullcolor, style = line.style_dashed, width = 1)
if OB_bear and showbear
line.delete(linebear1)
linebear1 := line.new(x1 = bar_index, y1 = OB_bear_avg, x2 = bar_index - 1, y2 = OB_bear_avg, extend = extend.left, color = bearcolor, style = line.style_solid, width = 1)
line.delete(linebear2)
linebear2 := line.new(x1 = bar_index, y1 = OB_bear_high, x2 = bar_index - 1, y2 = OB_bear_high, extend = extend.left, color = bearcolor, style = line.style_dashed, width = 1)
line.delete(linebear3)
linebear3 := line.new(x1 = bar_index, y1 = OB_bear_low, x2 = bar_index - 1, y2 = OB_bear_low, extend = extend.left, color = bearcolor, style = line.style_dashed, width = 1)
// Alerts for Order Blocks Detection
alertcondition(OB_bull, title='New Bullish OB detected', message='New Bullish OB detected - This is NOT a BUY signal!')
alertcondition(OB_bear, title='New Bearish OB detected', message='New Bearish OB detected - This is NOT a SELL signal!')
// Print latest Order Blocks in Data Window
var latest_bull_high = 0.0 // Variable to keep latest Bull OB high
var latest_bull_avg = 0.0 // Variable to keep latest Bull OB average
var latest_bull_low = 0.0 // Variable to keep latest Bull OB low
var latest_bear_high = 0.0 // Variable to keep latest Bear OB high
var latest_bear_avg = 0.0 // Variable to keep latest Bear OB average
var latest_bear_low = 0.0 // Variable to keep latest Bear OB low
// Assign latest values to variables
if OB_bull_high > 0
latest_bull_high := OB_bull_high
if OB_bull_avg > 0
latest_bull_avg := OB_bull_avg
if OB_bull_low > 0
latest_bull_low := OB_bull_low
if OB_bear_high > 0
latest_bear_high := OB_bear_high
if OB_bear_avg > 0
latest_bear_avg := OB_bear_avg
if OB_bear_low > 0
latest_bear_low := OB_bear_low
// Plot invisible characters to be able to show the values in the Data Window
plotchar(latest_bull_high, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bull High")
plotchar(latest_bull_avg, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bull Avg")
plotchar(latest_bull_low, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bull Low")
plotchar(latest_bear_high, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bear High")
plotchar(latest_bear_avg, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bear Avg")
plotchar(latest_bear_low, char = ' ', location = location.abovebar, color = #777777, transp = 100, size = size.tiny, title = "Latest Bear Low")
//InfoPanel for latest Order Blocks
draw_InfoPanel(_text, _x, _y, font_size)=>
var label la_panel = na
label.delete(la_panel)
la_panel := label.new(
x=_x, y=_y,
text=_text, xloc=xloc.bar_time, yloc=yloc.price,
color=color.new(#383838, 5), style=label.style_label_left, textcolor=color.white, size=font_size)
info_panel_x = time_close + round(change(time) * 100)
info_panel_y = close
title = "LATEST ORDER BLOCKS"
row0 = "-----------------------------------------------------"
row1 = ' Bullish - High: ' + tostring(latest_bull_high, '#.##')
row2 = ' Bullish - Avg: ' + tostring(latest_bull_avg, '#.##')
row3 = ' Bullish - Low: ' + tostring(latest_bull_low, '#.##')
row4 = "-----------------------------------------------------"
row5 = ' Bearish - High: ' + tostring(latest_bear_high, '#.##')
row6 = ' Bearish - Avg: ' + tostring(latest_bear_avg, '#.##')
row7 = ' Bearish - Low: ' + tostring(latest_bear_low, '#.##')
panel_text = '\n' + title + '\n' + row0 + '\n' + row1 + '\n' + row2 + '\n' + row3 + '\n' + row4 + '\n\n' + row5 + '\n' + row6 + '\n' + row7 + '\n'
if info_pan
draw_InfoPanel(panel_text, info_panel_x, info_panel_y, size.normal)
// === Label for Documentation/Tooltip ===
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
// === Tooltip text ===
var vartooltip = "Indicator to help identifying instituational Order Blocks. Often these blocks signal the beginning of a strong move, but there is a high probability, that these prices will be revisited at a later point in time again and therefore are interesting levels to place limit orders. \nBullish Order block is the last down candle before a sequence of up candles. \nBearish Order Block is the last up candle before a sequence of down candles. \nIn the settings the number of required sequential candles can be adjusted. \nFurthermore a %-threshold can be entered which the sequential move needs to achieve in order to validate a relevant Order Block. \nChannels for the last Bullish/Bearish Block can be shown/hidden."
// === Print Label ===
var label l_docu = na
label.delete(l_docu)
if showdocu
l_docu := label.new(x = time + chper * 35, y = close, text = "DOCU OB", color=color.gray, textcolor=color.white, style=label.style_label_center, xloc = xloc.bar_time, yloc=yloc.price, size=size.tiny, textalign = text.align_left, tooltip = vartooltip)
// @TradingSecrets: Generate entry and exit orders based on the signals
entryLongSignal = OB_bull
entryShortSignal = OB_bear
if not pyramiding
entryLongSignal := entryLongSignal and not strategy.position_size
entryShortSignal := entryShortSignal and not strategy.position_size
if entryLongSignal
strategy.entry("Long Entry", strategy.long)
//strategy.exit("Long Exit Loss", "Long Entry", stop = close * (1 - stoploss_percent*0.01))
if entryShortSignal
strategy.entry("Short Entry", strategy.short)
//strategy.exit("Short Exit Loss", "Short Entry", stop = close * (1 + stoploss_percent*0.01))
strategy.initial_capital = 50000
//Close Position by market order
if strategy.position_size > 0 and strategy.openprofit/nz(strategy.initial_capital + strategy.netprofit) >= takeprofit_percent*0.01
//If I m in a long position and my take profit got hit close it by market order
strategy.close("Long Entry", comment = "Long Exit Profit")
if strategy.position_size < 0 and strategy.openprofit/nz(strategy.initial_capital + strategy.netprofit) >= takeprofit_percent*0.01
strategy.close("Short Entry", comment = "Short Exit Profit")
if strategy.position_size > 0 and strategy.openprofit/nz(strategy.initial_capital + strategy.netprofit) <= -stoploss_percent*0.01
//If I m in a long position and my take profit got hit close it by market order
strategy.close("Long Entry", comment = "Long Exit Loss")
if strategy.position_size < 0 and strategy.openprofit/nz(strategy.initial_capital + strategy.netprofit) <= -stoploss_percent*0.01
strategy.close("Short Entry", comment = "Short Exit Loss")