OPEN-SOURCE SCRIPT

Optimized Order Flow Strategy

//version=5
indicator("Optimized Order Flow Strategy", overlay=true)

// تنظیمات ورودی
lookback = input(5, title="Lookback Period for Highs/Lows")
fvgLength = input(20, title="FVG Zone Length")
showOrderBlocks = input(true, title="Show Order Blocks")
showFVG = input(true, title="Show FVG Zones")

// شناسایی بالاترین و پایین‌ترین قیمت
highs = high >= ta.highest(high, lookback) ? high : na
lows = low <= ta.lowest(low, lookback) ? low : na

// شناسایی اوردر بلاک‌ها
orderBlockLow = ta.valuewhen(lows, low, 0)
orderBlockHigh = ta.valuewhen(highs, high, 0)
validOrderBlockLow = not na(orderBlockLow)
validOrderBlockHigh = not na(orderBlockHigh)

// فیلتر حجم
volumeFilter = volume > ta.sma(volume, 10)

// سیگنال خرید و فروش
buySignal = validOrderBlockLow and close < orderBlockLow and ta.crossover(close, orderBlockLow) and volumeFilter
sellSignal = validOrderBlockHigh and close > orderBlockHigh and ta.crossunder(close, orderBlockHigh) and volumeFilter

// نمایش سیگنال‌ها
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

// هشدارها
alertcondition(buySignal, title="Buy Alert", message="Buy Signal Detected!")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal Detected!")
Cycles

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer