vip//@version=5
indicator(" fmfm1 ", overlay=true, max_labels_count=500, max_lines_count=500, max_boxes_count=500)
// ==============================
// | الإعدادات الأساسية
// ==============================
atrPeriod = input.int(10, "ATR Period", minval=1, group="Supertrend")
factor = input.float(3.0, "Supertrend Multiplier", minval=0.1, step=0.1, group="Supertrend")
rsiLength = input.int(14, "RSI Length", minval=2, group="RSI")
macdFast = input.int(12, "MACD Fast Length", minval=1, group="MACD")
macdSlow = input.int(26, "MACD Slow Length", minval=1, group="MACD")
macdSig = input.int(9, "MACD Signal Length", minval=1, group="MACD")
emaLen1 = input.int(20, "EMA 20 Length", group="EMA")
emaLen2 = input.int(50, "EMA 50 Length", group="EMA")
tablePos = input.string("top_right", "Table Position",
options= , group="Display")
// إعدادات الصناديق
showBoxes = input.bool(true, "إظهار صناديق الإشارات", group="صناديق الإشارات")
boxTransparency = input.int(70, "شفافية الصندوق", minval=0, maxval=100, group="صناديق الإشارات")
boxHeight = input.float(0.15, "ارتفاع الصندوق %", minval=0.05, maxval=1.0, step=0.05, group="صناديق الإشارات")
// فلتر الشركات
enableFilter = input.bool(false, "تفعيل فلتر الشركات", group="فلتر الشركات")
symbol1 = input.string("", "الشركة 1", group="فلتر الشركات")
symbol2 = input.string("", "الشركة 2", group="فلتر الشركات")
symbol3 = input.string("", "الشركة 3", group="فلتر الشركات")
symbol4 = input.string("", "الشركة 4", group="فلتر الشركات")
symbol5 = input.string("", "الشركة 5", group="فلتر الشركات")
symbol6 = input.string("", "الشركة 6", group="فلتر الشركات")
// التنبيهات
enableAlerts = input.bool(true, "تفعيل التنبيهات", group="التنبيهات")
alertOnCall = input.bool(true, "تنبيه عند CALL", group="التنبيهات")
alertOnPut = input.bool(true, "تنبيه عند PUT", group="التنبيهات")
// إعدادات مناطق العرض والطلب
zigzagLen = input.int(9, 'ZigZag Length', group = 'Order Block Settings')
numberObShow = input.int(1, 'عدد مناطق العرض والطلب المعروضة', group = 'Order Block Settings', minval = 1, maxval = 10)
bearishOrderblockColor = input.color(color.new(#dc1515, 18), title = 'لون منطقة العرض', group = 'Order Block Settings')
bullishOrderblockColor = input.color(color.new(#58bd0f, 10), title = 'لون منطقة الطلب', group = 'Order Block Settings')
// إعدادات نسبة القوة
showStrengthLabels = input.bool(true, 'عرض نسبة القوة', group = 'Strength Settings')
strengthThreshold = input.int(60, 'حد التنبيه', group = 'Strength Settings', minval = 50, maxval = 90)
enableStrengthAlert = input.bool(true, 'تفعيل تنبيهات القوة', group = 'Strength Settings')
// ==============================
// | حسابات Supertrend و المؤشرات
// ==============================
atrValue = ta.atr(atrPeriod)
hl2Value = (high + low) / 2
upperBand = hl2Value - factor * atrValue
lowerBand = hl2Value + factor * atrValue
var float trendLine = na
trendLine := close > nz(trendLine , hl2Value) ? math.max(upperBand, nz(trendLine , upperBand)) : math.min(lowerBand, nz(trendLine , lowerBand))
bull = close > trendLine
bear = close < trendLine
buySignal = ta.crossover(close, trendLine)
sellSignal = ta.crossunder(close, trendLine)
ema20 = ta.ema(close, emaLen1)
ema50 = ta.ema(close, emaLen2)
emaBull = ema20 > ema50
emaBear = ema20 < ema50
rsi = ta.rsi(close, rsiLength)
rsiBull = rsi > 50
rsiBear = rsi < 50
macd = ta.ema(close, macdFast) - ta.ema(close, macdSlow)
signal = ta.ema(macd, macdSig)
macdBull = macd > signal
macdBear = macd < signal
vwapValue = ta.vwap(close)
vwapBull = close > vwapValue
vwapBear = close < vwapValue
// الإشارات النهائية
allBull = (bull and rsiBull and macdBull and emaBull and vwapBull)
allBear = (bear and rsiBear and macdBear and emaBear and vwapBear)
finalSignal = allBull ? "CALL " : allBear ? "PUT " :" NEUTRAL"
finalBg = allBull ? color.new(color.green, 0) : allBear ? color.new(color.red, 0) : color.new(color.orange, 0)
// حفظ الحالة السابقة للإشارات
var bool wasCall = false
var bool wasPut = false
// اكتشاف إشارة CALL جديدة
newCallSignal = allBull and not wasCall
// اكتشاف إشارة PUT جديدة
newPutSignal = allBear and not wasPut
// تحديث الحالة
wasCall := allBull
wasPut := allBear
// ==============================
// | Labels للإشارات الجديدة - تم تعطيلها
// ==============================
// تم إزالة Labels CALL/PUT من فوق وتحت الشموع
// ==============================
// | التنبيهات
// ==============================
if enableAlerts
if alertOnCall and newCallSignal
alert("🔔 إشارة CALL على " + syminfo.ticker + " | السعر: " + str.tostring(close, format.mintick), alert.freq_once_per_bar)
if alertOnPut and newPutSignal
alert("🔔 إشارة PUT على " + syminfo.ticker + " | السعر: " + str.tostring(close, format.mintick), alert.freq_once_per_bar)
// ==============================
// | لوحة المعلومات
// ==============================
var table dash = table.new(position=tablePos, columns=2, rows=9, border_width=1)
if barstate.islast
table.cell(dash, 0, 0, "Ind", text_color=color.white, bgcolor=color.blue, text_size=size.tiny)
table.cell(dash, 1, 0, "Sig", text_color=color.white, bgcolor=color.blue, text_size=size.tiny)
table.cell(dash, 0, 1, "Sup", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 1, buySignal ? "BUY" : sellSignal ? "SELL" : bull ? "UP" : "DN",
text_color=color.white,
bgcolor= buySignal ? color.new(color.green, 0) : sellSignal ? color.new(color.red, 0) : bull ? color.new(color.green, 0) : color.new(color.red, 0),
text_size=size.tiny)
table.cell(dash, 0, 2, "EMA", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 2, emaBull ? "UP" : "DN", text_color=color.white,
bgcolor=emaBull ? color.new(color.green, 0) : color.new(color.red, 0), text_size=size.tiny)
table.cell(dash, 0, 3, "RSI", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 3, rsiBull ? "UP" : "DN", text_color=color.white,
bgcolor=rsiBull ? color.new(color.green, 0) : color.new(color.red, 0), text_size=size.tiny)
table.cell(dash, 0, 4, "MACD", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 4, macdBull ? "UP" : "DN", text_color=color.white,
bgcolor=macdBull ? color.new(color.green, 0) : color.new(color.red, 0), text_size=size.tiny)
table.cell(dash, 0, 5, "VWAP", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 5, vwapBull ? "UP" : "DN", text_color=color.white,
bgcolor=vwapBull ? color.new(color.green, 0) : color.new(color.red, 0), text_size=size.tiny)
table.cell(dash, 0, 6, "دخول", text_color=color.yellow, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 6, finalSignal, text_color=color.white, bgcolor=finalBg, text_size=size.tiny)
table.cell(dash, 0, 7, "Price", text_color=color.white, bgcolor=color.black, text_size=size.tiny)
table.cell(dash, 1, 7, str.tostring(close, format.mintick), text_color=color.white, bgcolor=color.gray, text_size=size.tiny)
// ==============================
// | رسم المؤشرات
// ==============================
plot(trendLine, "Supertrend", color=bull ? color.green : color.red, linewidth=2)
plot(ema20, "EMA 20", color=color.blue, linewidth=1)
// ==============================
// | مناطق العرض والطلب
// ==============================
// أنواع البيانات
type orderblock
float value
int barStart
int barEnd
box block
bool broken
label supplyLabel
label demandLabel
// المصفوفات
var array bullishOrderblock = array.new()
var array bearishOrderblock = array.new()
var array highValIndex = array.new()
var array lowValIndex = array.new()
var array highVal = array.new_float()
var array lowVal = array.new_float()
// المتغيرات
var bool drawUp = false
var bool drawDown = false
var string lastState = na
var bool to_up = false
var bool to_down = false
var int trendZZ = 1
atrOB = ta.atr(14)
// حساب الاتجاه
to_up := high >= ta.highest(high, zigzagLen)
to_down := low <= ta.lowest(low, zigzagLen)
trendZZ := trendZZ == 1 and to_down ? -1 : trendZZ == -1 and to_up ? 1 : trendZZ
// تحديد تغيير الاتجاه للأعلى
if ta.change(trendZZ) != 0 and trendZZ == 1
array.push(highValIndex, time )
array.push(highVal, high )
if array.size(lowVal) > 1
drawUp := false
// تحديد تغيير الاتجاه للأسفل
if ta.change(trendZZ) != 0 and trendZZ == -1
array.push(lowValIndex, time )
array.push(lowVal, low )
if array.size(highVal) > 1
drawDown := false
// دالة حساب نسبة القوة
calculateStrengthRatio() =>
float supplyStrength = 0.0
float demandStrength = 0.0
int supplyTouches = 0
for i = 1 to 20
if i < bar_index
if close < open
supplyTouches += 1
int demandTouches = 0
for i = 1 to 20
if i < bar_index
if close > open
demandTouches += 1
float avgVolume = ta.sma(volume, 20)
float volumeRatio = volume / avgVolume
float rsiValue = ta.rsi(close, 14)
if rsiValue > 50
demandStrength := rsiValue
supplyStrength := 100 - rsiValue
else
supplyStrength := 100 - rsiValue
demandStrength := rsiValue
// إنشاء منطقة عرض (Bearish Order Block)
if array.size(lowVal) > 1 and drawDown == false
if close < array.get(lowVal, array.size(lowVal) - 1)
drawDown := true
lastState := 'down'
orderblock newOrderblock = orderblock.new()
float max = 0
int bar = na
for i = (time - array.get(lowValIndex, array.size(lowValIndex) - 1) - (time - time )) / (time - time ) to 0 by 1
if high > max
max := high
bar := time
newOrderblock.barStart := bar
newOrderblock.barEnd := time
newOrderblock.broken := false
newOrderblock.value := max
newOrderblock.block := box.new(
left = newOrderblock.barStart,
top = newOrderblock.value,
right = newOrderblock.barEnd,
bottom = newOrderblock.value - atrOB * 0.30,
xloc = xloc.bar_time,
bgcolor = bearishOrderblockColor,
border_width = 1,
border_color = color.new(#cd1212, 0))
= calculateStrengthRatio()
newOrderblock.supplyLabel := na
newOrderblock.demandLabel := na
if showStrengthLabels
newOrderblock.supplyLabel := label.new(
x = time,
y = newOrderblock.value + atrOB * 0.5,
text = "عرض: " + str.tostring(supplyStr, "#") + "%",
xloc = xloc.bar_time,
yloc = yloc.price,
color = supplyStr >= strengthThreshold ? color.new(color.red, 0) : color.new(color.orange, 0),
textcolor = color.white,
style = label.style_label_down,
size = size.tiny)
newOrderblock.demandLabel := label.new(
x = time,
y = newOrderblock.value - atrOB * 0.5,
text = "طلب: " + str.tostring(demandStr, "#") + "%",
xloc = xloc.bar_time,
yloc = yloc.price,
color = color.new(color.gray, 30),
textcolor = color.white,
style = label.style_label_up,
size = size.tiny)
if enableStrengthAlert and supplyStr >= strengthThreshold
alert("تنبيه: قوة العرض " + str.tostring(supplyStr, "#") + "% - تجاوزت " + str.tostring(strengthThreshold) + "%", alert.freq_once_per_bar)
array.push(bearishOrderblock, newOrderblock)
if array.size(bearishOrderblock) > 20
oldBlock = array.shift(bearishOrderblock)
if not na(oldBlock.supplyLabel)
label.delete(oldBlock.supplyLabel)
if not na(oldBlock.demandLabel)
label.delete(oldBlock.demandLabel)
// إنشاء منطقة طلب (Bullish Order Block)
if array.size(highVal) > 1 and drawUp == false
if close > array.get(highVal, array.size(highVal) - 1)
drawUp := true
lastState := 'up'
orderblock newOrderblock = orderblock.new()
float min = 999999999
int bar = na
for i = (time - array.get(highValIndex, array.size(highValIndex) - 1) - (time - time )) / (time - time ) to 0 by 1
if low < min
min := low
bar := time
newOrderblock.barStart := bar
newOrderblock.barEnd := time
newOrderblock.broken := false
newOrderblock.value := min
newOrderblock.block := box.new(
left = newOrderblock.barStart,
top = newOrderblock.value + atrOB * 0.12,
right = newOrderblock.barEnd,
bottom = newOrderblock.value,
xloc = xloc.bar_time,
bgcolor = bullishOrderblockColor,
border_width = 1,
border_color = color.new(#52ae10, 0))
= calculateStrengthRatio()
newOrderblock.supplyLabel := na
newOrderblock.demandLabel := na
if showStrengthLabels
newOrderblock.demandLabel := label.new(
x = time,
y = newOrderblock.value - atrOB * 0.5,
text = "طلب: " + str.tostring(demandStr, "#") + "%",
xloc = xloc.bar_time,
yloc = yloc.price,
color = demandStr >= strengthThreshold ? color.new(color.green, 0) : color.new(color.blue, 0),
textcolor = color.white,
style = label.style_label_up,
size = size.tiny)
if enableStrengthAlert and demandStr >= strengthThreshold
alert("تنبيه: قوة الطلب " + str.tostring(demandStr, "#") + "% - تجاوزت " + str.tostring(strengthThreshold) + "%", alert.freq_once_per_bar)
array.push(bullishOrderblock, newOrderblock)
if array.size(bullishOrderblock) > 20
oldBlock = array.shift(bullishOrderblock)
if not na(oldBlock.supplyLabel)
label.delete(oldBlock.supplyLabel)
if not na(oldBlock.demandLabel)
label.delete(oldBlock.demandLabel)
// متغيرات العداد
var int activeBullishCount = 0
var int activeBearishCount = 0
// تحديث مناطق الطلب
if array.size(bullishOrderblock) > 0
orderblock testOrderblock = na
int counter = 0
activeBullishCount := 0
for i = array.size(bullishOrderblock) - 1 to 0 by 1
testOrderblock := array.get(bullishOrderblock, i)
if counter < numberObShow
testOrderblock.block.set_right(time)
= calculateStrengthRatio()
if showStrengthLabels
if not na(testOrderblock.demandLabel)
label.set_x(testOrderblock.demandLabel, time)
label.set_text(testOrderblock.demandLabel, "طلب: " + str.tostring(demandStr, "#") + "%")
label.set_color(testOrderblock.demandLabel, demandStr >= strengthThreshold ? color.new(color.green, 0) : color.new(color.blue, 0))
if not na(testOrderblock.supplyLabel)
label.set_x(testOrderblock.supplyLabel, time)
label.set_text(testOrderblock.supplyLabel, "عرض: " + str.tostring(supplyStr, "#") + "%")
if close < testOrderblock.value
testOrderblock.block.delete()
if not na(testOrderblock.demandLabel)
label.delete(testOrderblock.demandLabel)
if not na(testOrderblock.supplyLabel)
label.delete(testOrderblock.supplyLabel)
array.remove(bullishOrderblock, i)
else
activeBullishCount += 1
counter := counter + 1
else
testOrderblock.block.set_right(testOrderblock.barStart)
if not na(testOrderblock.demandLabel)
label.delete(testOrderblock.demandLabel)
if not na(testOrderblock.supplyLabel)
label.delete(testOrderblock.supplyLabel)
// تحديث مناطق العرض
if array.size(bearishOrderblock) > 0
orderblock testOrderblock = na
int counter = 0
activeBearishCount := 0
for i = array.size(bearishOrderblock) - 1 to 0 by 1
testOrderblock := array.get(bearishOrderblock, i)
if counter < numberObShow
testOrderblock.block.set_right(time)
= calculateStrengthRatio()
if showStrengthLabels
if not na(testOrderblock.supplyLabel)
label.set_x(testOrderblock.supplyLabel, time)
label.set_text(testOrderblock.supplyLabel, "عرض: " + str.tostring(supplyStr, "#") + "%")
label.set_color(testOrderblock.supplyLabel, supplyStr >= strengthThreshold ? color.new(color.red, 0) : color.new(color.orange, 0))
if not na(testOrderblock.demandLabel)
label.set_x(testOrderblock.demandLabel, time)
label.set_text(testOrderblock.demandLabel, "طلب: " + str.tostring(demandStr, "#") + "%")
if close > testOrderblock.value
testOrderblock.block.delete()
if not na(testOrderblock.supplyLabel)
label.delete(testOrderblock.supplyLabel)
if not na(testOrderblock.demandLabel)
label.delete(testOrderblock.demandLabel)
array.remove(bearishOrderblock, i)
else
activeBearishCount += 1
counter := counter + 1
else
testOrderblock.block.set_right(testOrderblock.barStart)
if not na(testOrderblock.supplyLabel)
label.delete(testOrderblock.supplyLabel)
if not na(testOrderblock.demandLabel)
label.delete(testOrderblock.demandLabel)
// ================= SETTINGS =================
paint_bars = input.bool(false, "Paint bars?", group="Bars Settings")
catch_flat = input.bool(false, "Try to catch flat?", group="Bars Settings")
uptrend_colour = input.color(color.rgb(13,247,20), "Uptrend colour", group="Bars Settings")
downtrend_colour = input.color(color.rgb(250,10,10), "Downtrend colour", group="Bars Settings")
neutraltrend_colour = input.color(color.rgb(245,252,252), "Neutral colour", group="Bars Settings")
// ================= TABLE SETTINGS =================
show_header = input(false, "Show header?", group="Table Settings")
show_ema_value = input(false, "Show EMA value?", group="Table Settings")
dashboard_position = input.string("Middle right", "Position", options= , group="Table Settings")
text_color = input.color(color.white, "Text colour", group="Table Settings")
table_color = input.color(color.rgb(240,249,250), "Border colour", group="Table Settings")
uptrend_indicator = input.string("🟢", "Uptrend indicator", group="Table Settings")
downtrend_indicator = input.string("🔴", "Downtrend indicator", group="Table Settings")
neutraltrend_indicator = input.string("🟡", "Neutral indicator", group="Table Settings")
header_bg_color = input.color(color.rgb(18,18,18,75), "Header background", group="Table Settings")
uptrend_bg_color = input.color(color.new(color.green,90), "Up BG", group="Table Settings")
downtrend_bg_color = input.color(color.new(color.red,90), "Down BG", group="Table Settings")
neutraltrend_bg_color = input.color(color.new(color.yellow,90), "Neutral BG", group="Table Settings")
// ================= EMA SETTINGS =================
trend_identification_approach = input.string("Direction of a single EMA", "Trend approach", options= , group="EMA Settings")
ema1_length = input.int(50, "EMA length", minval=1, maxval=800, group="EMA Settings")
ema2_length = input.int(200, "Additional EMA length", minval=20, maxval=800, group="EMA Settings")
// ================= TIMEFRAMES =================
show_3m = input(true, "Show 3m", group="Timeframe Settings")
show_5m = input(true, "Show 5m", group="Timeframe Settings")
show_15m = input(true, "Show 15m", group="Timeframe Settings")
show_1h = input(true, "Show 1h", group="Timeframe Settings")
show_4h = input(true, "Show 4h", group="Timeframe Settings")
// ================= TABLE CREATION =================
var table_position = switch dashboard_position
"Top left" => position.top_left
"Top right" => position.top_right
"Bottom left" => position.bottom_left
"Bottom right" => position.bottom_right
"Top center" => position.top_center
"Bottom center" => position.bottom_center
"Middle right" => position.middle_right
=> position.middle_right
// جدول صغير جدًا جدًا
var t = table.new(position=table_position, columns=3, rows=20, frame_color=table_color, frame_width=0, border_color=table_color, border_width=0)
// ================= FUNCTIONS =================
calc_smma(src, len) =>
var float smma = na
smma := na(smma) ? ta.sma(src, len) : (smma * (len - 1) + src) / len
smma
calc_zlema(src, len) =>
ema1 = ta.ema(src, len)
ema2 = ta.ema(ema1, len)
ema1 + (ema1 - ema2)
check_impulse() =>
hi = calc_smma(high, 34)
lo = calc_smma(low, 34)
mi = calc_zlema(hlc3, 34)
md = (mi > hi ? mi - hi : mi < lo ? mi - lo : 0)
sb = ta.sma(md, 9)
sh = md - sb
sh != 0
get_trend_status() =>
impulse = catch_flat ? check_impulse() : true
ema1_current = ta.ema(close, ema1_length)
ema1_prev = ema1_current
ema2_current = ta.ema(close, ema2_length)
ema2_prev = ema2_current
if trend_identification_approach == "Direction of a single EMA"
bg = not impulse ? neutraltrend_bg_color : ema1_current > ema1_prev ? uptrend_bg_color : ema1_current < ema1_prev ? downtrend_bg_color : neutraltrend_bg_color
ind = not impulse ? neutraltrend_indicator : ema1_current > ema1_prev ? uptrend_indicator : ema1_current < ema1_prev ? downtrend_indicator : neutraltrend_indicator
else
bg = not impulse ? neutraltrend_bg_color : ema1_current > ema2_current ? uptrend_bg_color : ema1_current < ema2_current ? downtrend_bg_color : neutraltrend_bg_color
ind = not impulse ? neutraltrend_indicator : ema1_current > ema2_current ? uptrend_indicator : ema1_current < ema2_current ? downtrend_indicator : neutraltrend_indicator
// ================= TREND REQUESTS =================
= request.security(syminfo.tickerid, "3", get_trend_status())
= request.security(syminfo.tickerid, "5", get_trend_status())
= request.security(syminfo.tickerid, "15", get_trend_status())
= request.security(syminfo.tickerid, "60", get_trend_status())
= request.security(syminfo.tickerid, "240", get_trend_status())
// ================= SMALL TABLE =================
if barstate.islast
tiny = size.tiny
if show_header
table.cell(t, 0, 0, "TF", text_color=text_color, text_size=tiny, bgcolor=header_bg_color)
table.cell(t, 1, 0, "Trend", text_color=text_color, text_size=tiny, bgcolor=header_bg_color)
if show_ema_value
table.cell(t, 2, 0, "EMA", text_color=text_color, text_size=tiny, bgcolor=header_bg_color)
if show_3m
table.cell(t, 0, 1, "3m", text_color=text_color, text_size=tiny, bgcolor=bg_3m)
table.cell(t, 1, 1, ind_3m, text_color=text_color, text_size=tiny, bgcolor=bg_3m)
if show_5m
table.cell(t, 0, 2, "5m", text_color=text_color, text_size=tiny, bgcolor=bg_5m)
table.cell(t, 1, 2, ind_5m, text_color=text_color, text_size=tiny, bgcolor=bg_5m)
if show_15m
table.cell(t, 0, 3, "15m", text_color=text_color, text_size=tiny, bgcolor=bg_15m)
table.cell(t, 1, 3, ind_15m, text_color=text_color, text_size=tiny, bgcolor=bg_15m)
if show_1h
table.cell(t, 0, 4, "1h", text_color=text_color, text_size=tiny, bgcolor=bg_1h)
table.cell(t, 1, 4, ind_1h, text_color=text_color, text_size=tiny, bgcolor=bg_1h)
if show_4h
table.cell(t, 0, 5, "4h", text_color=text_color, text_size=tiny, bgcolor=bg_4h)
table.cell(t, 1, 5, ind_4h, text_color=text_color, text_size=tiny, bgcolor=bg_4h)
// --- إعدادات الإدخال ---
string GRP_SETTINGS = "الإعدادات"
var bool showTable = input.bool(true, "إظهار جدول التحليل", group=GRP_SETTINGS)
var int lookbackPeriod = input.int(5, "فترة التحليل (أشرطة)", minval=5, maxval=100, group=GRP_SETTINGS)
var int maxBarsDisplay = input.int(5, "أقصى عدد أشرطة مرئية", minval=5, maxval=20, group=GRP_SETTINGS)
var color buyColor = input.color(color.new(#00C853, 0), "لون الشراء", group=GRP_SETTINGS)
var color sellColor = input.color(color.new(#FF1744, 0), "لون البيع", group=GRP_SETTINGS)
var string tablePosition = input.string("Top-Right", "موضع الجدول", options= , group=GRP_SETTINGS)
// --- متغيرات الحالة ---
var float volumes = array.new_float(0)
var float buyVolumes = array.new_float(0)
var float sellVolumes = array.new_float(0)
var float netFlows = array.new_float(0)
var float priceChanges = array.new_float(0)
var float highs = array.new_float(0)
var float lows = array.new_float(0)
var float opens = array.new_float(0)
var float closes = array.new_float(0)
var table trendTable = na
// --- دالة بناء الشريط البصري ---
f_buildBar(int filled, int total) =>
string result = ""
for i = 1 to total
result += i <= filled ? "█" : "░"
result
// --- جمع البيانات ---
if barstate.isconfirmed
float h = high
float l = low
float o = open
float c = close
float v = volume
float prevClose = nz(close , c)
float priceChange = c - prevClose
float priceRange = math.max(h - l, syminfo.mintick)
float buyV = v * (c - l) / priceRange
float sellV = v * (h - c) / priceRange
float netFlow = buyV - sellV
if array.size(volumes) >= lookbackPeriod
array.shift(volumes)
array.shift(buyVolumes)
array.shift(sellVolumes)
array.shift(netFlows)
array.shift(priceChanges)
array.shift(highs)
array.shift(lows)
array.shift(opens)
array.shift(closes)
array.push(volumes, v)
array.push(buyVolumes, buyV)
array.push(sellVolumes, sellV)
array.push(netFlows, netFlow)
array.push(priceChanges, priceChange)
array.push(highs, h)
array.push(lows, l)
array.push(opens, o)
array.push(closes, c)
// --- منطق الجدول ---
if showTable and array.size(volumes) >= lookbackPeriod
// === 1. الاتجاه ===
float totalVol = array.sum(volumes)
float totalBuyVol = array.sum(buyVolumes)
float totalSellVol = array.sum(sellVolumes)
float buyPerc = totalVol > 0 ? (totalBuyVol / totalVol) * 100 : 0
float sellPerc = totalVol > 0 ? (totalSellVol / totalVol) * 100 : 0
float diffPerc = buyPerc - sellPerc
string diffText = str.tostring(math.abs(diffPerc), "#.##") + "%"
int filledBars = int(math.round((math.abs(diffPerc) / 100) * maxBarsDisplay))
string visualBar = f_buildBar(filledBars, maxBarsDisplay)
color barColor = totalBuyVol > totalSellVol ? buyColor : sellColor
// === 2. الديناميكية ===
float meanFlow = array.avg(netFlows)
float stdFlow = array.stdev(netFlows)
float skew = 0.0
if stdFlow > 1e-10
for i = 0 to array.size(netFlows) - 1
float z = (array.get(netFlows, i) - meanFlow) / stdFlow
skew += math.pow(z, 3)
skew /= array.size(netFlows)
float skew_norm = math.max(-1, math.min(1, skew / 2))
float pBuy = totalBuyVol / totalVol
float pSell = totalSellVol / totalVol
pBuy := math.max(pBuy, 1e-10)
pSell := math.max(pSell, 1e-10)
float entropy = -(pBuy * math.log(pBuy) + pSell * math.log(pSell))
float normEntropy = entropy / math.log(2)
float entropy_score = 1 - normEntropy
float sumX = array.sum(priceChanges)
float sumY = array.sum(netFlows)
float sumXY = 0.0, sumX2 = 0.0, sumY2 = 0.0
int n = array.size(priceChanges)
for i = 0 to n - 1
float x = array.get(priceChanges, i)
float y = array.get(netFlows, i)
sumXY += x * y
sumX2 += x * x
sumY2 += y * y
float numerator = n * sumXY - sumX * sumY
float denominator = math.sqrt((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY))
float corr = denominator != 0 ? numerator / denominator : 0.0
float signal = math.abs(totalBuyVol - totalSellVol)
float noise = totalVol - signal
float snr = signal / (noise + 1e-10)
float snr_norm = math.min(1, snr / 3)
float dynamicScore = (skew_norm + entropy_score + corr + snr_norm) / 4
float finalPerc = (dynamicScore + 1) * 50
int filledDynamicBars = int(math.round(finalPerc / 100 * maxBarsDisplay))
string dynamicBar = f_buildBar(filledDynamicBars, maxBarsDisplay)
color dynamicColor = finalPerc > 50 ? buyColor : sellColor
// === 3. السلوك ===
float controlSum = 0.0
float reactionSum = 0.0
float closeDomSum = 0.0
int upBars = 0
int totalBars = array.size(closes)
for i = 0 to totalBars - 1
float h_i = array.get(highs, i)
float l_i = array.get(lows, i)
float o_i = array.get(opens, i)
float c_i = array.get(closes, i)
float v_i = array.get(volumes, i)
float range_i = math.max(h_i - l_i, syminfo.mintick)
controlSum += (c_i - l_i) / range_i
reactionSum += v_i / range_i
closeDomSum += math.abs(c_i - o_i) / range_i
if c_i > o_i
upBars += 1
float controlScore = controlSum / float(totalBars)
float volumeBiasScore = float(upBars) / float(totalBars)
float reactionAvg = reactionSum / float(totalBars)
float reactionScore = reactionAvg / math.max(ta.highest(reactionAvg, math.max(lookbackPeriod * 2, 10)), 1e-10)
reactionScore := math.min(1.0, reactionScore)
float closeDominanceScore = closeDomSum / float(totalBars)
float behaviorScore = (controlScore + volumeBiasScore + reactionScore + closeDominanceScore) / 4.0
float behaviorPerc = math.min(100.0, math.max(0.0, behaviorScore * 100.0))
int filledBehaviorBars = int(math.round(behaviorPerc / 100.0 * maxBarsDisplay))
string behaviorBar = f_buildBar(filledBehaviorBars, maxBarsDisplay)
color behaviorColor = behaviorPerc > 50 ? buyColor : sellColor
// === إنشاء الجدول (2 عمود، 4 صفوف) ===
if na(trendTable)
if tablePosition == "Top-Right"
trendTable := table.new(position.top_right, 2, 4, bgcolor=color.new(#121212, 90), border_color=color.gray, border_width=1)
else if tablePosition == "Top-Left"
trendTable := table.new(position.top_left, 2, 4, bgcolor=color.new(#121212, 90), border_color=color.gray, border_width=1)
else if tablePosition == "Bottom-Right"
trendTable := table.new(position.bottom_right, 2, 4, bgcolor=color.new(#121212, 90), border_color=color.gray, border_width=1)
else
trendTable := table.new(position.bottom_left, 2, 4, bgcolor=color.new(#121212, 90), border_color=color.gray, border_width=1)
// === الصف 1: الاتجاه ===
table.cell(trendTable, 0, 1, "الاتجاه", text_color=color.white, bgcolor=color.new(color.gray, 90))
table.cell(trendTable, 1, 1, diffText + " | " + visualBar, text_color=barColor, bgcolor=color.new(barColor, 80))
// === الصف 2: الديناميكية ===
table.cell(trendTable, 0, 2, "الديناميكية", text_color=color.white, bgcolor=color.new(color.gray, 90))
table.cell(trendTable, 1, 2, str.tostring(finalPerc, "#.##") + "% | " + dynamicBar, text_color=dynamicColor, bgcolor=color.new(dynamicColor, 80))
// === الصف 3: السلوك ===
table.cell(trendTable, 0, 3, "السلوك", text_color=color.white, bgcolor=color.new(color.gray, 90))
table.cell(trendTable, 1, 3, str.tostring(behaviorPerc, "#.##") + "% | " + behaviorBar, text_color=behaviorColor, bgcolor=color.new(behaviorColor, 80))
FPeriod = input(35, title='Fibo Period')
plotF1618 = input(title='Plot 1.618 Level?', defval=true)
Fhigh = ta.highest(FPeriod)
Flow = ta.lowest(FPeriod)
FH = ta.highestbars(high, FPeriod)
FL = ta.lowestbars(low, FPeriod)
downfibo = FH < FL
// تصغير حجم الإشارات مع الحفاظ على النص
plotshape(Flow, style=shape.labelup, location=location.absolute, size=size.tiny,
color=color.new(#000000, 40), textcolor=color.new(#c7c9d0, 0), show_last=1, text="🟢", offset=FL)
plotshape(Fhigh, style=shape.labeldown, location=location.absolute, size=size.tiny,
color=color.new(#000000, 30), textcolor=color.new(#e3e5e8, 0), show_last=1, text="🔴", offset=FH)
// === Inputs ===
trendLineLength = input.int(10, 'Trend Line Detection Sensitivity', minval=10)
upTlColor = input.color(color.new(color.teal, 15), title='Trend Line Colors', inline='tl')
downTlColor = input.color(color.new(color.red, 15), title=' ', inline='tl')
showTrendLines = input.bool(true, 'Show Trend Lines')
// === Helper Functions ===
extendTrendline(lineId, startIndex, startValue, endIndex, endValue) =>
slope = (endValue - startValue) / (endIndex - startIndex)
newEndIndex = bar_index
newEndValue = startValue + slope * (newEndIndex - startIndex)
line.set_x2(lineId, newEndIndex)
line.set_y2(lineId, newEndValue)
getSlope(startIndex, startValue, endIndex, endValue) =>
(endValue - startValue) / (endIndex - startIndex)
// === Trendlines Calculation ===
var line newBearishTrendline = na
var line newBullishTrendline = na
if showTrendLines
phTrend = ta.pivothigh(high, trendLineLength, trendLineLength)
plTrend = ta.pivotlow(low, trendLineLength, trendLineLength)
bullishTrendLineStart = ta.valuewhen(not na(plTrend), bar_index , 1)
bullishTrendLineEnd = ta.valuewhen(not na(plTrend), bar_index , 0)
bearishTrendLineStart = ta.valuewhen(not na(phTrend), bar_index , 1)
bearishTrendLineEnd = ta.valuewhen(not na(phTrend), bar_index , 0)
bullishTrendLineStartVal = ta.valuewhen(not na(plTrend), low , 1)
bullishTrendLineEndVal = ta.valuewhen(not na(plTrend), low , 0)
bearishTrendLineStartVal = ta.valuewhen(not na(phTrend), high , 1)
bearishTrendLineEndVal = ta.valuewhen(not na(phTrend), high , 0)
line.delete(newBearishTrendline)
line.delete(newBullishTrendline)
slopeBearish = getSlope(bearishTrendLineStart, bearishTrendLineStartVal, bearishTrendLineEnd, bearishTrendLineEndVal)
slopeBullish = getSlope(bullishTrendLineStart, bullishTrendLineStartVal, bullishTrendLineEnd, bullishTrendLineEndVal)
if slopeBearish < 0
newBearishTrendline := line.new(x1=bearishTrendLineStart, y1=bearishTrendLineStartVal, x2=bar_index, y2=bearishTrendLineEndVal, xloc=xloc.bar_index, color=downTlColor, width=2)
if slopeBullish > 0
newBullishTrendline := line.new(x1=bullishTrendLineStart, y1=bullishTrendLineStartVal, x2=bar_index, y2=bullishTrendLineEndVal, xloc=xloc.bar_index, color=upTlColor, width=2)
if not na(newBearishTrendline)
extendTrendline(newBearishTrendline, bearishTrendLineStart, bearishTrendLineStartVal, bearishTrendLineEnd, bearishTrendLineEndVal)
if not na(newBullishTrendline)
extendTrendline(newBullishTrendline, bullishTrendLineStart, bullishTrendLineStartVal, bullishTrendLineEnd, bullishTrendLineEndVal)
// ========== إعدادات FVG ==========
showFVG = input.bool(defval = true, title = "Show Fair Value Gaps", group = "FVG")
contract = input.bool(defval = false, title = "Contract Violated FVG", group = "FVG")
closeOnly = input.bool(defval = false, title = "Show Closest Up/Down FVG Only", group = "FVG")
fvgcol = input.color(defval = #f2da07, title = "FVG Color", group = "FVG")
fvgtra = input.int(defval = 30, minval = 0, maxval = 100, title = "FVG Transparency", group = "FVG")
// ========== دالة FVG ==========
fvg(direction) =>
var fvgMat = matrix.new(5)
var fvgDrawings = array.new()
fvgMat.add_col(0, array.from(math.sign(close - open), close, high, low, time))
if fvgMat.columns() > 3
fvgMat.remove_col(fvgMat.columns() - 1)
if fvgMat.row(0).sum() == direction
getDir = math.sign(direction)
= switch getDir
-1 =>
=>
col = switch closeOnly
true => #00000000
=> color.new(fvgcol, fvgtra)
fvgDrawings.push(
box.new(int(fvgMat.get(4, 1)), y, last_bar_time, y1, xloc = xloc.bar_time,
border_color = col, bgcolor = col)
)
fvgDrawings
// ========== تنفيذ FVG ==========
if showFVG
fvgDn = fvg(-3)
fvgUp = fvg(3)
// معالجة FVG الهابط
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getfvg = fvgDn.get(i)
if high >= getfvg.get_top()
getfvg.delete()
fvgDn.remove(i)
else if contract
if high > getfvg.get_bottom()
getfvg.set_bottom(high)
// معالجة FVG الصاعد
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getfvg = fvgUp.get(i)
if low <= getfvg.get_bottom()
getfvg.delete()
fvgUp.remove(i)
else if contract
if low < getfvg.get_top()
getfvg.set_top(low)
// إظهار أقرب FVG فقط
if closeOnly and barstate.islast
minDist = matrix.new(1, 2, 20e20)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getBottom = fvgDn.get(i).get_bottom()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getBottom)))
if math.abs(close - getBottom) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgDn.get(i).set_right(fvgDn.get(i).get_left())
fvgDn.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_right(last_bar_time)
minDist.set(0, 0, 0)
minDist.set(0, 1, 20e20)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getTop = fvgUp.get(i).get_top()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getTop)))
if math.abs(close - getTop) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgUp.get(i).set_right(fvgUp.get(i).get_left())
fvgUp.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_right(last_bar_time)
//----------------------------------------
// Key Levels - 4H Only
//----------------------------------------
Show_4H_Levels = input.bool(defval=true, title='عرض مستويات 4H', group='Key Levels')
Color_Resistance = input.color(title='لون المقاومة', defval=color.green, group='Key Levels', inline='colors')
Color_Support = input.color(title='لون الدعم', defval=color.red, group='Key Levels', inline='colors')
Style_4H_Levels = input.string('Dotted', 'نمط الخطوط', , group="Key Levels")
Text_4H_Levels = input.bool(defval=false, title='نص مختصر', group='Key Levels')
labelsize = input.string(defval='Medium', title='حجم النص', options= , group = "Key Levels")
// تعديل مستويات الدعم والمقاومة
Resistance_Offset = input.float(defval=0.0, title='تعديل المقاومة (نقاط)', step=0.01, group='تعديل المستويات', tooltip='رفع (+) أو خفض (-) مستوى المقاومة بالنقاط')
Support_Offset = input.float(defval=0.0, title='تعديل الدعم (نقاط)', step=0.01, group='تعديل المستويات', tooltip='رفع (+) أو خفض (-) مستوى الدعم بالنقاط')
// إعدادات خط المنتصف
Show_Middle_Line = input.bool(defval=true, title='عرض خط المنتصف', group='"0"')
Color_Middle = input.color(title='لون خط المنتصف', defval=color.blue, group='Key Levels')
//----------------------------------------
// Targets Settings
//----------------------------------------
Show_Targets = input.bool(defval=true, title='إظهار الأهداف', group='إعدادات الأهداف')
// أهداف صاعدة (بعد اختراق المقاومة)
Target1_Up_Distance = input.float(defval=0.5, title='المسافة للهدف الأول %', minval=0.01, step=0.1, group='أهداف الاختراق (صعود)')
Color_Target1_Up = input.color(title='لون الهدف الأول', defval=color.new(color.lime, 40), group='أهداف الاختراق (صعود)')
Target2_Up_Distance = input.float(defval=1.0, title='المسافة للهدف الثاني %', minval=0.01, step=0.1, group='أهداف الاختراق (صعود)')
Color_Target2_Up = input.color(title='لون الهدف الثاني', defval=color.new(color.lime, 20), group='أهداف الاختراق (صعود)')
Target3_Up_Distance = input.float(defval=1.5, title='المسافة للهدف الثالث %', minval=0.01, step=0.1, group='أهداف الاختراق (صعود)')
Color_Target3_Up = input.color(title='لون الهدف الثالث', defval=color.lime, group='أهداف الاختراق (صعود)')
// أهداف هابطة (بعد كسر الدعم)
Target1_Down_Distance = input.float(defval=0.5, title='المسافة للهدف الأول %', minval=0.01, step=0.1, group='أهداف الكسر (هبوط)')
Color_Target1_Down = input.color(title='لون الهدف الأول', defval=color.new(color.fuchsia, 40), group='أهداف الكسر (هبوط)')
Target2_Down_Distance = input.float(defval=1.0, title='المسافة للهدف الثاني %', minval=0.01, step=0.1, group='أهداف الكسر (هبوط)')
Color_Target2_Down = input.color(title='لون الهدف الثاني', defval=color.new(color.fuchsia, 20), group='أهداف الكسر (هبوط)')
Target3_Down_Distance = input.float(defval=1.5, title='المسافة للهدف الثالث %', minval=0.01, step=0.1, group='أهداف الكسر (هبوط)')
Color_Target3_Down = input.color(title='لون الهدف الثالث', defval=color.fuchsia, group='أهداف الكسر (هبوط)')
Style_Targets = input.string('Dashed', 'نمط خطوط الأهداف', , group="إعدادات الأهداف")
//----------------------------------------
// Signal Settings
//----------------------------------------
Show_Signals = input.bool(defval=true, title='إظهار إشارات البيع والشراء', group='إعدادات الإشارات')
Signal_Size = input.string(defval='Normal', title='حجم الإشارة', options= , group='إعدادات الإشارات')
Color_Buy_Signal = input.color(title='لون إشارة الشراء', defval=color.new(color.lime, 0), group='إعدادات الإشارات')
Color_Sell_Signal = input.color(title='لون إشارة البيع', defval=color.new(color.red, 0), group='إعدادات الإشارات')
//----------------------------------------
// FVG Settings
//----------------------------------------
Show_FVG = input.bool(defval=true, title='إظهار FVG', group='إعدادات FVG')
FVG_Lookback = input.int(defval=10, title='عدد الشموع للبحث عن FVG', minval=3, maxval=50, group='إعدادات FVG')
Color_Bullish_FVG = input.color(title='لون FVG الصاعد', defval=color.new(color.lime, 80), group='إعدادات FVG')
Color_Bearish_FVG = input.color(title='لون FVG الهابط', defval=color.new(color.red, 80), group='إعدادات FVG')
FVG_Border_Color = input.color(title='لون إطار FVG', defval=color.new(color.gray, 50), group='إعدادات FVG')
//========================================
// HELPER FUNCTIONS
//========================================
// Format price display
formatPrice(float price) =>
str.tostring(price, format.mintick)
// Get signal size
getSignalSize(string size_str) =>
switch size_str
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
'Large' => size.large
'Huge' => size.huge
=> size.normal
// Get line style
getLineStyle(string x) =>
switch x
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
=> line.style_solid
// Get font size
getFontSize(string size_str) =>
switch size_str
'Small' => size.small
'Medium' => size.normal
'Large' => size.large
=> size.normal
// Detect Bullish FVG
detectBullishFVG(int lookback) =>
float fvg_top = na
float fvg_bottom = na
int fvg_left = na
if bar_index >= 3
int max_bars = math.min(lookback, bar_index - 2)
for i = 1 to max_bars
if bar_index >= i + 1
if low > high
fvg_top := low
fvg_bottom := high
fvg_left := bar_index - i
break
// Detect Bearish FVG
detectBearishFVG(int lookback) =>
float fvg_top = na
float fvg_bottom = na
int fvg_left = na
if bar_index >= 3
int max_bars = math.min(lookback, bar_index - 2)
for i = 1 to max_bars
if bar_index >= i + 1
if high < low
fvg_top := low
fvg_bottom := high
fvg_left := bar_index - i
break
// Extend line to current bar
extendToCurrentBar(int offset_bars) =>
timenow + (time - time ) * offset_bars
//========================================
// MAIN CALCULATIONS
//========================================
// Get 4H levels
= request.security(syminfo.tickerid, '240', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '240', [time , low ], lookahead=barmerge.lookahead_on)
// Apply offsets to levels
float adjusted_resistance = intrah_value + Resistance_Offset
float adjusted_support = intral_value + Support_Offset
// Text labels
string resistance_text = Text_4H_Levels ? 'كول' : 'مقاومة'
string support_text = Text_4H_Levels ? 'بوت' : 'دعم'
// Style settings
int line_width = 1
string font_size = getFontSize(labelsize)
string line_style = getLineStyle(Style_4H_Levels)
string target_style = getLineStyle(Style_Targets)
int distance_right = 25
//========================================
// BREAKOUT DETECTION & TRACKING
//========================================
var bool resistance_broken = false
var bool support_broken = false
var float last_resistance = na
var float last_support = na
var int buy_signal_bar = na
var int sell_signal_bar = na
var float buy_signal_price = na
var float sell_signal_price = na
// Detect resistance breakout
if close > adjusted_resistance and not resistance_broken
resistance_broken := true
support_broken := false
last_resistance := adjusted_resistance
buy_signal_bar := bar_index
buy_signal_price := adjusted_resistance
// Detect support breakdown
if close < adjusted_support and not support_broken
support_broken := true
resistance_broken := false
last_support := adjusted_support
sell_signal_bar := bar_index
sell_signal_price := adjusted_support
// Cancel breakout if price returns
if close < adjusted_resistance and resistance_broken
resistance_broken := false
buy_signal_bar := na
buy_signal_price := na
if close > adjusted_support and support_broken
support_broken := false
sell_signal_bar := na
sell_signal_price := na
// Reset on new level formation
if adjusted_resistance != last_resistance
resistance_broken := false
last_resistance := adjusted_resistance
buy_signal_bar := na
buy_signal_price := na
if adjusted_support != last_support
support_broken := false
last_support := adjusted_support
sell_signal_bar := na
sell_signal_price := na
//========================================
// DRAWING - SUPPORT & RESISTANCE LEVELS
//========================================
if barstate.islast and Show_4H_Levels
int right_extension = extendToCurrentBar(distance_right)
// Draw Resistance Line
var line resistance_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Resistance, width=line_width, style=line_style)
line.set_xy1(resistance_line, intrah_time, adjusted_resistance)
line.set_xy2(resistance_line, right_extension, adjusted_resistance)
line.set_color(resistance_line, Color_Resistance)
var label resistance_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Resistance, size=font_size)
label.set_xy(resistance_label, right_extension, adjusted_resistance)
label.set_text(resistance_label, formatPrice(adjusted_resistance) + " " + resistance_text)
label.set_textcolor(resistance_label, Color_Resistance)
// Draw Support Line
var line support_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Support, width=line_width, style=line_style)
line.set_xy1(support_line, intral_time, adjusted_support)
line.set_xy2(support_line, right_extension, adjusted_support)
line.set_color(support_line, Color_Support)
var label support_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Support, size=font_size)
label.set_xy(support_label, right_extension, adjusted_support)
label.set_text(support_label, formatPrice(adjusted_support) + " " + support_text)
label.set_textcolor(support_label, Color_Support)
// Draw Middle Line
if Show_Middle_Line
float middle_price = (adjusted_resistance + adjusted_support) / 2
var line middle_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Middle, width=line_width, style=line_style)
line.set_xy1(middle_line, intrah_time, middle_price)
line.set_xy2(middle_line, right_extension, middle_price)
line.set_color(middle_line, Color_Middle)
var label middle_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Middle, size=font_size)
label.set_xy(middle_label, right_extension, middle_price)
label.set_text(middle_label, formatPrice(middle_price) +"0")
label.set_textcolor(middle_label, Color_Middle)
//========================================
// DRAWING - BULLISH TARGETS & SIGNALS
//========================================
if barstate.islast and Show_Targets and resistance_broken
int right_extension = extendToCurrentBar(distance_right)
// Buy Signal
if Show_Signals and not na(buy_signal_bar)
var label buy_label = label.new(na, na, text="شراء BUY", style=label.style_label_up, color=Color_Buy_Signal, textcolor=color.white, size=getSignalSize(Signal_Size))
label.set_xy(buy_label, buy_signal_bar, buy_signal_price)
label.set_color(buy_label, Color_Buy_Signal)
label.set_size(buy_label, getSignalSize(Signal_Size))
// Bullish FVG Box
if Show_FVG
= detectBullishFVG(FVG_Lookback)
if not na(bull_top) and not na(bull_bottom) and not na(bull_left)
var box bull_box = box.new(na, na, na, na, xloc=xloc.bar_index, bgcolor=Color_Bullish_FVG, border_color=FVG_Border_Color, border_width=1)
box.set_lefttop(bull_box, bull_left, bull_top)
box.set_rightbottom(bull_box, bar_index, bull_bottom)
box.set_bgcolor(bull_box, Color_Bullish_FVG)
box.set_border_color(bull_box, FVG_Border_Color)
// Calculate Target Prices
float target1_price = adjusted_resistance * (1 + Target1_Up_Distance / 100)
float target2_price = adjusted_resistance * (1 + Target2_Up_Distance / 100)
float target3_price = adjusted_resistance * (1 + Target3_Up_Distance / 100)
// Target 1
var line t1_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target1_Up, width=2, style=target_style)
line.set_xy1(t1_line, intrah_time, target1_price)
line.set_xy2(t1_line, right_extension, target1_price)
line.set_color(t1_line, Color_Target1_Up)
var label t1_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target1_Up, size=size.small)
label.set_xy(t1_label, right_extension, target1_price)
label.set_text(t1_label, formatPrice(target1_price) + " ⬆ T1")
label.set_textcolor(t1_label, Color_Target1_Up)
// Target 2
var line t2_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target2_Up, width=2, style=target_style)
line.set_xy1(t2_line, intrah_time, target2_price)
line.set_xy2(t2_line, right_extension, target2_price)
line.set_color(t2_line, Color_Target2_Up)
var label t2_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target2_Up, size=size.small)
label.set_xy(t2_label, right_extension, target2_price)
label.set_text(t2_label, formatPrice(target2_price) + " ⬆ T2")
label.set_textcolor(t2_label, Color_Target2_Up)
// Target 3
var line t3_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target3_Up, width=2, style=target_style)
line.set_xy1(t3_line, intrah_time, target3_price)
line.set_xy2(t3_line, right_extension, target3_price)
line.set_color(t3_line, Color_Target3_Up)
var label t3_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target3_Up, size=size.small)
label.set_xy(t3_label, right_extension, target3_price)
label.set_text(t3_label, formatPrice(target3_price) + " ⬆ T3")
label.set_textcolor(t3_label, Color_Target3_Up)
//========================================
// DRAWING - BEARISH TARGETS & SIGNALS
//========================================
if barstate.islast and Show_Targets and support_broken
int right_extension = extendToCurrentBar(distance_right)
// Sell Signal
if Show_Signals and not na(sell_signal_bar)
var label sell_label = label.new(na, na, text="بيع SELL", style=label.style_label_down, color=Color_Sell_Signal, textcolor=color.white, size=getSignalSize(Signal_Size))
label.set_xy(sell_label, sell_signal_bar, sell_signal_price)
label.set_color(sell_label, Color_Sell_Signal)
label.set_size(sell_label, getSignalSize(Signal_Size))
// Bearish FVG Box
if Show_FVG
= detectBearishFVG(FVG_Lookback)
if not na(bear_top) and not na(bear_bottom) and not na(bear_left)
var box bear_box = box.new(na, na, na, na, xloc=xloc.bar_index, bgcolor=Color_Bearish_FVG, border_color=FVG_Border_Color, border_width=1)
box.set_lefttop(bear_box, bear_left, bear_top)
box.set_rightbottom(bear_box, bar_index, bear_bottom)
box.set_bgcolor(bear_box, Color_Bearish_FVG)
box.set_border_color(bear_box, FVG_Border_Color)
// Calculate Target Prices
float target1_price = adjusted_support * (1 - Target1_Down_Distance / 100)
float target2_price = adjusted_support * (1 - Target2_Down_Distance / 100)
float target3_price = adjusted_support * (1 - Target3_Down_Distance / 100)
// Target 1
var line t1_down_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target1_Down, width=2, style=target_style)
line.set_xy1(t1_down_line, intral_time, target1_price)
line.set_xy2(t1_down_line, right_extension, target1_price)
line.set_color(t1_down_line, Color_Target1_Down)
var label t1_down_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target1_Down, size=size.small)
label.set_xy(t1_down_label, right_extension, target1_price)
label.set_text(t1_down_label, formatPrice(target1_price) + " ⬇ T1")
label.set_textcolor(t1_down_label, Color_Target1_Down)
// Target 2
var line t2_down_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target2_Down, width=2, style=target_style)
line.set_xy1(t2_down_line, intral_time, target2_price)
line.set_xy2(t2_down_line, right_extension, target2_price)
line.set_color(t2_down_line, Color_Target2_Down)
var label t2_down_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target2_Down, size=size.small)
label.set_xy(t2_down_label, right_extension, target2_price)
label.set_text(t2_down_label, formatPrice(target2_price) + " ⬇ T2")
label.set_textcolor(t2_down_label, Color_Target2_Down)
// Target 3
var line t3_down_line = line.new(na, na, na, na, xloc=xloc.bar_time, color=Color_Target3_Down, width=2, style=target_style)
line.set_xy1(t3_down_line, intral_time, target3_price)
line.set_xy2(t3_down_line, right_extension, target3_price)
line.set_color(t3_down_line, Color_Target3_Down)
var label t3_down_label = label.new(na, na, text="", xloc=xloc.bar_time, style=label.style_none, textcolor=Color_Target3_Down, size=size.small)
label.set_xy(t3_down_label, right_extension, target3_price)
label.set_text(t3_down_label, formatPrice(target3_price) + " ⬇ T3")
label.set_textcolor(t3_down_label, Color_Target3_Down)
// ===== إعدادات =====
src = input.source(close, "Source")
anchor = input.string( "top_right", "موقع الجدول", options= )
v_step = input.int(0, "تحريك عمودي 0 أعلى .. 1 أسفل", minval=0, maxval=1)
h_step = input.int(0, "تحريك أفقي 0 يسار .. 1 يمين", minval=0, maxval=1)
size_step = input.int(1, "حجم الخط 0 صغير جدًا .. 5 كبير", minval=0, maxval=5)
show_table = input.bool(true, "إظهار الجدول؟")
// ===== حساب RSI =====
r = ta.rsi(src, rsiLength)
// ===== حساب Flow (عرض وطلب) كمثال =====
FlowUp = close > open
FlowDown = close < open
FlowText = FlowUp ? "🟢" : FlowDown ? "🔴" : "⚪"
// ===== ألوان RSI =====
bgColor = r > 56 ? color.green : (r < 44 ? color.red : color.gray)
numColor = color.white
// ===== حجم الخط =====
textSizes = array.from(size.tiny, size.small, size.normal, size.large, size.large, size.large)
tsize = array.get(textSizes, size_step)
// ===== إنشاء جدول مصغر جدًا 2x2 =====
var int grid = 2
pos = anchor == "top_right" ? position.top_right :
anchor == "top_left" ? position.top_left :
anchor == "bottom_right" ? position.bottom_right : position.bottom_left
var table tbl = table.new(pos, grid, grid, frame_width=0, frame_color=color.black)
// ===== تحديث الجدول =====
if show_table
cellText = "قوة:" + str.tostring(r, "#.0") + FlowText
for row = 0 to grid-1
for col = 0 to grid-1
if row == v_step and col == h_step
table.cell(tbl, row, col, text=cellText, text_color=numColor, bgcolor=bgColor, text_size=tsize)
// # ========================================================================= #
// # | Colors |
// # ========================================================================= #
//#region
// # Core -------------------------------------------------------------------- #
colors_orange = color.rgb(246, 255, 0)
colors_blue = color.rgb(243, 246, 246)
colors_aqua = color.rgb(237, 245, 12)
colors_red = color.red
colors_green = color.rgb(246, 246, 16)
colors_maroon = color.maroon
colors_purple = color.rgb(9, 94, 253)
colors_gray = color.rgb(250, 6, 6)
colors_transparent = color.new(color.white,100)
//#endregion
// # ========================================================================= #
// # | End |
// # ========================================================================= #
// # ========================================================================= #
// # | Inputs |
// # ========================================================================= #
//#region
// # General ----------------------------------------------------------------- #
general_font = input.string("Monospace", "Text ", options = , inline = "5", group = "General")
general_text = input.string("Tiny", "", options = , inline = "5", group = "General", tooltip = "Customize global text size and style")
general_brand_show = input.bool(false, "Hide Brand", group = "General")
// # LKZ --------------------------------------------------------------------- #
hl_daily = input.bool(true, "Day ", inline = "1", group = "HTF Levels")
hl_weekly = input.bool(false, "Week ", inline = "2", group = "HTF Levels")
hl_monthly = input.bool(false, "Month ", inline = "3", group = "HTF Levels")
hl_quartely = input.bool(false, "Quarter ", inline = "4", group = "HTF Levels")
hl_yearly = input.bool(false, "Year ", inline = "5", group = "HTF Levels")
hl_css_daily = input.color(colors_blue, "", inline = "1", group = "HTF Levels")
hl_css_weekly = input.color(colors_green, "", inline = "2", group = "HTF Levels")
hl_css_monthly = input.color(colors_purple, "", inline = "3", group = "HTF Levels")
hl_css_quaterly = input.color(colors_maroon, "", inline = "4", group = "HTF Levels")
hl_css_yearly = input.color(colors_gray, "", inline = "5", group = "HTF Levels")
hl_line_daily = input.string('⎯⎯⎯', '', inline = '1', group = "HTF Levels", options = )
hl_line_weekly = input.string('⎯⎯⎯', '', inline = '2', group = "HTF Levels", options = )
hl_line_monthly = input.string('⎯⎯⎯', '', inline = '3', group = "HTF Levels", options = )
hl_line_quaterly = input.string('⎯⎯⎯', '', inline = '4', group = "HTF Levels", options = )
hl_line_yearly = input.string('⎯⎯⎯', '', inline = '5', group = "HTF Levels", options = )
hl_line_width_daily = input.int(1, '', inline = '1', group = "HTF Levels", minval = 1, maxval = 5)
hl_line_width_weekly = input.int(1, '', inline = '2', group = "HTF Levels", minval = 1, maxval = 5)
hl_line_width_monthly = input.int(1, '', inline = '3', group = "HTF Levels", minval = 1, maxval = 5)
hl_line_width_quaterly = input.int(1, '', inline = '4', group = "HTF Levels", minval = 1, maxval = 5)
hl_line_width_yearly = input.int(1, '', inline = '5', group = "HTF Levels", minval = 1, maxval = 5)
hl_midline = input.bool(true, "Show Average ", inline = "6" , group = "HTF Levels")
hl_midline_css = input.color(colors_aqua, "", inline = "6", group = "HTF Levels")
hl_midline_type = input.string("----", "", inline = "6", group = "HTF Levels", options = , tooltip = "Show highs & lows mid-line")
hl_midline_width = input.int(1, "", inline = "6", group = "HTF Levels", tooltip = "Change mid-line highs & lows width")
hl_openline = input.bool(true, "Show Open ", inline = "7" , group = "HTF Levels")
hl_openline_css = input.color(colors_orange, "", inline = "7", group = "HTF Levels")
hl_openline_type = input.string("····", "", inline = "7", group = "HTF Levels", options = , tooltip = "Show highs & lows mid-line")
hl_openline_width = input.int(1, "", inline = "7", group = "HTF Levels", tooltip = "Change mid-line highs & lows width")
//#endregion
// # ========================================================================= #
// # | End |
// # ========================================================================= #
// # ========================================================================= #
// # | UDTs |
// # ========================================================================= #
//#region
type UDT_Store
line hl_ln
label hl_lbl
type UDT_MTF
int x1 = na
int x2 = na
float y1 = na
float y2 = na
type UDT_HTF_Candle
string tf
// real coordinates of HTF candle
float o
float c
float h
float l
int ot
int ct
int ht
int lt
bool bull
//#endregion
// # ========================================================================= #
// # | End |
// # ========================================================================= #
// # ========================================================================= #
// # | Functions |
// # ========================================================================= #
//#region
method text_size(string size) =>
out = switch size
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
"Auto" => size.auto
out
method line_style(string line) =>
out = switch line
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
method font_style(string font) =>
out = switch font
'Default' => font.family_default
'Monospace' => font.family_monospace
shift_to_right(int current, int length, string tf) =>
current + timeframe.in_seconds(tf) * 1000 * (length + 1)
shift_to_left(int current, int prev, int length) =>
current - (current - prev) * length + 1
shift_bars_to_right(int bars) =>
bars + 20
//#endregion
// # ========================================================================= #
// # | End |
// # ========================================================================= #
// # ========================================================================= #
// # | Store |
// # ========================================================================= #
//#region
var UDT_Store bin = UDT_Store.new(hl_ln = array.new(), hl_lbl = array.new())
method clean_hl(UDT_Store store) =>
for obj in store.hl_ln
obj.delete()
for obj in store.hl_lbl
obj.delete()
store.hl_ln.clear()
store.hl_lbl.clear()
//#endregion
// # ========================================================================= #
// # | End |
// # ========================================================================= #
// # ========================================================================= #
// # | Highs & Lows MTF |
// # ========================================================================= #
//#region
method draw_pivots_ol_line(UDT_MTF mtf) =>
ol = line.new(
x1 = mtf.x1
, y1 = mtf.y1
, x2 = mtf.x2
, y2 = mtf.y2
, xloc = xloc.bar_time
, color = hl_openline_css
, style = line_style(hl_openline_type)
, width = hl_openline_width
)
bin.hl_ln.push(ol)
mtf
method draw_pivots_hl_line(UDT_MTF mtf, color css, string pdhl_style, int line_width) =>
hl = line.new(
x1 = mtf.x1
, y1 = mtf.y1
, x2 = mtf.x2
, y2 = mtf.y2
, xloc = xloc.bar_time
, color = css
, style = line_style(pdhl_style)
, width = line_width
)
bin.hl_ln.push(hl)
mtf
method draw_pivots_mid_line(UDT_MTF mtf) =>
ml = line.new(
x1 = mtf.x1
, y1 = mtf.y1
, x2 = mtf.x2
, y2 = mtf.y2
, xloc = xloc.bar_time
, color = hl_midline_css
, style = line_style(hl_midline_type)
, width = hl_midline_width
)
bin.hl_ln.push(ml)
mtf
method draw_pivots_ll_line(UDT_MTF mtf, color css, string pdhl_style, int line_width) =>
ll = line.new(
x1 = mtf.x1
, y1 = mtf.y1
, x2 = mtf.x2
, y2 = mtf.y2
, xloc = xloc.bar_time
, color = css
, style = line_style(pdhl_style)
, width = line_width
)
bin.hl_ln.push(ll)
mtf
method draw_pivots_label(UDT_MTF mtf, string fmt, string tf, color css) =>
lbl = label.new(
x = mtf.x2
, y = mtf.y2
, xloc = xloc.bar_time
, text = str.format(fmt, tf)
, color = colors_transparent
, textcolor = css
, size = text_size(general_text)
, style = label.style_label_left
, text_font_family = font_style(general_font)
)
bin.hl_lbl.push(lbl)
mtf
method mtf_pivots(UDT_HTF_Candle candle, tf, css
Chart patterns
فلتر فوليوم// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org
// © BigBeluga
//@version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low - area
, bar_index
, low - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high + area
, bar_index
, high + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//@version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = )
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
= request.security(syminfo.tickerid, res, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong بوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong كول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot
count := math.min(5, count + 1)
else if v_plot < v_plot
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong بوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong كول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org
// © BigBeluga
//@version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low - area
, bar_index
, low - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high + area
, bar_index
, high + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//@version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = )
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
= request.security(syminfo.tickerid, res, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
= request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong بوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong كول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot
count := math.min(5, count + 1)
else if v_plot < v_plot
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong بوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong كول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")
GainzAlgo V2 [Proficient]// © GainzAlgo
//@version=5
indicator('GainzAlgo V2 ', overlay=true, max_labels_count=500)
show_tp_sl = input.bool(true, 'Display TP & SL', group='Techical', tooltip='Display the exact TP & SL price levels for BUY & SELL signals.')
rrr = input.string('1:2', 'Risk to Reward Ratio', group='Techical', options= , tooltip='Set a risk to reward ratio (RRR).')
tp_sl_multi = input.float(1, 'TP & SL Multiplier', 1, group='Techical', tooltip='Multiplies both TP and SL by a chosen index. Higher - higher risk.')
tp_sl_prec = input.int(2, 'TP & SL Precision', 0, group='Techical')
candle_stability_index_param = 0.7
rsi_index_param = 60
candle_delta_length_param = 4
disable_repeating_signals_param = input.bool(true, 'Disable Repeating Signals', group='Techical', tooltip='Removes repeating signals. Useful for removing clusters of signals and general clarity.')
GREEN = color.rgb(29, 255, 40)
RED = color.rgb(255, 0, 0)
TRANSPARENT = color.rgb(0, 0, 0, 100)
label_size = input.string('huge', 'Label Size', options= , group='Cosmetic')
label_style = input.string('text bubble', 'Label Style', , group='Cosmetic')
buy_label_color = input(GREEN, 'BUY Label Color', inline='Highlight', group='Cosmetic')
sell_label_color = input(RED, 'SELL Label Color', inline='Highlight', group='Cosmetic')
label_text_color = input(color.white, 'Label Text Color', inline='Highlight', group='Cosmetic')
stable_candle = math.abs(close - open) / ta.tr > candle_stability_index_param
rsi = ta.rsi(close, 14)
atr = ta.atr(14)
bullish_engulfing = close < open and close > open and close > open
rsi_below = rsi < rsi_index_param
decrease_over = close < close
var last_signal = ''
var tp = 0.
var sl = 0.
bull_state = bullish_engulfing and stable_candle and rsi_below and decrease_over and barstate.isconfirmed
bull = bull_state and (disable_repeating_signals_param ? (last_signal != 'buy' ? true : na) : true)
bearish_engulfing = close > open and close < open and close < open
rsi_above = rsi > 100 - rsi_index_param
increase_over = close > close
bear_state = bearish_engulfing and stable_candle and rsi_above and increase_over and barstate.isconfirmed
bear = bear_state and (disable_repeating_signals_param ? (last_signal != 'sell' ? true : na) : true)
round_up(number, decimals) =>
factor = math.pow(10, decimals)
math.ceil(number * factor) / factor
if bull
last_signal := 'buy'
dist = atr * tp_sl_multi
tp_dist = rrr == '2:3' ? dist / 2 * 3 : rrr == '1:2' ? dist * 2 : rrr == '1:4' ? dist * 4 : dist
tp := round_up(close + tp_dist, tp_sl_prec)
sl := round_up(close - dist, tp_sl_prec)
if label_style == 'text bubble'
label.new(bar_index, low, 'BUY', color=buy_label_color, style=label.style_label_up, textcolor=label_text_color, size=label_size)
else if label_style == 'triangle'
label.new(bar_index, low, 'BUY', yloc=yloc.belowbar, color=buy_label_color, style=label.style_triangleup, textcolor=TRANSPARENT, size=label_size)
else if label_style == 'arrow'
label.new(bar_index, low, 'BUY', yloc=yloc.belowbar, color=buy_label_color, style=label.style_arrowup, textcolor=TRANSPARENT, size=label_size)
label.new(show_tp_sl ? bar_index : na, low, 'TP: ' + str.tostring(tp) + ' SL: ' + str.tostring(sl), yloc=yloc.price, color=color.gray, style=label.style_label_down, textcolor=label_text_color)
if bear
last_signal := 'sell'
dist = atr * tp_sl_multi
tp_dist = rrr == '2:3' ? dist / 2 * 3 : rrr == '1:2' ? dist * 2 : rrr == '1:4' ? dist * 4 : dist
tp := round_up(close - tp_dist, tp_sl_prec)
sl := round_up(close + dist, tp_sl_prec)
if label_style == 'text bubble'
label.new(bear ? bar_index : na, high, 'SELL', color=sell_label_color, style=label.style_label_down, textcolor=label_text_color, size=label_size)
else if label_style == 'triangle'
label.new(bear ? bar_index : na, high, 'SELL', yloc=yloc.abovebar, color=sell_label_color, style=label.style_triangledown, textcolor=TRANSPARENT, size=label_size)
else if label_style == 'arrow'
label.new(bear ? bar_index : na, high, 'SELL', yloc=yloc.abovebar, color=sell_label_color, style=label.style_arrowdown, textcolor=TRANSPARENT, size=label_size)
label.new(show_tp_sl ? bar_index : na, low, 'TP: ' + str.tostring(tp) + ' SL: ' + str.tostring(sl), yloc=yloc.price, color=color.gray, style=label.style_label_up, textcolor=label_text_color)
alertcondition(bull or bear, 'BUY & SELL Signals', 'New signal!')
alertcondition(bull, 'BUY Signals (Only)', 'New signal: BUY')
alertcondition(bear, 'SELL Signals (Only)', 'New signal: SELL')
Quasimodo Pattern Strategy Back Test [TradingFinder] QM Trading🔵 Introduction
The QM pattern, also known as the Quasimodo pattern, is one of the popular patterns in price action, and it is often used by technical analysts. The QM pattern is used to identify trend reversals and provides a very good risk-to-reward ratio. One of the advantages of the QM pattern is its high frequency and visibility in charts.
Additionally, due to its strength, it is highly profitable, and as mentioned, its risk-to-reward ratio is very good. The QM pattern is highly popular among traders in supply and demand, and traders also use this pattern.
The Price Action QM pattern, like other Price Action patterns, has two types: Bullish QM and Bearish QM patterns. To identify this pattern, you need to be familiar with its types to recognize it.
🔵 Identifying the QM Pattern
🟣 Bullish QM
In the bullish QM pattern, as you can see in the image below, an LL and HH are formed. As you can see, the neckline is marked as a dashed line. When the price reaches this range, it will start its upward movement.
🟣 Bearish QM
The Price Action QM pattern also has a bearish pattern. As you can see in the image below, initially, an HH and LL are formed. The neckline in this image is the dashed line, and when the LL is formed, the price reaches this neckline. However, it cannot pass it, and the downward trend resumes.
🔵 How to Use
The Quasimodo pattern is one of the clearest structures used to identify market reversals. It is built around the concept of a structural break followed by a pullback into an area of trapped liquidity. Instead of relying on lagging indicators, this pattern focuses purely on price action and how the market reacts after exhausting one side of liquidity. When understood correctly, it provides traders with precise entry points at the transition between trend phases.
🟣 Bullish Quasimodo
A bullish Quasimodo forms after a clear downtrend when sellers start losing control. The market continues to make lower lows until a sudden higher high appears, signaling that buyers are entering with strength. Price then pulls back to retest the previous low, creating what is known as the Quasimodo low.
This area often becomes the final trap for sellers before the market shifts upward. A visible rejection or displacement from this zone confirms bullish momentum. Traders usually place entries near this level, stops below the low, and targets at previous highs or the next resistance zone. Combining the setup with demand zones or Fair Value Gaps increases its accuracy.
🟣 Bearish Quasimodo
A bearish Quasimodo forms near the top of an uptrend when buyers begin to lose strength. The market continues to make higher highs until a sudden lower low breaks the bullish structure, showing that selling pressure is entering the market. Price then retraces upward to retest the previous high, forming the Quasimodo high, where breakout buyers are often trapped.
Once rejection appears at this level, it indicates a likely reversal. Traders can enter short near this area, with stop-losses placed above the high and targets near the next support or previous lows. The setup gains more reliability when aligned with supply zones, SMT divergence, or bearish Fair Value Gaps.
🔵 Setting
Pivot Period : You can use this parameter to use your desired period to identify the QM pattern. By default, this parameter is set to the number 5.
Take Profit Mode : You can choose your desired Take Profit in three ways. Based on the logic of the QM strategy, you can select two Take Profit levels, TP1 and TP2. You can also choose your take profit based on the Reward to Risk ratio. You must enter your desired R/R in the Reward to Risk Ratio parameter.
Stop Loss Refine : The loss limit of the QM strategy is based on its logic on the Head pattern. You can refine it using the ATR Refine option to prevent Stop Hunt. You can enter your desired coefficient in the Stop Loss ATR Adjustment Coefficient parameter.
Reward to Risk Ratio : If you set Take Profit Mode to R/R, you must enter your desired R/R here. For example, if your loss limit is 10 pips and you set R/R to 2, your take profit will be reached when the price is 20 pips away from your entry point.
Stop Loss ATR Adjustment Coefficient : If you set Stop Loss Refine to ATR Refine, you must adjust your loss limit coefficient here. For example, if your buy position's loss limit is at the price of 1000, and your ATR is 10, if you set Stop Loss ATR Adjustment Coefficient to 2, your loss limit will be at the price of 980.
Entry Level Validity : Determines how long the Entry level remains valid. The higher the level, the longer the entry level will remain valid. By default it is 2 and it can be set between 2 and 15.
🔵 Results
The following examples show the backtest results of the Quasimodo (QM) strategy in action. Each image is based on specific settings for the symbol, timeframe, and input parameters, illustrating how the QM logic can generate signals under different market conditions. The detailed configuration for each backtest is also displayed on the image.
⚠ Important Note : Even with identical settings and the same symbol, results may vary slightly across different brokers due to data feed variations and pricing differences.
Default Properties of Backtests :
OANDA:XAUUSD | TimeFrame: 5min | Duration: 1 Year :
BINANCE:BTCUSD | TimeFrame: 5min | Duration: 1 Year :
CAPITALCOM:US30 | TimeFrame: 5min | Duration: 1 Year :
NASDAQ:QQQ | TimeFrame: 5min | Duration: 5 Year :
OANDA:EURUSD | TimeFrame: 5min | Duration: 5 Year :
PEPPERSTONE:US500 | TimeFrame: 5min | Duration: 5 Year :
Strict Engulfing + Rich Email Alerts (v6, stable)an engulfing pattern indicator designed to alert whenever the pattern forms in the chart. this is killer pattern when used together with market structure. not final version though
MACD crossover while RSI Oversold/Overbought# MACD Crossover with RSI Overbought/Oversold Indicator Explained
## Indicator Overview
This is a trading signal system that combines two classic technical indicators: **MACD (Moving Average Convergence Divergence)** and **RSI (Relative Strength Index)**. Its core logic is: MACD crossover signals are only triggered when RSI is in extreme zones (overbought/oversold), thereby filtering out many false signals and improving trading accuracy.
## Core Principles
### 1. **Dual Confirmation Mechanism**
This indicator doesn't use MACD or RSI alone, but requires both conditions to be met simultaneously:
- **Short Signal (Orange Triangle)**: MACD bearish crossover (fast line crosses below signal line) + RSI was overbought (≥71)
- **Long Signal (Green Triangle)**: MACD bullish crossover (fast line crosses above signal line) + RSI was oversold (≤29)
### 2. **RSI Memory Function**
The indicator checks the RSI values of the current and past 5 candlesticks. As long as any one of them reaches the overbought/oversold level, the condition is satisfied. This design avoids overly strict requirements, as RSI may have already left the extreme zone before the MACD crossover occurs.
```pine
wasOversold = rsi <= 29 or rsi <= 29 or ... or rsi <= 29
wasOverbought = rsi >= 71 or rsi >= 71 or ... or rsi >= 71
```
## Parameter Settings
### MACD Parameters
- **Fast MA**: 12 periods (adjustable 7-∞)
- **Slow MA**: 26 periods (adjustable 7-∞)
- **Signal Line**: 9 periods
### RSI Parameters
- **Oversold Threshold**: 29 (traditional 30)
- **Overbought Threshold**: 71 (traditional 70)
- **Calculation Period**: 14
## Visual Elements
### 1. **Signal Markers**
- 🔻 **Orange Downward Triangle**: Appears above the candlestick, labeled "overbought", indicating a shorting opportunity
- 🔺 **Green Upward Triangle**: Appears below the candlestick, labeled "oversold", indicating a long opportunity
### 2. **Price Level Lines**
- **Orange Dashed Line**: Extends rightward from the high of the short signal, serving as a potential resistance level
- **Green Dashed Line**: Extends rightward from the low of the long signal, serving as a potential support level
Each time a new signal appears, the old level line is deleted, keeping only the most recent reference line.
## Trading Logic Explained
### Short Signal Scenario
1. Price rises, RSI surges above 71 (market overheated)
2. Momentum subsequently weakens, MACD fast line crosses below signal line
3. Indicator draws an orange triangle at the high, alerting to reversal risk
4. Orange dashed line marks the high point of the short entry position
### Long Signal Scenario
1. Price falls, RSI drops below 29 (market oversold)
2. Selling pressure exhausted, MACD fast line crosses above signal line
3. Indicator draws a green triangle at the low, suggesting a rebound opportunity
4. Green dashed line marks the low point of the long entry position
## Advantages and Limitations
### ✅ Advantages
- **Filters Noise**: Reduces false signals through dual confirmation
- **Captures Reversals**: Catches trend reversals in extreme conditions
- **Visual Clarity**: Level lines help identify support/resistance
- **Built-in Alerts**: Can set up message push notifications
### ⚠️ Limitations
- **Lag**: Both indicators are lagging, signals may be delayed
- **Poor Performance in Ranging Markets**: Prone to whipsaws during consolidation
- **Needs Other Analysis**: Should not be the sole decision-making basis
- **Parameter Sensitivity**: Different markets and timeframes may require parameter adjustments
## Practical Trading Suggestions
1. **Confirm Trend Context**: Counter-trend signals carry high risk in strong trending markets
2. **Combine with Candlestick Patterns**: Confirm with patterns (such as engulfing, hammer candles)
3. **Set Stop Losses**: Use level lines as stop-loss references (long stop below green line, short stop above orange line)
4. **Watch Volume**: Signals accompanied by high volume are more reliable
5. **Multi-Timeframe Verification**: Signals appearing simultaneously on daily and 4-hour charts are more credible
## Summary
This indicator follows the "mean reversion from extremes" philosophy, seeking reversal opportunities when market sentiment becomes excessive. It's suitable for auxiliary judgment, particularly in swing trading and position trading strategies. But remember, no indicator is perfect—always combine risk management and multi-dimensional analysis when making trading decisions
Multi-EMA Session Breakout Strategythis is a strategy that use the session high and low and the EMA LOWS 2 3 6 9 110 355 AND 480
Choch Pattern Levels WITH ALERTS [credit to: @BigBeluga]🔵 OVERVIEW
The Choch Pattern Levels WITH ALERTS indicator automatically detects Change of Character (CHoCH) shifts in market structure — crucial moments that often signal early trend reversals or major directional transitions. It plots the structural break level, visualizes the pattern zone with triangle overlays, and tracks delta volume to help traders assess the strength behind each move. Now, an additional feature of alerts have been included!
🔵 CONCEPTS
CHoCH Pattern: A bullish CHoCH forms when price breaks a previous swing high after a swing low, while a bearish CHoCH appears when price breaks a swing low after a prior swing high.
snapshot
Break Level Mapping: The indicator identifies the highest or lowest point between the pivot and the breakout, marking it with a clean horizontal level where price often reacts.
snapshot
Delta Volume Tracking: Net bullish or bearish volume is accumulated between the pivot and the breakout, revealing the momentum and conviction behind each CHoCH.
snapshot
Chart Clean-Up: If price later closes through the CHoCH level, the zone is automatically removed to maintain clarity and focus on active setups only.
🔵 FEATURES
Automatic CHoCH pattern detection using pivot-based logic.
Triangle shapes show structure break: pivot → breakout → internal high/low.
snapshot
snapshot
Horizontal level marks the structural zone with a ◯ symbol.
snapshot
Optional delta volume label with directional sign (+/−).
Green visuals for bullish CHoCHs, red for bearish.
Fully auto-cleaning invalidated levels to reduce clutter.
Clean organization of all lines, labels, and overlays.
User-defined Length input to adjust pivot sensitivity.
snapshot
NEW! - alert system inserted to Pinescript for either: any triangle forms or whether a bullish "green" triangle or bearish "red" triangle forms - providing real-time alerts for whenever timeframe chart you've selected while creating the alert.
🔵 HOW TO USE
Use CHoCH levels as early trend reversal zones or confirmation signals.
Treat bullish CHoCHs as support zones, bearish CHoCHs as resistance.
Look for high delta volume to validate the strength behind each CHoCH.
Combine with other BigBeluga tools like supply/demand, FVGs, or liquidity maps for confluence.
Adjust pivot Length based on your strategy — shorter for intraday, longer for swing trading.
🔵 CONCLUSION
Choch Pattern Levels WITH ALERTS highlights key structural breaks that can mark the start of new trends. By combining precise break detection with volume analytics and automatic cleanup, it provides actionable insights into the true intent behind price moves — giving traders a clean edge in spotting early reversals and key reaction zones with real-time alerts for precision to evaluate and enter markets.
4/8/15 EMA + Classic & Camarilla PivotsSays it all in the title...4/8/15 EMA + Classic & Camarilla Pivots without setting up difficult choices on TOS. Stay on the right side of the 15. Let it detach from the 8 and follow it up. If you are entangled in the 4/8, time to bail in my humble opinon. For Scalpers and intraday traders.
Previous Day/Week/Month OHLC for renko (from Regular Candles)this indiactor gives you previous day/week/month levels on a renko chart based on the ohlc data of normal candles
4/8/15 EMA + Classic & Camarilla PivotsEssentially this is what you can get on TOS but everything included in one chart.
4/8/15 EMA Overlaya simple script to overlay your 4/8/15. If it clears the 8, it usually will raise. If it stays entangled with the 4/8, it rarely breaks above.
Green Pen Tail TP V.8.5 fibo Patterns - Defines which pattern will be drawn depending on its status. Possible values: All, Awaiting and Reached, Only Awaiting, Last Awaiting. If Last Awaiting is selected, only one pattern with the Awaiting status will be displayed, the first point of which is located to the right of all the others.
Price Targets - Defines which price targets will be drawn depending status of the pattern. Possible values: All, Only Awaiting, Awaiting and Reached, None.
In Progress – Search for emerging patterns.
Trendline Detector - 3 TimeframesThis advanced Pine Script indicator automatically identifies and draws diagonal support and resistance trendlines across three customizable timeframes simultaneously.
Key Features:
Multi-Timeframe Analysis: Configure three independent sets (A, B, C) to analyze different timeframes on a single chart
Smart Pivot Detection: Identifies local minimums and maximums based on open/close prices rather than wicks, reducing false signals from volatile candle shadows
Automatic Trendline Drawing: Calculates ascending support lines from pivot lows and descending resistance lines from pivot highs
Touch Validation: Only displays trendlines that meet your minimum touch requirements, ensuring statistical significance
Customizable Parameters: Full control over lookback period, pivot window size, deviation tolerance, and minimum touches for each timeframe
Visual Pivot Markers: Optional display of all detected pivot points with color-coded arrows (green for lows, red for highs)
Extended Lines: All valid trendlines extend to the right for forward projection
How It Works:
The indicator scans historical bars within your specified lookback period to identify pivot points. It then evaluates all possible trendline combinations, counting how many price points touch each potential line within your deviation tolerance. The trendline with the most touches (meeting your minimum requirement) is displayed.
Parameter Breakdown:
Each set (A, B, C) includes five critical parameters:
Timeframe: The chart timeframe for analysis (e.g., "1" for 1-minute, "15" for 15-minute, "1D" for daily)
Lookback Bars: How many historical bars to scan for pivot points (default: 250). Higher values capture longer-term trends but may increase computation time.
Min Touches: Minimum number of price touches required for a trendline to be considered valid (default: 3). Higher values ensure stronger, more reliable trendlines but may filter out emerging trends.
Deviation %: Percentage tolerance for what constitutes a "touch" (default: 0.1-1.0%). A 0.5% deviation means prices within 0.5% of the theoretical trendline are counted as touches. Lower values create stricter trendlines; higher values are more forgiving.
Pivot Window: Number of bars on each side used to identify local highs/lows (default: 5). A pivot window of 5 means the center bar must be the highest/lowest among 11 bars total (5 left + center + 5 right). Larger values identify more significant pivots but may miss shorter-term turning points.
Display Options:
Show Min/Max Points: Toggle visibility of pivot point markers to see exactly which price levels the algorithm identified as potential trendline anchors.
Perfect For:
Swing traders looking for multi-timeframe confluence zones
Technical analysts who rely on diagonal support/resistance levels
Traders who want automated trendline detection without manual drawing
Anyone seeking to identify trend channels and breakout opportunities
Color Coding:
Support lines are displayed in green with varying transparency, while resistance lines appear in red. Each timeframe set can be independently enabled/disabled based on which chart timeframe you're currently viewing, preventing clutter and maintaining clarity.
Technical Notes:
The indicator uses efficient algorithms to process large datasets while maintaining accuracy. It avoids repainting by only considering confirmed pivot points. The algorithm prioritizes trendlines with more touches and, in case of ties, favors more recent formations with steeper angles for maximum relevance.
SSMT + HSSMT Detector- Q to Q Analysis- (by FINOR V10.1)📘 Description
This indicator detects Same-Side Market Trend (SSMT) and Hidden Same-Side Market Trend (HSSMT) divergences between three correlated symbols, providing multi-timeframe intermarket structure analysis.
It works entirely in a Q-based framework, allowing precise identification of structural inefficiencies between related markets.
🕒 Session Structure and Logic
The script divides price data into four time scopes:
1️⃣ Daily Session
2️⃣ 6-hour Session
3️⃣ 90-minute Session
4️⃣ 22.5-minute Session
Each of these sessions is split into consecutive Q intervals (quarters).
Within each Q, the algorithm detects local highs and lows for each of the three selected symbols.
⚙️ How It Works
Q Analysis:
For each session type, the algorithm evaluates the price structure of each symbol inside every Q.
It identifies swing highs and lows to map short-term market structure boundaries.
Inter-Q Comparison:
The script compares consecutive Q periods to locate structural asymmetries — situations where correlated symbols fail to move in sync.
These asymmetries often reveal intermarket inefficiencies and potential reversals or continuations.
SSMT Detection:
The SSMT logic checks for divergence in highs and lows between the selected symbols.
For example, if Symbol A makes a higher high but Symbol B does not, an SSMT signal is generated.
HSSMT Detection:
The HSSMT logic performs a similar analysis but based solely on closing prices, detecting hidden divergences that may appear within continuation phases rather than reversals.
🧭 Visualization and Alerts
Each detected event is labeled directly on the chart with visual tags showing whether it is an SSMT or HSSMT event.
Color-coded markers distinguish between highs, lows, and closes depending on the detected structure.
Optional smart alerts instantly notify the trader when a new SSMT or HSSMT signal is found.
💡 Use Cases
Confirm institutional SMT setups across correlated indices or assets.
Detect non-synchronous behavior between correlated pairs for early reversal confirmation.
Identify continuation or exhaustion points in multi-symbol price action.
🧠 Summary
This tool provides an advanced, multi-timeframe method to visualize and quantify intermarket divergences using a Q-segmented framework.
It allows traders to observe both explicit (SSMT) and hidden (HSSMT) inefficiencies between correlated symbols in real time — a capability not available in standard open-source SMT detectors.
📊 Multi-TF Bias + Premium/Discount by Dayn12SirРусский
Мультитаймфреймовый индикатор с концепциями Smart Money для поиска точек входа.
Основные функции:
Multi-Timeframe Bias: анализ тренда на 5 таймфреймах (EMA, RSI, структура)
Confluence Score: подсчёт подтверждений от разных таймфреймов (0-5)
Premium/Discount зоны: Fibonacci уровни от Swing High/Low
Premium (61.8%-100%): не лонговать ❌
Equilibrium (38.2%-61.8%): обе стороны ✅
Discount (0%-38.2%): не шортить ❌
Liquidity Grabs: обнаружение захватов ликвидности с фильтрацией
Сигналы входа: 🚀 STRONG LONG / 🔻 STRONG SHORT
Как использовать:
Проверьте Confluence (4-5/5 = сильный сигнал 💪)
Убедитесь что цена в правильной зоне (Discount для LONG, Premium для SHORT)
Ждите 💧 Liquidity Grab + сигнал входа
Входите только если старшие таймфреймы подтверждают
Настройки:
5 таймфреймов (по умолчанию: 5m, 15m, 1H, 4H, D)
EMA периоды (20/50)
RSI уровни (40/60)
Период ликвидности (20)
Минимальный Confluence (3/5)
Таймфрейм для P/D зон (4H)
⚠️ Не перерисовывается. Лучше работает на трендовых рынках.
🇬🇧 English
Multi-timeframe bias indicator with Smart Money Concepts for high-probability entries.
Key Features:
Multi-Timeframe Bias: trend analysis across 5 timeframes (EMA, RSI, structure)
Confluence Score: counts confirmations from different timeframes (0-5)
Premium/Discount Zones: Fibonacci levels from Swing High/Low
Premium (61.8%-100%): don't long ❌
Equilibrium (38.2%-61.8%): both directions ✅
Discount (0%-38.2%): don't short ❌
Liquidity Grabs: detects liquidity sweeps with filtering
Entry Signals: 🚀 STRONG LONG / 🔻 STRONG SHORT
How to Use:
Check Confluence (4-5/5 = strong signal 💪)
Ensure price is in correct zone (Discount for LONG, Premium for SHORT)
Wait for 💧 Liquidity Grab + entry signal
Only enter if higher timeframes confirm
Settings:
5 timeframes (default: 5m, 15m, 1H, 4H, D)
EMA periods (20/50)
RSI levels (40/60)
Liquidity period (20)
Minimum Confluence (3/5)
P/D zones timeframe (4H)
⚠️ Non-repainting. Works best on trending markets.
💡 Tip: Best results when 4+ timeframes align + liquidity grab in discount/premium zone!
Multi-EMA Strategy (Low Source)this strategy use the ema low for its functionality 8 9 110 355 and 480
Trend Indicator🚀 Trend Indicator Pro – The Smart Money Edge
Catch Every Major Trend Shift – The Moment It Happens.
(Image of chart not shown correctly, message me for a screenshot)
Instantly See the Trend. Trade with Confidence.
Tired of guessing tops and bottoms? Trend Indicator Pro turns chaos into clarity with real-time, color-coded candles and pinpoint entry arrows – no lag, no noise.
How It Works
Smart Volatility Bands
Dynamically adapt to market conditions using ATR-based trailing logic – tighter in calm markets, wider in chaos.
One-Candle Trend Detection
The exact bar a trend flips is highlighted:
Purple Candle + ▲ → Fresh Uptrend Starting
Yellow Candle + ▼ → Downtrend Confirmed
Visual Trend Lock™
Green Candles = Ride the uptrend
Red Candles = Short or stand aside
→ No second-guessing.
Low Volume Detector//@version=5
indicator("Low Volume Detector", overlay=true)
// Parameters
length = input.int(20, title="Volume MA Length")
threshold = input.float(0.5, title="Low Volume Threshold (as % of MA)", minval=0.1, step=0.1)
// Volume logic
vol = volume
volMA = ta.sma(vol, length)
lowVol = vol < (volMA * threshold)
// Plot background when volume is low
bgcolor(lowVol ? color.new(color.red, 85) : na, title="Low Volume Background")
// Optional: plot volume and its MA in separate pane
plot(vol, title="Volume", color=color.gray, style=plot.style_columns)
plot(volMA, title="Volume MA", color=color.orange)
Major exchages total Open interest & Long/Short OI trends📊 Indicator: Major Exchanges Total OI & Long/Short Trends
This Pine Script™ indicator is designed to provide a comprehensive analysis of Open Interest (OI) and Long/Short position trends across major cryptocurrency exchanges (Binance, Bybit, OKX, Bitget, HTX, Deribit). It serves as a powerful tool for traders seeking to understand market liquidity, participant positioning, and overall market sentiment.
🔑 Key Features and Functionalities
Aggregated Multi-Exchange Open Interest (OI):
Consolidates real-time Open Interest data from user-selected major cryptocurrency exchanges.
Provides a unified view of the total OI, offering insights into the collective market liquidity and the aggregate size of participants' open positions.
Visualized Combined OI Candles:
Presents the aggregated total OI data in a candlestick chart format.
Displays the Open, High, Low, and Close of the combined OI, with color variations indicating increases or decreases from the previous period. This enables intuitive visualization of OI trend shifts.
Estimated Long/Short OI and Visualization:
Calculates and visualizes estimated Long and Short position Open Interest based on the total aggregated OI data.
Estimation Logic:
Employs a sophisticated logic that considers both price changes and OI fluctuations to infer the balance between Long and Short positions. For instance, an increase in both price and OI may suggest an accumulation of Long positions, while a price decrease coupled with an OI increase might indicate growing Short positions.
Initial 50:50 Ratio:
The estimation for Long/Short OI begins with an assumption of a 50:50 ratio at the initial data point available for the selected timeframe. This establishes a neutral baseline, from which subsequent price and OI changes drive the divergence and evolution of the estimated Long/Short balance.
Flexible Visualization Options:
Allows users to display Long/Short OI data in either line or candlestick styles, with customizable color schemes. This flexibility aids in clearly discerning bullish or bearish positioning trends.
💡 Development Background
The development of this indicator stems from the critical importance of Open Interest data in the cryptocurrency derivatives market. Recognizing the limitations of analyzing individual exchange OI in isolation, the primary objective was to integrate data from leading exchanges to offer a holistic perspective on market sentiment and overall positioning dynamics.
The inclusion of the Long/Short position estimation feature is crucial for deciphering the specific directional biases of market participants, which is often not evident from raw OI data alone. This enables a deeper understanding of how positions are being accumulated or liquidated, moving beyond simple OI change analysis.
Furthermore, a key design consideration was to leverage the characteristic where the indicator's data start point dynamically adjusts with the chart's timeframe selection. This allows for the analysis of short-term Long/Short trends on shorter timeframes and long-term trends on longer timeframes. This inherent flexibility empowers traders to conduct analyses across various time scales, aligning with their diverse trading strategies.
🚀 Trading Applications
Leveraging Combined Open Interest (OI):
Trend Confirmation: A sustained increase in total OI signifies growing market interest and capital inflow, potentially confirming the strength of an existing trend. Conversely, decreasing OI may suggest diminishing participant interest or widespread position liquidation.
Validation of Price Extremes: If price forms a new high but OI fails to increase or declines, it could signal a potential trend reversal (divergence). Conversely, a sharp increase in OI during a price decline might indicate a surge in short positions or renewed selling pressure.
Identifying Volatility Triggers: Monitoring rapid shifts in OI during significant news events or market catalysts can help assess immediate market reactions and liquidity changes.
📈Utilizing Long/Short OI Trends
Assessing Market Bias: A sustained dominance or rapid increase in Long OI suggests a prevalent bullish sentiment, which could inform decisions to enter or maintain long positions. The inverse scenario indicates bearish sentiment and potential short entry opportunities.
Anticipating Squeezes: The indicator can help identify scenarios conducive to short or long squeezes. Excessive short positioning followed by a price uptick can trigger a short squeeze, leading to rapid price appreciation. Conversely, an oversupply of long positions preceding a price drop can result in a long squeeze and sharp declines.
Divergence Analysis: Divergences between price action and Long/Short OI estimates can signal potential trend reversals. For example, if price is rising but the increase in Long OI slows down or Short OI begins to grow, it may suggest weakening buying pressure.
🕔Timeframe-Specific Trend Analysis:
Shorter Timeframes (e.g., 1m, 5m, 15m): Ideal for identifying short-term shifts in participant positioning, beneficial for day trading and scalping strategies. Provides insights into immediate market reactions to price movements.
Longer Timeframes (e.g., 1h, 4h, Daily): Valuable for evaluating broader positioning trends and the sustainability or potential reversal of medium-to-long-term trends. Offers a macro perspective on Long/Short dynamics, suitable for swing trading or long-term investment strategies.
This indicator integrates complex market data, provides nuanced Long/Short position estimations, and offers multi-timeframe analytical capabilities, empowering traders to make more informed and strategic decisions.
ERR FIX 100% SILVER 300 06 -0.2 1 POSITIONAL ALGO EXITpositionalpositionalpositionalpositionalpositionalpositional























