OPEN-SOURCE SCRIPT
MTF CRT Setup Finder (Raids + BOS linked)

//version=6
indicator("MTF CRT Setup Finder (Raids + BOS linked)", overlay=true, max_lines_count=500)
// === INPUTS ===
lookback = input.int(5, "Swing Lookback Bars", minval=2)
// === Function: Detect swing highs/lows ===
swingHigh(src, lb) => ta.pivothigh(src, lb, lb)
swingLow(src, lb) => ta.pivotlow(src, lb, lb)
// === Function: Detect CRT with memory ===
f_crt(tf) =>
hi = request.security(syminfo.tickerid, tf, high)
lo = request.security(syminfo.tickerid, tf, low)
cl = request.security(syminfo.tickerid, tf, close)
sh = request.security(syminfo.tickerid, tf, swingHigh(high, lookback))
sl = request.security(syminfo.tickerid, tf, swingLow(low, lookback))
raidHigh = not na(sh) and hi > sh and cl < sh
raidLow = not na(sl) and lo < sl and cl > sl
// store last raid state
var bool hadRaidHigh = false
var bool hadRaidLow = false
if raidHigh
hadRaidHigh := true
if raidLow
hadRaidLow := true
bosDown = hadRaidHigh and cl < sl
bosUp = hadRaidLow and cl > sh
// reset after BOS
if bosDown
hadRaidHigh := false
if bosUp
hadRaidLow := false
[raidHigh, raidLow, bosUp, bosDown]
// === Apply on H1 only first (test) ===
[raidHigh, raidLow, bosUp, bosDown] = f_crt("60")
// === Plot ===
plotshape(raidHigh, title="Raid High", style=shape.diamond, color=color.red, size=size.small, text="Raid High")
plotshape(raidLow, title="Raid Low", style=shape.diamond, color=color.green, size=size.small, text="Raid Low")
plotshape(bosDown, title="Bearish CRT", style=shape.triangledown, color=color.red, size=size.large, text="CRT↓")
plotshape(bosUp, title="Bullish CRT", style=shape.triangleup, color=color.green, size=size.large, text="CRT↑")
indicator("MTF CRT Setup Finder (Raids + BOS linked)", overlay=true, max_lines_count=500)
// === INPUTS ===
lookback = input.int(5, "Swing Lookback Bars", minval=2)
// === Function: Detect swing highs/lows ===
swingHigh(src, lb) => ta.pivothigh(src, lb, lb)
swingLow(src, lb) => ta.pivotlow(src, lb, lb)
// === Function: Detect CRT with memory ===
f_crt(tf) =>
hi = request.security(syminfo.tickerid, tf, high)
lo = request.security(syminfo.tickerid, tf, low)
cl = request.security(syminfo.tickerid, tf, close)
sh = request.security(syminfo.tickerid, tf, swingHigh(high, lookback))
sl = request.security(syminfo.tickerid, tf, swingLow(low, lookback))
raidHigh = not na(sh) and hi > sh and cl < sh
raidLow = not na(sl) and lo < sl and cl > sl
// store last raid state
var bool hadRaidHigh = false
var bool hadRaidLow = false
if raidHigh
hadRaidHigh := true
if raidLow
hadRaidLow := true
bosDown = hadRaidHigh and cl < sl
bosUp = hadRaidLow and cl > sh
// reset after BOS
if bosDown
hadRaidHigh := false
if bosUp
hadRaidLow := false
[raidHigh, raidLow, bosUp, bosDown]
// === Apply on H1 only first (test) ===
[raidHigh, raidLow, bosUp, bosDown] = f_crt("60")
// === Plot ===
plotshape(raidHigh, title="Raid High", style=shape.diamond, color=color.red, size=size.small, text="Raid High")
plotshape(raidLow, title="Raid Low", style=shape.diamond, color=color.green, size=size.small, text="Raid Low")
plotshape(bosDown, title="Bearish CRT", style=shape.triangledown, color=color.red, size=size.large, text="CRT↓")
plotshape(bosUp, title="Bullish CRT", style=shape.triangleup, color=color.green, size=size.large, text="CRT↑")
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.