PROTECTED SOURCE SCRIPT
Ichimoku + SuperTrend + Oscillator + Divergence + SMC Lite

//version=5
indicator("Ichimoku + SuperTrend + Oscillator + Divergence + SMC Lite", overlay=true, max_labels_count=500, max_lines_count=500, max_boxes_count=500, max_bars_back=1000)
// ====================
// === CODE BLOCK 1: Ichimoku + SuperTrend + Oscillator Monitor + Divergence ===
// ====================
// --- User Inputs ---
lowerTF = input.timeframe("5", "Lower Timeframe (Ichimoku + SuperTrend)")
higherTF = input.timeframe("60", "Higher Timeframe (Tenkan/Kijun check)")
tenkanLength = input.int(9, "Tenkan-sen Length (Lower TF)")
kijunLength = input.int(26, "Kijun-sen Length (Lower TF)")
senkouSpanBLength = input.int(52, "Senkou Span B Length (Lower TF)")
displacement = input.int(26, "Displacement (Lower TF)")
showCloud = input.bool(true, "Show Kumo Cloud (Lower TF)")
buyColor = input.color(color.new(color.green, 0), "Buy Candle Color")
sellColor = input.color(color.new(color.red, 0), "Sell Candle Color")
crossCandleColor = input.color(color.new(color.yellow, 0), "Cross Candle Color")
bodyFilterColor = input.color(color.new(color.lime,0), "Body Filter Active Color")
htfCrossColor = input.color(color.new(color.orange,0), "HTF Cross Signal Color")
stopColor = input.color(color.new(color.red,0), "Stop Line Color")
targetColor = input.color(color.new(color.blue,0), "Target Line Color")
cooldownBars = input.int(5, "Cooldown Bars After Signal")
// --- Higher TF Ichimoku ---
tenkanLengthHTF = input.int(36, "Tenkan Length (Higher TF)")
kijunLengthHTF = input.int(103, "Kijun Length (Higher TF)")
showTenkanHTF = input.bool(true, "Show Tenkan (HTF)")
showKijunHTF = input.bool(true, "Show Kijun (HTF)")
tenkanHTFValue = request.security(syminfo.tickerid, higherTF, (ta.highest(high, tenkanLengthHTF)+ta.lowest(low, tenkanLengthHTF))/2)
kijunHTFValue = request.security(syminfo.tickerid, higherTF, (ta.highest(high, kijunLengthHTF)+ta.lowest(low, kijunLengthHTF))/2)
plot(showTenkanHTF ? tenkanHTFValue : na, color=color.blue, linewidth=2, title="Tenkan HTF")
plot(showKijunHTF ? kijunHTFValue : na, color=color.red, linewidth=2, title="Kijun HTF")
// --- Lower TF Ichimoku ---
tenkan = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, tenkanLength) + ta.lowest(low, tenkanLength)) / 2)
kijun = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, kijunLength) + ta.lowest(low, kijunLength)) / 2)
senkouA = request.security(syminfo.tickerid, lowerTF, (tenkan + kijun) / 2)
senkouB = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, senkouSpanBLength) + ta.lowest(low, senkouSpanBLength)) / 2)
plot(tenkan, color=color.blue, title="Tenkan-sen (LTF)", linewidth=2)
plot(kijun, color=color.red, title="Kijun-sen (LTF)", linewidth=2)
sA = plot(senkouA[displacement], display=display.none)
sB = plot(senkouB[displacement], display=display.none)
cloudColor = showCloud ? (senkouA[displacement] > senkouB[displacement] ? color.new(color.green, 80) : color.new(color.red, 80)) : na
fill(sA, sB, color=cloudColor)
// --- Detect Crosses ---
crossUp = ta.crossover(tenkan, kijun)
crossDown = ta.crossunder(tenkan, kijun)
crossUpHTF = ta.crossover(tenkanHTFValue, kijunHTFValue)
crossDownHTF = ta.crossunder(tenkanHTFValue, kijunHTFValue)
candle2AboveCloud = close > math.max(senkouA[displacement], senkouB[displacement])
candle2BelowCloud = close < math.min(senkouA[displacement], senkouB[displacement])
// --- SuperTrend Lower TF ---
atrPeriodLTF = 12
multiplierLTF = 3.0
atrValueLTF = ta.atr(atrPeriodLTF)
upLTF = hl2 - multiplierLTF * atrValueLTF
dnLTF = hl2 + multiplierLTF * atrValueLTF
var int trendLTF = 1
trendLTF := trendLTF == -1 and close > dnLTF[1] ? 1 : trendLTF == 1 and close < upLTF[1] ? -1 : trendLTF
// --- SuperTrend Higher TF ---
useHTFST = input.bool(true, "Use HTF SuperTrend")
atrPeriodHTF = input.int(12, "HTF SuperTrend ATR")
multiplierHTF = input.float(3.0, "HTF SuperTrend Multiplier")
hl2HTF = request.security(syminfo.tickerid, higherTF, hl2)
atrHTF = request.security(syminfo.tickerid, higherTF, ta.atr(atrPeriodHTF))
upHTF = hl2HTF - multiplierHTF * atrHTF
dnHTF = hl2HTF + multiplierHTF * atrHTF
var int trendHTF = 1
trendHTF := trendHTF == -1 and close > dnHTF[1] ? 1 : trendHTF == 1 and close < upHTF[1] ? -1 : trendHTF
// --- Body Filter ---
useBodyFilter = input.bool(true, "Use Body Filter")
bodyMinPerc = input.float(20, "Min Body %")
bodyMaxPerc = input.float(100, "Max Body %")
bodyLen = math.abs(close - open)
candleLen = high - low
bodyPerc = (bodyLen / candleLen) * 100
bodyFilterPass = not useBodyFilter or (bodyPerc >= bodyMinPerc and bodyPerc <= bodyMaxPerc)
// --- Reward Filter ---
useReward = input.bool(true, "Use Reward 1:1 Filter")
stopLossPerc = input.float(1.5, "Stop Loss %")
reward1 = input.float(1.0, "Target 1 R/R")
reward2 = input.float(2.0, "Target 2 R/R")
reward3 = input.float(3.0, "Target 3 R/R")
rewardPass = not useReward or ((math.abs(close - tenkanHTFValue) * reward1) <= math.abs(kijunHTFValue - close))
// --- TSI Higher TF ---
tsiLong = input.int(25, "TSI Long")
tsiShort = input.int(13, "TSI Short")
tsiHTF = ta.tsi(request.security(syminfo.tickerid, higherTF, close), tsiLong, tsiShort)
// --- Lower TF Signals ---
buySignalLTF = (crossUp and candle2AboveCloud) and trendLTF == 1
sellSignalLTF = (crossDown and candle2BelowCloud) and trendLTF == -1
plotshape(crossUpHTF, title="HTF Buy Cross", location=location.belowbar, color=htfCrossColor, style=shape.triangleup, size=size.small)
plotshape(crossDownHTF, title="HTF Sell Cross", location=location.abovebar, color=htfCrossColor, style=shape.triangledown, size=size.small)
buyConfirmedRaw = (buySignalLTF and close > tenkanHTFValue and (not useHTFST or trendHTF==1)) and rewardPass and (tsiHTF > 0)
sellConfirmedRaw = (sellSignalLTF and close < tenkanHTFValue and (not useHTFST or trendHTF==-1)) and rewardPass and (tsiHTF < 0)
// --- Cooldown ---
var int barsSinceSignal = cooldownBars
barsSinceSignal += 1
buyConfirmed = buyConfirmedRaw and barsSinceSignal >= cooldownBars
sellConfirmed = sellConfirmedRaw and barsSinceSignal >= cooldownBars
if buyConfirmed or sellConfirmed
barsSinceSignal := 0
// --- Plot Final Signals ---
plotshape(buyConfirmed and bodyFilterPass, title="Buy Signal", location=location.belowbar, color=buyColor, style=shape.triangleup, size=size.small)
plotshape(sellConfirmed and bodyFilterPass, title="Sell Signal", location=location.abovebar, color=sellColor, style=shape.triangledown, size=size.small)
plotshape(buyConfirmed and not bodyFilterPass, title="Buy Signal (Filtered)", location=location.belowbar, color=bodyFilterColor, style=shape.triangleup, size=size.tiny)
plotshape(sellConfirmed and not bodyFilterPass, title="Sell Signal (Filtered)", location=location.abovebar, color=bodyFilterColor, style=shape.triangledown, size=size.tiny)
barcolor(crossUp or crossDown ? crossCandleColor : na)
barcolor(buyConfirmed and bodyFilterPass ? buyColor : sellConfirmed and bodyFilterPass ? sellColor : na)
// --- Stop & Targets ---
var float lastBuyPrice = na
var float lastSellPrice = na
var bool buyActive = false
var bool sellActive = false
f_drawLine(_price) =>
line.new(bar_index, _price, bar_index+3, _price, color=targetColor, width=2, style=line.style_dotted)
if buyConfirmed and not buyActive and not sellActive
buyActive := true
lastBuyPrice := close
line.new(bar_index, close*(1-stopLossPerc/100), bar_index+3, close*(1-stopLossPerc/100), color=stopColor, width=2, style=line.style_dotted)
f_drawLine(close*(1+reward1/100))
f_drawLine(close*(1+reward2/100))
f_drawLine(close*(1+reward3/100))
if buyActive
if low <= lastBuyPrice*(1-stopLossPerc/100) or high >= lastBuyPrice*(1+reward1/100)
buyActive := false
if sellConfirmed and not sellActive and not buyActive
sellActive := true
lastSellPrice := close
line.new(bar_index, close*(1+stopLossPerc/100), bar_index+3, close*(1+stopLossPerc/100), color=stopColor, width=2, style=line.style_dotted)
f_drawLine(close*(1-reward1/100))
f_drawLine(close*(1-reward2/100))
f_drawLine(close*(1-reward3/100))
if sellActive
if high >= lastSellPrice*(1+stopLossPerc/100) or low <= lastSellPrice*(1-reward1/100)
sellActive := false
// --- Oscillator Panel ---
showPanel = input.bool(true, "Show Oscillator Panel")
panelX = input.int(20, "Panel X Offset (Bars)")
panelY = input.int(50, "Panel Y Offset (Pixels)")
panelBgColor = input.color(color.new(color.black, 85), "Panel Background Color")
panelTextSize = input.string("normal", "Text Size", options=["tiny","small","normal","large","huge"])
// MACD
macdFast = input.int(12)
macdSlow = input.int(26)
macdSignal= input.int(9)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdBull = macdLine > signalLine
// RSI
rsiLen = input.int(14)
rsiVal = ta.rsi(close, rsiLen)
rsiBull = rsiVal > 50
// TSI
tsiVal = ta.tsi(close, 25, 13)
tsiBull = tsiVal > 0
// Divergence detection (RSI, MACD, TSI)
leftBars = input.int(2)
rightBars = input.int(2)
rsiLow = ta.pivotlow(rsiVal, leftBars, rightBars)
rsiHigh = ta.pivothigh(rsiVal, leftBars, rightBars)
bullDivRSI = not na(rsiLow) and low[rightBars] < low[rightBars+leftBars+1] and rsiVal[rightBars] > rsiVal[rightBars+leftBars+1]
bearDivRSI = not na(rsiHigh) and high[rightBars] > high[rightBars+leftBars+1] and rsiVal[rightBars] < rsiVal[rightBars+leftBars+1]
macdLow = ta.pivotlow(macdLine, leftBars, rightBars)
macdHigh = ta.pivothigh(macdLine, leftBars, rightBars)
bullDivMACD = not na(macdLow) and low[rightBars] < low[rightBars+leftBars+1] and macdLine[rightBars] > macdLine[rightBars+leftBars+1]
bearDivMACD = not na(macdHigh) and high[rightBars] > high[rightBars+leftBars+1] and macdLine[rightBars] < macdLine[rightBars+leftBars+1]
tsiLow = ta.pivotlow(tsiVal, leftBars, rightBars)
tsiHigh = ta.pivothigh(tsiVal, leftBars, rightBars)
bullDivTSI = not na(tsiLow) and low[rightBars] < low[rightBars+leftBars+1] and tsiVal[rightBars] > tsiVal[rightBars+leftBars+1]
bearDivTSI = not na(tsiHigh) and high[rightBars] > high[rightBars+leftBars+1] and tsiVal[rightBars] < tsiVal[rightBars+leftBars+1]
// Plot divergence on chart
plotshape(bullDivRSI, style=shape.labelup, text="R d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivRSI, style=shape.labeldown, text="R d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
plotshape(bullDivMACD, style=shape.labelup, text="M d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivMACD, style=shape.labeldown, text="M d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
plotshape(bullDivTSI, style=shape.labelup, text="T d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivTSI, style=shape.labeldown, text="T d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
// Panel
var label panelLabel = label.new(bar_index + panelX, close, "", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=panelBgColor, size=panelTextSize)
if showPanel
label.set_xy(panelLabel, bar_index + panelX, close + panelY * syminfo.mintick)
label.set_text(panelLabel, "MACD: " + (macdBull ? "↑" : "↓") + (bullDivMACD ? " d+" : bearDivMACD ? " d-" : "") + "\n" +
"RSI : " + (rsiBull ? "↑" : "↓") + (bullDivRSI ? " d+" : bearDivRSI ? " d-" : "") + "\n" +
"TSI : " + (tsiBull ? "↑" : "↓") + (bullDivTSI ? " d+" : bearDivTSI ? " d-" : "") + "\n" +
"ST : " + (trendLTF==1 ? "↑" : "↓"))
label.set_textcolor(panelLabel, color.white)
// ====================
// === CODE BLOCK 2: FluidTrades - SMC Lite (Light) ===
// ====================
// === SETTINGS ===
swing_length = input.int(10, "Swing High/Low Length", minval=1, maxval=50)
history_keep = input.int(20, "History To Keep", minval=5, maxval=50)
box_width = input.float(2.5, "Supply/Demand Box Width", minval=1, maxval=10, step=0.5)
show_labels = input.bool(false, "Show Price Action Labels")
supply_color = input.color(color.new(#EDEDED,70), "Supply Color")
supply_outline = input.color(color.new(color.white,75), "Supply Outline")
demand_color = input.color(color.new(#00FFFF,70), "Demand Color")
demand_outline = input.color(color.new(color.white,75), "Demand Outline")
bos_color = input.color(color.white, "BOS Label Color")
poi_color = input.color(color.white, "POI Label Color")
label_color = input.color(color.black, "Swing Label Color")
// === FUNCTIONS ===
f_add_pop(arr, val) =>
array.unshift(arr, val)
array.pop(arr)
f_draw_swing_label(values, swing_type) =>
var string txt = na
if swing_type == 1
txt := array.get(values,0) >= array.get(values,1) ? "HH" : "LH"
label.new(bar_index - swing_length, array.get(values,0), txt, style=label.style_label_down, textcolor=label_color, color=color.new(label_color,100), size=size.tiny)
else
txt := array.get(values,0) >= array.get(values,1) ? "HL" : "LL"
label.new(bar_index - swing_length, array.get(values,0), txt, style=label.style_label_up, textcolor=label_color, color=color.new(label_color,100), size=size.tiny)
f_check_overlap(new_poi, box_arr, atr) =>
ok = true
for i=0 to array.size(box_arr)-1
b = array.get(box_arr,i)
top = box.get_top(b)
bot = box.get_bottom(b)
mid = (top+bot)/2
threshold = atr*2
if new_poi >= mid - threshold and new_poi <= mid + threshold
ok := false
break
ok
f_create_box(vals, bn_arr, box_arr, label_arr, type_box, atr) =>
atr_buf = atr*(box_width/10)
left = array.get(bn_arr,0)
right = bar_index
var float top=0.0
var float bottom=0.0
var float poi=0.0
if type_box==1
top := array.get(vals,0)
bottom := top - atr_buf
else
bottom := array.get(vals,0)
top := bottom + atr_buf
poi := (top+bottom)/2
if f_check_overlap(poi, box_arr, atr)
box.delete(array.get(box_arr,array.size(box_arr)-1))
f_add_pop(box_arr, box.new(left, top, right, bottom, border_color=type_box==1?supply_outline:demand_outline,
bgcolor=type_box==1?supply_color:demand_color, extend=extend.right, text=type_box==1?"SUPPLY":"DEMAND",
text_halign=text.align_center, text_valign=text.align_center, text_color=poi_color, text_size=size.small, xloc=xloc.bar_index))
box.delete(array.get(label_arr,array.size(label_arr)-1))
f_add_pop(label_arr, box.new(left, poi, right, poi, border_color=color.new(poi_color,90),
bgcolor=color.new(poi_color,90), extend=extend.right, text="POI", text_halign=text.align_left, text_valign=text.align_center, text_color=poi_color, text_size=size.small, xloc=xloc.bar_index))
f_to_bos(box_arr, bos_arr, label_arr, type_box) =>
for i=0 to array.size(box_arr)-1
b = array.get(box_arr,i)
lvl = type_box==1? box.get_top(b) : box.get_bottom(b)
cond = type_box==1? close>=lvl : close<=lvl
if cond
cbox = box.copy(b)
f_add_pop(bos_arr, cbox)
mid = (box.get_top(b)+box.get_bottom(b))/2
box.set_top(cbox, mid)
box.set_bottom(cbox, mid)
box.set_extend(cbox, extend.none)
box.set_right(cbox, bar_index)
box.set_text(cbox, "BOS")
box.set_text_color(cbox, bos_color)
box.set_text_size(cbox, size.small)
box.set_text_halign(cbox, text.align_center)
box.set_text_valign(cbox, text.align_center)
box.delete(b)
box.delete(array.get(label_arr,i))
f_extend(box_arr) =>
for i=0 to array.size(box_arr)-1
box.set_right(array.get(box_arr,i), bar_index+100)
// === CALCULATIONS ===
atr = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
var swing_high_vals = array.new_float(5,0.0)
var swing_low_vals = array.new_float(5,0.0)
var swing_high_bn = array.new_int(5,0)
var swing_low_bn = array.new_int(5,0)
var supply_boxes = array.new_box(history_keep, na)
var demand_boxes = array.new_box(history_keep, na)
var supply_poi = array.new_box(history_keep, na)
var demand_poi = array.new_box(history_keep, na)
var bos_supply = array.new_box(5, na)
var bos_demand = array.new_box(5, na)
// NEW SWING HIGH
if not na(swing_high)
f_add_pop(swing_high_vals, swing_high)
f_add_pop(swing_high_bn, bar_index[swing_length])
if show_labels
f_draw_swing_label(swing_high_vals,1)
f_create_box(swing_high_vals, swing_high_bn, supply_boxes, supply_poi, 1, atr)
// NEW SWING LOW
if not na(swing_low)
f_add_pop(swing_low_vals, swing_low)
f_add_pop(swing_low_bn, bar_index[swing_length])
if show_labels
f_draw_swing_label(swing_low_vals,-1)
f_create_box(swing_low_vals, swing_low_bn, demand_boxes, demand_poi, -1, atr)
f_to_bos(supply_boxes, bos_supply, supply_poi, 1)
f_to_bos(demand_boxes, bos_demand, demand_poi, -1)
f_extend(supply_boxes)
f_extend(demand_boxes)
//version=6
length = input.int(9, minval=1)
src = input(close, title="Source")
e1 = ta.ema(src, length)
e2 = ta.ema(e1, length)
dema = 2 * e1 - e2
plot(dema, "DEMA", color=#43A047)
indicator("Ichimoku + SuperTrend + Oscillator + Divergence + SMC Lite", overlay=true, max_labels_count=500, max_lines_count=500, max_boxes_count=500, max_bars_back=1000)
// ====================
// === CODE BLOCK 1: Ichimoku + SuperTrend + Oscillator Monitor + Divergence ===
// ====================
// --- User Inputs ---
lowerTF = input.timeframe("5", "Lower Timeframe (Ichimoku + SuperTrend)")
higherTF = input.timeframe("60", "Higher Timeframe (Tenkan/Kijun check)")
tenkanLength = input.int(9, "Tenkan-sen Length (Lower TF)")
kijunLength = input.int(26, "Kijun-sen Length (Lower TF)")
senkouSpanBLength = input.int(52, "Senkou Span B Length (Lower TF)")
displacement = input.int(26, "Displacement (Lower TF)")
showCloud = input.bool(true, "Show Kumo Cloud (Lower TF)")
buyColor = input.color(color.new(color.green, 0), "Buy Candle Color")
sellColor = input.color(color.new(color.red, 0), "Sell Candle Color")
crossCandleColor = input.color(color.new(color.yellow, 0), "Cross Candle Color")
bodyFilterColor = input.color(color.new(color.lime,0), "Body Filter Active Color")
htfCrossColor = input.color(color.new(color.orange,0), "HTF Cross Signal Color")
stopColor = input.color(color.new(color.red,0), "Stop Line Color")
targetColor = input.color(color.new(color.blue,0), "Target Line Color")
cooldownBars = input.int(5, "Cooldown Bars After Signal")
// --- Higher TF Ichimoku ---
tenkanLengthHTF = input.int(36, "Tenkan Length (Higher TF)")
kijunLengthHTF = input.int(103, "Kijun Length (Higher TF)")
showTenkanHTF = input.bool(true, "Show Tenkan (HTF)")
showKijunHTF = input.bool(true, "Show Kijun (HTF)")
tenkanHTFValue = request.security(syminfo.tickerid, higherTF, (ta.highest(high, tenkanLengthHTF)+ta.lowest(low, tenkanLengthHTF))/2)
kijunHTFValue = request.security(syminfo.tickerid, higherTF, (ta.highest(high, kijunLengthHTF)+ta.lowest(low, kijunLengthHTF))/2)
plot(showTenkanHTF ? tenkanHTFValue : na, color=color.blue, linewidth=2, title="Tenkan HTF")
plot(showKijunHTF ? kijunHTFValue : na, color=color.red, linewidth=2, title="Kijun HTF")
// --- Lower TF Ichimoku ---
tenkan = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, tenkanLength) + ta.lowest(low, tenkanLength)) / 2)
kijun = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, kijunLength) + ta.lowest(low, kijunLength)) / 2)
senkouA = request.security(syminfo.tickerid, lowerTF, (tenkan + kijun) / 2)
senkouB = request.security(syminfo.tickerid, lowerTF, (ta.highest(high, senkouSpanBLength) + ta.lowest(low, senkouSpanBLength)) / 2)
plot(tenkan, color=color.blue, title="Tenkan-sen (LTF)", linewidth=2)
plot(kijun, color=color.red, title="Kijun-sen (LTF)", linewidth=2)
sA = plot(senkouA[displacement], display=display.none)
sB = plot(senkouB[displacement], display=display.none)
cloudColor = showCloud ? (senkouA[displacement] > senkouB[displacement] ? color.new(color.green, 80) : color.new(color.red, 80)) : na
fill(sA, sB, color=cloudColor)
// --- Detect Crosses ---
crossUp = ta.crossover(tenkan, kijun)
crossDown = ta.crossunder(tenkan, kijun)
crossUpHTF = ta.crossover(tenkanHTFValue, kijunHTFValue)
crossDownHTF = ta.crossunder(tenkanHTFValue, kijunHTFValue)
candle2AboveCloud = close > math.max(senkouA[displacement], senkouB[displacement])
candle2BelowCloud = close < math.min(senkouA[displacement], senkouB[displacement])
// --- SuperTrend Lower TF ---
atrPeriodLTF = 12
multiplierLTF = 3.0
atrValueLTF = ta.atr(atrPeriodLTF)
upLTF = hl2 - multiplierLTF * atrValueLTF
dnLTF = hl2 + multiplierLTF * atrValueLTF
var int trendLTF = 1
trendLTF := trendLTF == -1 and close > dnLTF[1] ? 1 : trendLTF == 1 and close < upLTF[1] ? -1 : trendLTF
// --- SuperTrend Higher TF ---
useHTFST = input.bool(true, "Use HTF SuperTrend")
atrPeriodHTF = input.int(12, "HTF SuperTrend ATR")
multiplierHTF = input.float(3.0, "HTF SuperTrend Multiplier")
hl2HTF = request.security(syminfo.tickerid, higherTF, hl2)
atrHTF = request.security(syminfo.tickerid, higherTF, ta.atr(atrPeriodHTF))
upHTF = hl2HTF - multiplierHTF * atrHTF
dnHTF = hl2HTF + multiplierHTF * atrHTF
var int trendHTF = 1
trendHTF := trendHTF == -1 and close > dnHTF[1] ? 1 : trendHTF == 1 and close < upHTF[1] ? -1 : trendHTF
// --- Body Filter ---
useBodyFilter = input.bool(true, "Use Body Filter")
bodyMinPerc = input.float(20, "Min Body %")
bodyMaxPerc = input.float(100, "Max Body %")
bodyLen = math.abs(close - open)
candleLen = high - low
bodyPerc = (bodyLen / candleLen) * 100
bodyFilterPass = not useBodyFilter or (bodyPerc >= bodyMinPerc and bodyPerc <= bodyMaxPerc)
// --- Reward Filter ---
useReward = input.bool(true, "Use Reward 1:1 Filter")
stopLossPerc = input.float(1.5, "Stop Loss %")
reward1 = input.float(1.0, "Target 1 R/R")
reward2 = input.float(2.0, "Target 2 R/R")
reward3 = input.float(3.0, "Target 3 R/R")
rewardPass = not useReward or ((math.abs(close - tenkanHTFValue) * reward1) <= math.abs(kijunHTFValue - close))
// --- TSI Higher TF ---
tsiLong = input.int(25, "TSI Long")
tsiShort = input.int(13, "TSI Short")
tsiHTF = ta.tsi(request.security(syminfo.tickerid, higherTF, close), tsiLong, tsiShort)
// --- Lower TF Signals ---
buySignalLTF = (crossUp and candle2AboveCloud) and trendLTF == 1
sellSignalLTF = (crossDown and candle2BelowCloud) and trendLTF == -1
plotshape(crossUpHTF, title="HTF Buy Cross", location=location.belowbar, color=htfCrossColor, style=shape.triangleup, size=size.small)
plotshape(crossDownHTF, title="HTF Sell Cross", location=location.abovebar, color=htfCrossColor, style=shape.triangledown, size=size.small)
buyConfirmedRaw = (buySignalLTF and close > tenkanHTFValue and (not useHTFST or trendHTF==1)) and rewardPass and (tsiHTF > 0)
sellConfirmedRaw = (sellSignalLTF and close < tenkanHTFValue and (not useHTFST or trendHTF==-1)) and rewardPass and (tsiHTF < 0)
// --- Cooldown ---
var int barsSinceSignal = cooldownBars
barsSinceSignal += 1
buyConfirmed = buyConfirmedRaw and barsSinceSignal >= cooldownBars
sellConfirmed = sellConfirmedRaw and barsSinceSignal >= cooldownBars
if buyConfirmed or sellConfirmed
barsSinceSignal := 0
// --- Plot Final Signals ---
plotshape(buyConfirmed and bodyFilterPass, title="Buy Signal", location=location.belowbar, color=buyColor, style=shape.triangleup, size=size.small)
plotshape(sellConfirmed and bodyFilterPass, title="Sell Signal", location=location.abovebar, color=sellColor, style=shape.triangledown, size=size.small)
plotshape(buyConfirmed and not bodyFilterPass, title="Buy Signal (Filtered)", location=location.belowbar, color=bodyFilterColor, style=shape.triangleup, size=size.tiny)
plotshape(sellConfirmed and not bodyFilterPass, title="Sell Signal (Filtered)", location=location.abovebar, color=bodyFilterColor, style=shape.triangledown, size=size.tiny)
barcolor(crossUp or crossDown ? crossCandleColor : na)
barcolor(buyConfirmed and bodyFilterPass ? buyColor : sellConfirmed and bodyFilterPass ? sellColor : na)
// --- Stop & Targets ---
var float lastBuyPrice = na
var float lastSellPrice = na
var bool buyActive = false
var bool sellActive = false
f_drawLine(_price) =>
line.new(bar_index, _price, bar_index+3, _price, color=targetColor, width=2, style=line.style_dotted)
if buyConfirmed and not buyActive and not sellActive
buyActive := true
lastBuyPrice := close
line.new(bar_index, close*(1-stopLossPerc/100), bar_index+3, close*(1-stopLossPerc/100), color=stopColor, width=2, style=line.style_dotted)
f_drawLine(close*(1+reward1/100))
f_drawLine(close*(1+reward2/100))
f_drawLine(close*(1+reward3/100))
if buyActive
if low <= lastBuyPrice*(1-stopLossPerc/100) or high >= lastBuyPrice*(1+reward1/100)
buyActive := false
if sellConfirmed and not sellActive and not buyActive
sellActive := true
lastSellPrice := close
line.new(bar_index, close*(1+stopLossPerc/100), bar_index+3, close*(1+stopLossPerc/100), color=stopColor, width=2, style=line.style_dotted)
f_drawLine(close*(1-reward1/100))
f_drawLine(close*(1-reward2/100))
f_drawLine(close*(1-reward3/100))
if sellActive
if high >= lastSellPrice*(1+stopLossPerc/100) or low <= lastSellPrice*(1-reward1/100)
sellActive := false
// --- Oscillator Panel ---
showPanel = input.bool(true, "Show Oscillator Panel")
panelX = input.int(20, "Panel X Offset (Bars)")
panelY = input.int(50, "Panel Y Offset (Pixels)")
panelBgColor = input.color(color.new(color.black, 85), "Panel Background Color")
panelTextSize = input.string("normal", "Text Size", options=["tiny","small","normal","large","huge"])
// MACD
macdFast = input.int(12)
macdSlow = input.int(26)
macdSignal= input.int(9)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdBull = macdLine > signalLine
// RSI
rsiLen = input.int(14)
rsiVal = ta.rsi(close, rsiLen)
rsiBull = rsiVal > 50
// TSI
tsiVal = ta.tsi(close, 25, 13)
tsiBull = tsiVal > 0
// Divergence detection (RSI, MACD, TSI)
leftBars = input.int(2)
rightBars = input.int(2)
rsiLow = ta.pivotlow(rsiVal, leftBars, rightBars)
rsiHigh = ta.pivothigh(rsiVal, leftBars, rightBars)
bullDivRSI = not na(rsiLow) and low[rightBars] < low[rightBars+leftBars+1] and rsiVal[rightBars] > rsiVal[rightBars+leftBars+1]
bearDivRSI = not na(rsiHigh) and high[rightBars] > high[rightBars+leftBars+1] and rsiVal[rightBars] < rsiVal[rightBars+leftBars+1]
macdLow = ta.pivotlow(macdLine, leftBars, rightBars)
macdHigh = ta.pivothigh(macdLine, leftBars, rightBars)
bullDivMACD = not na(macdLow) and low[rightBars] < low[rightBars+leftBars+1] and macdLine[rightBars] > macdLine[rightBars+leftBars+1]
bearDivMACD = not na(macdHigh) and high[rightBars] > high[rightBars+leftBars+1] and macdLine[rightBars] < macdLine[rightBars+leftBars+1]
tsiLow = ta.pivotlow(tsiVal, leftBars, rightBars)
tsiHigh = ta.pivothigh(tsiVal, leftBars, rightBars)
bullDivTSI = not na(tsiLow) and low[rightBars] < low[rightBars+leftBars+1] and tsiVal[rightBars] > tsiVal[rightBars+leftBars+1]
bearDivTSI = not na(tsiHigh) and high[rightBars] > high[rightBars+leftBars+1] and tsiVal[rightBars] < tsiVal[rightBars+leftBars+1]
// Plot divergence on chart
plotshape(bullDivRSI, style=shape.labelup, text="R d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivRSI, style=shape.labeldown, text="R d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
plotshape(bullDivMACD, style=shape.labelup, text="M d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivMACD, style=shape.labeldown, text="M d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
plotshape(bullDivTSI, style=shape.labelup, text="T d+", color=color.lime, textcolor=color.white, location=location.belowbar, size=size.tiny)
plotshape(bearDivTSI, style=shape.labeldown, text="T d-", color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)
// Panel
var label panelLabel = label.new(bar_index + panelX, close, "", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=panelBgColor, size=panelTextSize)
if showPanel
label.set_xy(panelLabel, bar_index + panelX, close + panelY * syminfo.mintick)
label.set_text(panelLabel, "MACD: " + (macdBull ? "↑" : "↓") + (bullDivMACD ? " d+" : bearDivMACD ? " d-" : "") + "\n" +
"RSI : " + (rsiBull ? "↑" : "↓") + (bullDivRSI ? " d+" : bearDivRSI ? " d-" : "") + "\n" +
"TSI : " + (tsiBull ? "↑" : "↓") + (bullDivTSI ? " d+" : bearDivTSI ? " d-" : "") + "\n" +
"ST : " + (trendLTF==1 ? "↑" : "↓"))
label.set_textcolor(panelLabel, color.white)
// ====================
// === CODE BLOCK 2: FluidTrades - SMC Lite (Light) ===
// ====================
// === SETTINGS ===
swing_length = input.int(10, "Swing High/Low Length", minval=1, maxval=50)
history_keep = input.int(20, "History To Keep", minval=5, maxval=50)
box_width = input.float(2.5, "Supply/Demand Box Width", minval=1, maxval=10, step=0.5)
show_labels = input.bool(false, "Show Price Action Labels")
supply_color = input.color(color.new(#EDEDED,70), "Supply Color")
supply_outline = input.color(color.new(color.white,75), "Supply Outline")
demand_color = input.color(color.new(#00FFFF,70), "Demand Color")
demand_outline = input.color(color.new(color.white,75), "Demand Outline")
bos_color = input.color(color.white, "BOS Label Color")
poi_color = input.color(color.white, "POI Label Color")
label_color = input.color(color.black, "Swing Label Color")
// === FUNCTIONS ===
f_add_pop(arr, val) =>
array.unshift(arr, val)
array.pop(arr)
f_draw_swing_label(values, swing_type) =>
var string txt = na
if swing_type == 1
txt := array.get(values,0) >= array.get(values,1) ? "HH" : "LH"
label.new(bar_index - swing_length, array.get(values,0), txt, style=label.style_label_down, textcolor=label_color, color=color.new(label_color,100), size=size.tiny)
else
txt := array.get(values,0) >= array.get(values,1) ? "HL" : "LL"
label.new(bar_index - swing_length, array.get(values,0), txt, style=label.style_label_up, textcolor=label_color, color=color.new(label_color,100), size=size.tiny)
f_check_overlap(new_poi, box_arr, atr) =>
ok = true
for i=0 to array.size(box_arr)-1
b = array.get(box_arr,i)
top = box.get_top(b)
bot = box.get_bottom(b)
mid = (top+bot)/2
threshold = atr*2
if new_poi >= mid - threshold and new_poi <= mid + threshold
ok := false
break
ok
f_create_box(vals, bn_arr, box_arr, label_arr, type_box, atr) =>
atr_buf = atr*(box_width/10)
left = array.get(bn_arr,0)
right = bar_index
var float top=0.0
var float bottom=0.0
var float poi=0.0
if type_box==1
top := array.get(vals,0)
bottom := top - atr_buf
else
bottom := array.get(vals,0)
top := bottom + atr_buf
poi := (top+bottom)/2
if f_check_overlap(poi, box_arr, atr)
box.delete(array.get(box_arr,array.size(box_arr)-1))
f_add_pop(box_arr, box.new(left, top, right, bottom, border_color=type_box==1?supply_outline:demand_outline,
bgcolor=type_box==1?supply_color:demand_color, extend=extend.right, text=type_box==1?"SUPPLY":"DEMAND",
text_halign=text.align_center, text_valign=text.align_center, text_color=poi_color, text_size=size.small, xloc=xloc.bar_index))
box.delete(array.get(label_arr,array.size(label_arr)-1))
f_add_pop(label_arr, box.new(left, poi, right, poi, border_color=color.new(poi_color,90),
bgcolor=color.new(poi_color,90), extend=extend.right, text="POI", text_halign=text.align_left, text_valign=text.align_center, text_color=poi_color, text_size=size.small, xloc=xloc.bar_index))
f_to_bos(box_arr, bos_arr, label_arr, type_box) =>
for i=0 to array.size(box_arr)-1
b = array.get(box_arr,i)
lvl = type_box==1? box.get_top(b) : box.get_bottom(b)
cond = type_box==1? close>=lvl : close<=lvl
if cond
cbox = box.copy(b)
f_add_pop(bos_arr, cbox)
mid = (box.get_top(b)+box.get_bottom(b))/2
box.set_top(cbox, mid)
box.set_bottom(cbox, mid)
box.set_extend(cbox, extend.none)
box.set_right(cbox, bar_index)
box.set_text(cbox, "BOS")
box.set_text_color(cbox, bos_color)
box.set_text_size(cbox, size.small)
box.set_text_halign(cbox, text.align_center)
box.set_text_valign(cbox, text.align_center)
box.delete(b)
box.delete(array.get(label_arr,i))
f_extend(box_arr) =>
for i=0 to array.size(box_arr)-1
box.set_right(array.get(box_arr,i), bar_index+100)
// === CALCULATIONS ===
atr = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
var swing_high_vals = array.new_float(5,0.0)
var swing_low_vals = array.new_float(5,0.0)
var swing_high_bn = array.new_int(5,0)
var swing_low_bn = array.new_int(5,0)
var supply_boxes = array.new_box(history_keep, na)
var demand_boxes = array.new_box(history_keep, na)
var supply_poi = array.new_box(history_keep, na)
var demand_poi = array.new_box(history_keep, na)
var bos_supply = array.new_box(5, na)
var bos_demand = array.new_box(5, na)
// NEW SWING HIGH
if not na(swing_high)
f_add_pop(swing_high_vals, swing_high)
f_add_pop(swing_high_bn, bar_index[swing_length])
if show_labels
f_draw_swing_label(swing_high_vals,1)
f_create_box(swing_high_vals, swing_high_bn, supply_boxes, supply_poi, 1, atr)
// NEW SWING LOW
if not na(swing_low)
f_add_pop(swing_low_vals, swing_low)
f_add_pop(swing_low_bn, bar_index[swing_length])
if show_labels
f_draw_swing_label(swing_low_vals,-1)
f_create_box(swing_low_vals, swing_low_bn, demand_boxes, demand_poi, -1, atr)
f_to_bos(supply_boxes, bos_supply, supply_poi, 1)
f_to_bos(demand_boxes, bos_demand, demand_poi, -1)
f_extend(supply_boxes)
f_extend(demand_boxes)
//version=6
length = input.int(9, minval=1)
src = input(close, title="Source")
e1 = ta.ema(src, length)
e2 = ta.ema(e1, length)
dema = 2 * e1 - e2
plot(dema, "DEMA", color=#43A047)
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.