hubis

hubis

//@version=5
indicator("Order Blocks Strategy - Khan", overlay=true)

// Input parameters
var float orderBlockZone = na
lookback = input.int(20, title="Lookback Period for High/Low")
showLiquidity = input.bool(true, title="Highlight Liquidity Zones")
colorOrderBlock = color.new(color.green, 80)
colorLiquidity = color.new(color.red, 80)

// Identify highs and lows
highLevel = ta.highest(high, lookback)
lowLevel = ta.lowest(low, lookback)

// Detect bullish and bearish order blocks
bullishOrderBlock = (close < open ) and (close > open) and (low open ) and (close < open) and (high >= highLevel)

// Highlight order blocks
if bullishOrderBlock
orderBlockZone := low
var line bullLine = na
bullLine := line.new(bar_index , orderBlockZone, bar_index, orderBlockZone, color=colorOrderBlock, width=1)

if bearishOrderBlock
orderBlockZone := high
var line bearLine = na
bearLine := line.new(bar_index , orderBlockZone, bar_index, orderBlockZone, color=colorOrderBlock, width=1)

// Highlight liquidity zones (if enabled)
if showLiquidity
var line liquidityLineHigh = na
var line liquidityLineLow = na
liquidityLineHigh := line.new(bar_index , highLevel, bar_index, highLevel, color=colorLiquidity, width=1)
liquidityLineLow := line.new(bar_index , lowLevel, bar_index, lowLevel, color=colorLiquidity, width=1)

// Plot order blocks for visualization
plotshape(series=bullishOrderBlock, title="Bullish Order Block", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=bearishOrderBlock, title="Bearish Order Block", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

Read More

Share:

Latest News