//@version=6
indicator("Pro V3 [SMRT Algo]", overlay = true)
// ==========================[INPUTS]========================= //
// Signal Inputs
signalMode = [Link]("All", "Signal Mode", options=["All", "Normal",
"Strong"], group="BUY/SELL", inline='1')
sigsensitiviti = [Link](5, "Signal Sensitivity (1-15)", minval=1, maxval=15,
tooltip="Changes the signal display frequency", group="BUY/SELL", inline='j')
showCandleColors = [Link](true, "Show Bar Colors", group="BUY/SELL",
inline='ee')
bullishColor = [Link](#01d7ee, '', group="BUY/SELL", inline='ee')
bearishColor = [Link](#cd0542, '', group="BUY/SELL", inline='ee')
maFilter = [Link](false, "MA Filter", group="BUY/SELL", inline='rr')
maType = [Link]("SMA", "", options=["SMA", "EMA", "WMA", "VWMA", "HMA"],
group="BUY/SELL", inline='rr')
malength = [Link](200, "", minval=1, group="BUY/SELL", inline='rr')
// ================= IMAGE 2 =================
tp2Color = [Link](#16A000, "TP-2 Color", group="TP/SL")
tp3Color = [Link](#16A000, "TP-3 Color", group="TP/SL")
longtp = [Link](#16A000, "TP-3 Color", group="TP/SL")
shorttp = [Link](#16A000, "TP-3 Color", group="TP/SL")
// Note: 'tpstrength' must be defined before use. Assuming a placeholder or that it
appears in your later pages.
tpstrength = 1.0
useTP1 = true
multTP1 = tpstrength
useTP2 = true
multTP2 = tpstrength * 2
useTP3 = true
multTP3 = tpstrength * 3
supertrend_func(_src, factor, atrLen) =>
atr = [Link](atrLen)
upperBand = _src + factor * atr
lowerBand = _src - factor * atr
[upperBand, lowerBand] // Placeholder return for incomplete function
// ================= IMAGE 3 =================
// Note: 'val' and '_slp' would need prior definition in actual script
var float val = 0.0
_slp = 0.0
val += _slp
barsL = 10
barsR = 10
// 'fixnan' is deprecated in v6. Use 'ta.na_nan' or logic below:
pivotHigh = [Link](not na([Link](barsL, barsR)[1]), [Link](barsL,
barsR)[1], 0)
pivotLow = [Link](not na([Link](barsL, barsR)[1]), [Link](barsL,
barsR)[1], 0)
source = close
period = 150
// Note: lr_slope and lr_dev are custom functions that need to be defined in your
script
// [s1, a1, i1] = lr_slope(source, period)
// [upDev, dnDev] = lr_dev(source, period, s1, a1, i1)
// ================= IMAGE 4 =================
// Removed '$' from variable name as it is illegal in Pine Script syntax
bear_signal = [Link](close, 1.0) and close <= 1.0 and not (close[1] > 1.0
and close > 1.0) and (not maFilter or close < 1.0)
showNormalBuy = signalMode == "All" or signalMode == "Normal"
showStrongBuy = signalMode == "All" or signalMode == "Strong"
showNormalSell = signalMode == "All" or signalMode == "Normal"
showStrongSell = signalMode == "All" or signalMode == "Strong"
// ================= IMAGE 5 =================
// Variables valid_bull and valid_bear must be defined for these to work
valid_bull = true
valid_bear = true
signals_show = true
plotshape(signals_show and valid_bull, title="buy", text='buy',
style=[Link], location=[Link], color=#01d7ee,
textcolor=[Link], size=[Link])plotshape(signals_show and valid_bear ? true
: na, title="sell", text='sell', style=[Link], location=[Link],
color=#cd0542, textcolor=[Link], size=[Link])
// ================= IMAGE 6 =================
// Fixed ternary logic for price calculations
tp2_y = direction1 == 1 ? entry_y + (multTP2 * [Link](14)) : direction1 == -1 ?
entry_y - (multTP2 * [Link](14)) : entry_y
tp3_y = direction1 == 1 ? entry_y + (multTP3 * [Link](14)) : direction1 == -1 ?
entry_y - (multTP3 * [Link](14)) : entry_y
longTp1Breakout = [Link](high, tp1_y) and longPositionActive and not
longTp1Broken
longTp2Breakout = [Link](high, tp2_y) and longPositionActive and not
longTp2Broken
longTp3Breakout = [Link](high, tp3_y) and longPositionActive and not
longTp3Broken
shortTp1Breakout = [Link](low, tp1_y) and shortPositionActive and not
shortTp1Broken
shortTp2Breakout = [Link](low, tp2_y) and shortPositionActive and not
shortTp2Broken
shortTp3Breakout = [Link](low, tp3_y) and shortPositionActive and not
shortTp3Broken
// ================= IMAGE 7 =================
// Logic for labels inside IF blocks (assuming parameters like 'longtp' exist from
Page 1)
if longTp1Breakout
[Link](bar_index, high, "TP 1", color=longtp, style=label.style_label_down)
if longTp2Breakout
[Link](bar_index, high, "TP 2", color=longtp, style=label.style_label_down)
if longTp3Breakout
[Link](bar_index, high, "TP 3", color=longtp, style=label.style_label_down)
// Function to handle TP/SL Labels - Fixed variable persistence
labelTpSl(cond, y, txt, bgColor, txtColor) =>
var label lbl = na
if riskmanage_bool and cond
lbl := [Link](bar_index + 1, y, txt, xloc=xloc.bar_index,
yloc=[Link], color=bgColor, style=label.style_label_left, textcolor=txtColor,
size=[Link])
[Link](lbl[1])
// ================= IMAGE 8 =================
// Function to handle TP/SL Lines - Fixed the 'count' logic and line deletion
lineTpSl(cond, y, lineColor, lineStyle) =>
count = signal_type == 1 ? [Link](valid_bull) : signal_type == 2 ?
[Link](valid_Sbull) : signal_type == 3 ? [Link](valid_bear) :
signal_type == 4 ? [Link](valid_Sbear) : 0
var line ln = na
if riskmanage_bool and cond
ln := [Link](bar_index - count, y, bar_index + 1, y, xloc=xloc.bar_index,
extend=[Link], color=lineColor, style=lineStyle)
[Link](ln[1])
is_signal = signal_type != 0
linecolor = [Link]
labelTpSl(is_signal, entry_y, "Entry : (" +
[Link](math.round_to_mintick(entry_y)) + ")", entryColor, linecolor)
labelTpSl(is_signal, stop_y, "SL : (" + [Link](math.round_to_mintick(stop_y))
+ ")", slColor, linecolor)
// ================= IMAGE 9 =================
ema3 = [Link](close, 200)
emaBull = close > ema3
// Fixed Security function logic for v6
securityNoRep(sym, res, src) =>
[Link](sym, res, src[1], barmerge.gaps_off, barmerge.lookahead_on)
// ================= IMAGE 10 =================
// Inputs for Reversal Bands
length1 = [Link](80, minval=1, title="Length 1", group = 'reversal Bands')
length2 = [Link](80, minval=1, title="Length 2", group = 'reversal Bands')
length3 = [Link](80, minval=1, title="Length 3", group = 'reversal Bands')
mult1 = [Link](5, title="Multiplier 1", group = 'reversal Bands')
mult2 = [Link](7, title="Multiplier 2", group = 'reversal Bands')
mult3 = [Link](9, title="Multiplier 3", group = 'reversal Bands')
src1 = input(close, title="Source", group = 'reversal Bands')
exp = [Link](false, title="Use Exponential MA", group = 'reversal Bands')
BandsStyle = [Link]("Range", options=["Average True Range", "True Range",
"Range"], title="Bands Style", group = 'reversal Bands')
atrlength1 = [Link](2000, title="ATR Length 1", group = 'reversal Bands')
// MA Calculation Function
esma(source_val, len)=>
exp ? [Link](source_val, len) : [Link](source_val, len)
ma1 = esma(src1, length1)
rangema1 = BandsStyle == "True Range" ? [Link](true) : BandsStyle == "Average True
Range" ? [Link](atrlength1) : [Link](high - low, length1)
upper1 = ma1 + rangema1 * mult1
lower1 = ma1 - rangema1 * mult1
// ================= IMAGE 11 =================
// Note: If length1/length2 were already defined in Page 2, these are re-
definitions.
// I have kept them as provided but ensured syntax is valid.
length1_v2 = [Link](80, minval=1, title="Length 1", group = 'reversal Bands')
length2_v2 = [Link](80, minval=1, title="Length 2", group = 'reversal Bands')
length3_v2 = [Link](80, minval=1, title="Length 3", group = 'reversal Bands')
mult1_v2 = [Link](5, title="Multiplier 1", group = 'reversal Bands')
mult2_v2 = [Link](7, title="Multiplier 2", group = 'reversal Bands')
mult3_v2 = [Link](9, title="Multiplier 3", group = 'reversal Bands')
src1_v2 = input(close, title="Source", group = 'reversal Bands')
exp_v2 = [Link](false, title="Use Exponential MA", group = 'reversal Bands')
BandsStyle_v2 = [Link]("Range", options=["Average True Range", "True Range",
"Range"], title="Bands Style", group = 'reversal Bands')
atrlength1_v2 = [Link](2000, title="ATR Length 1", group = 'reversal Bands')
atrlength2_v2 = [Link](2000, title="ATR Length 2", group = 'reversal Bands')
atrlength3_v2 = [Link](2000, title="ATR Length 3", group = 'reversal Bands')
esma_func(source, length, is_exp)=>
is_exp ? [Link](source, length) : [Link](source, length)
ma1_v2 = esma_func(src1_v2, length1_v2, exp_v2)
rangema1_v2 = BandsStyle_v2 == "True Range" ? [Link](true) : BandsStyle_v2 ==
"Average True Range" ? [Link](atrlength1_v2) : [Link](high - low, length1_v2)
upper1_v2 = ma1_v2 + rangema1_v2 * mult1_v2
lower1_v2 = ma1_v2 - rangema1_v2 * mult1_v2
// ================= IMAGE 12 =================
// Fixed 'transp' to [Link]() as transp is deprecated in v6
plotKeltnterChannels = true // Placeholder for reversalBandsEnabled
u1 = plot(plotKeltnterChannels ? upper1_v2 : na, color=[Link](#787b86, 70),
title="Upper Band 1")
l1 = plot(plotKeltnterChannels ? lower1_v2 : na, color=[Link](#787b86, 70),
title="Lower Band 1")
u2 = plot(plotKeltnterChannels ? upper1_v2 : na, color=[Link](#787b86, 70),
title="Upper Band 2")
l2 = plot(plotKeltnterChannels ? lower1_v2 : na, color=[Link](#787b86, 70),
title="Lower Band 2")
u3 = plot(plotKeltnterChannels ? upper1_v2 : na, color=[Link](#787b86, 70),
title="Upper Band 3")
l3 = plot(plotKeltnterChannels ? lower1_v2 : na, color=[Link](#787b86, 70),
title="Lower Band 3")
fill(u1, l1, color=[Link](#787b86, 90), title="Fill 1")
fill(u2, l2, color=[Link](#787b86, 90), title="Fill 2")
fill(u3, l3, color=[Link](#787b86, 90), title="Fill 3")
strengthSR = [Link](2, "S&R Strength", 1, group="S/R")
useZones = input(true, "SR Zones", group="S/R")
// ================= IMAGE 13 =================
prd = 284
rb = 10 // Placeholder for rb value
ph = [Link](high, rb, rb)
pl = [Link](low, rb, rb)
sr_levels = array.new_float(21, na)
aas = array.new_bool(41, true)
// Fixed variable assignment syntax
var float u11 = 0.0
u11 := nz(u11[1])
var float d1_val = 0.0
d1_val := nz(d1_val[1])
// ================= IMAGE 14 =================
// Logic for for-loops and array sets
var int tpoint = 0
var bool chg = false
// Placeholder variables for missing context in the snippet
x = 0, xx = 0, upl = 0.0, dnl = 0.0, cnt = 0, countpp = 0
tmp = array.new_bool(41, true)
if not na(pl)
if low[xx + rb] <= upl and low[xx + rb] >= dnl
tpoint := tpoint + 1
chg := true
if chg and cnt < 41
[Link](tmp, cnt, false)
if tpoint >= strengthSR
for g = 0 to 40 by 1
if not [Link](tmp, g)
[Link](aas, g, false)
if not na(ph) and countpp < 21
[Link](sr_levels, countpp, high[rb])
// ================= IMAGE 15 =================
// Line and Linefill logic fixed for v6
var sr_linesL = array.new_line(21, na)
var sr_linesF = array.new_linefill(21, na)
var sr_linesH = array.new_line(21, na)
sr_levs = array.new_float(21, 0.0)
zonePerc = 0.01
line_col = [Link]
expandSR = true
// Example array set logic
if [Link]
for i = 0 to 20
[Link](sr_linesL, i, [Link](bar_index - 355, [Link](sr_levs, i) -
zonePerc, bar_index, [Link](sr_levs, i) - zonePerc, xloc.bar_index, expandSR ?
[Link] : [Link], na))
simple_filter(source, length, duel_filter) =>
duel_filter ? [Link]([Link](source, length), length) : [Link](source, length)
sr_ma(source = close, output_smoothing = 3, trigger_smoothing = 1, atr_length = 50,
multiplier = 1.0, range_switch = "Body", duel_filter = false) =>
candle_top = range_switch != "Body" ? high : [Link](open, close)
candle_bottom = range_switch != "Body" ? low : [Link](open, close)
[candle_top, candle_bottom]
// ================= IMAGE 16 =================
G_POI = "POI Settings"
ColorDemandOutline = [Link]([Link]([Link], 100), title = 'Demand',
group = G_POI)
SwingLength = [Link](10, title = 'High/Low Swing Length', group = G_POI, minval
= 1, maxval = 50)
HistoryDemandRep = [Link](21, title = 'History to maintain', minval = 5, maxval
= 50, group = G_POI)
BoxWidth = [Link](10.0, title = 'Supply/Demand Box Width', group = G_POI,
minval = 1, maxval = 10, step = 0.5)
ColorLablePOI = [Link](#bdbdbd, title = 'POI', group = G_POI)
MaxExtention = [Link](true, title = 'Extend', group = G_POI)
// Fixed Array function: [Link] and [Link] do not return the array
ArrayAddPopF(box_array, new_value_to_add) =>
[Link](box_array, new_value_to_add)
if [Link](box_array) > 0
[Link]([Link](box_array))
CheckOverlappingF(new_poi, box_array, POIATR) =>
atr_threshold = POIATR * 2
okay_to_draw = true
if [Link](box_array) > 0
for i = 0 to [Link](box_array) - 1
top = box.get_top([Link](box_array, i))
bottom = box.get_bottom([Link](box_array, i))
poi_val = (top + bottom) / 2
if [Link](new_poi - poi_val) < atr_threshold
okay_to_draw := false
break
okay_to_draw
// ================= IMAGE 17 =================
// Note: Assuming 'poi', 'box_top', 'box_bottom', etc., are defined in local scope
poi_price = (box_top + box_bottom) / 2
okay_to_draw_final = CheckOverlappingF(poi_price, box_array, 1.0) // 1.0 as
placeholder ATR
if box_type == 1 and okay_to_draw_final and POISwitch
ArrayAddPopF(box_array, [Link](left=bar_index, top=box_top, right=bar_index+5,
bottom=box_bottom))
else if box_type == -1 and okay_to_draw_final and POISwitch
ArrayAddPopF(box_array, [Link](left=bar_index, top=box_top, right=bar_index+5,
bottom=box_bottom))
BosSdF(box_array, bos_array, label_array, zone_type) =>
if zone_type == 1 and POISwitch
if [Link](box_array) > 0
for i = 0 to [Link](box_array) - 1
level_to_break = box.get_top([Link](box_array, i))
if close >= level_to_break
copied_box = [Link]([Link](box_array, i))
ArrayAddPopF(bos_array, copied_box)
// ================= IMAGE 18 =================
// Inside the logic where bos_array[0] is manipulated
if [Link](bos_array) > 0
first_box = [Link](bos_array, 0)
mid_price = (box.get_top(first_box) + box.get_bottom(first_box)) / 2
box.set_top(first_box, mid_price)
box.set_bottom(first_box, mid_price)
box.set_extend(first_box, [Link])
box.set_right(first_box, bar_index)
box.set_text(first_box, '')
box.set_text_color(first_box, [Link]([Link], 0))
box.set_text_size(first_box, [Link])
// ================= IMAGE 19 =================
if not na(SwingLow)
ArrayAddPopF(SwingLowValues, SwingLow)
ArrayAddPopF(SwingLowBNS, bar_index[SwingLength])
// Assuming SupplyDemandF is defined similarly to BosSdF
// SupplyDemandF(SwingLowValues, SwingLowBNS, DemandBoxCurrent,
DemandPOICurrent, -1, POTATR)
BosSdF(SupplyBoxCurrent, BOSSupply, SupplyPOICurrent, 1)
BosSdF(DemandBoxCurrent, BOSDemand, DemandPOICurrent, -1)
// ================= IMAGE 20 =================
var int prevBreakoutDir = 0
CLEAR = [Link]([Link], 100)
float highSrc = bosConfType == 'Candle Close' ? close : high
float lowSrc = bosConfType == 'Candle Close' ? close : low
if highSrc > prevHigh and highActive
highBroken := true
highActive := false
if lowSrc < prevLow and lowActive
lowBroken := true
lowActive := false
if marketStructure
if hh
[Link](bar_index - swingSize, pivHi, 'HH', color=CLEAR,
style=label.style_label_down, textcolor=[Link], size=[Link])
if lh
[Link](bar_index - swingSize, pivHi, 'LH', color=CLEAR,
style=label.style_label_down, textcolor=[Link], size=[Link])
if hl
[Link](bar_index - swingSize, pivLo, 'HL', color=CLEAR,
style=label.style_label_up, textcolor=[Link], size=[Link])
if ll
[Link](bar_index - swingSize, pivLo, 'LL', color=CLEAR,
style=label.style_label_up, textcolor=[Link], size=[Link])
// ================= IMAGE 21 =================
// Note: 'prevHigh', 'highActive', etc., must be declared as 'var' to persist.
var int prevBreakoutDirection = 0
CLEAR_COL = [Link]([Link], 100)
float highSrc_val = bosConfType == 'Candle Close' ? close : high
float lowSrc_val = bosConfType == 'Candle Close' ? close : low
if highSrc_val > prevHigh and highActive
highBroken := true
highActive := false
if lowSrc_val < prevLow and lowActive
lowBroken := true
lowActive := false
if marketStructure
// Use chart.fg_color or [Link]; 'swingSize' and 'pivHi' assumed defined
earlier
if hh
[Link](bar_index - swingSize, pivHi, 'HH', color=CLEAR_COL,
style=label.style_label_down, textcolor=chart.fg_color, size=[Link])
if lh
[Link](bar_index - swingSize, pivHi, 'LH', color=CLEAR_COL,
style=label.style_label_down, textcolor=chart.fg_color, size=[Link])
if hl
[Link](bar_index - swingSize, pivLo, 'HL', color=CLEAR_COL,
style=label.style_label_up, textcolor=chart.fg_color, size=[Link])
if ll
[Link](bar_index - swingSize, pivLo, 'LL', color=CLEAR_COL,
style=label.style_label_up, textcolor=chart.fg_color, size=[Link])
// ================= IMAGE 22 =================
// Fixed Shadowing: Renamed internal variable to 'res' to avoid conflict with
function name
rngfilt_func(x, r) =>
var float res = na
res := x > nz(res[1]) ? (x - r < nz(res[1]) ? nz(res[1]) : x - r) : (x + r >
nz(res[1]) ? nz(res[1]) : x + r)
res
filt_val = rngfilt_func(close, smrng)
var float upward = 0.0
upward := filt_val > filt_val[1] ? nz(upward[1]) + 1 : filt_val < filt_val[1] ? 0 :
nz(upward[1])
var float downward = 0.0
downward := filt_val < filt_val[1] ? nz(downward[1]) + 1 : filt_val > filt_val[1] ?
0 : nz(downward[1])
// ================= IMAGE 23 =================
filtx1colorx1 = [Link](#00bbd4, 100)
xxx1 = plot(CirrusCloud ? filtx1 : na, color=filtx1colorx1, linewidth=1,
title='Trend Tracer', editable = false)
xxx2 = plot(CirrusCloud ? filtx12 : na, color=filtx1colorx1, linewidth=1,
title='Trend Tracer', editable = false)
// Corrected fill syntax for v6
fill(xxx1, xxx2, color = filtx1 > filtx12 ? [Link](#9d0040, 50) :
[Link](#00cce2, 50), title="Cloud Fill")
avg_vol = [Link](volume, 20)
rsi_val = [Link](close, 14)
isBelow30 = rsi_val < 30
isAbove70 = rsi_val > 70
// ================= IMAGE 24 =================
// Fixed function naming and recursion logic
smoothrng_func(x, t, m) =>
wper = t * 2 - 1
avrng = [Link]([Link](x - x[1]), t)
[Link](avrng, wper) * m
smrngx1x5 = smoothrng_func(close, 22, 9)
smrngx1x25 = smoothrng_func(close, 15, 5)
rngfilt_custom(x5, r5) =>
var float res5 = na
res5 := x5 > nz(res5[1]) ? (x5 - r5 < nz(res5[1]) ? nz(res5[1]) : x5 - r5) :
(x5 + r5 > nz(res5[1]) ? nz(res5[1]) : x5 + r5)
res5
filtx15 = rngfilt_custom(close, smrngx1x5)
filtx125 = rngfilt_custom(close, smrngx1x25)
// ================= IMAGE 25 =================
// Fixed transp=0 (deprecated) to [Link]
zlemaPlot = powers_ema ? zlema : na
plot(zlemaPlot, title="ZLEMA", linewidth=2, color=[Link](zlemaColor, 0))
// Line management: In v6, [Link] returns a reference; we use var to keep track
for deletion
var line upperTL = na
var line middleTL = na
var line lowerTL = na
if autoTL
[Link](upperTL)
[Link](middleTL)
[Link](lowerTL)
upperTL := [Link](x1, _y1 + upDev, x2, _y2 + upDev, xloc.bar_index,
expandTrend ? [Link] : [Link], width=lineWidth1, style=lineStyle1,
color=upperTL1)
middleTL := [Link](x1, _y1, x2, _y2, xloc.bar_index, expandTrend ?
[Link] : [Link], width=lineWidth1, style=lineStyle1, color=middleTL2)
lowerTL := [Link](x1, _y1 - dnDev, x2, _y2 - dnDev, xloc.bar_index,
expandTrend ? [Link] : [Link], width=lineWidth1, style=lineStyle1,
color=lowerTL3)