INVITE-ONLY SCRIPT
Atualizado

3Signal Strategy+

25
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// Script combining Support Resistance Strategy and Buy/Sell Filter with 3 Moving Averages 3Signal Strategy+ by InteliCryptos

//version=6

indicator("3Signal Strategy+", overlay=true, max_lines_count=500)

// ====== Inputs Section ======
// HHLL Strategy Inputs
lb = input.int(3, title="Support HL", minval=1)
rb = input.int(4, title="Resistance LH", minval=1)
showsupres = input.bool(true, title="Support/Resistance", inline="srcol")
supcol = input.color(color.red, title="", inline="srcol")
rescol = input.color(color.lime, title="", inline="srcol")
srlinestyle = input.string("solid", title="Line Style", options=["solid", "dashed", "dotted"], inline="style")
srlinewidth = input.int(1, title="Line Width", minval=1, maxval=5, inline="style")
changebarcol = input.bool(true, title="Change Bar Color", inline="bcol")
bcolup = input.color(color.yellow, title="", inline="bcol")
bcoldn = input.color(color.black, title="", inline="bcol")

// Twin Range Filter Inputs
source = input(close, title="Source")
per1 = input.int(27, minval=1, title="Fast Period")
mult1 = input.float(1.6, minval=0.1, title="Fast Range")
per2 = input.int(55, minval=1, title="Slow Period")
mult2 = input.float(2, minval=0.1, title="Slow Range")

// Moving Average Inputs
ma_type1 = input.string("EMA", "MA 1 Type (Fast)", options=["EMA", "SMA", "WMA"], group="Moving Averages")
ma_length1 = input.int(12, "MA 1 Length", minval=1, group="Moving Averages")
ma_color1 = input.color(color.blue, "MA 1 Color", group="Moving Averages")

ma_type2 = input.string("EMA", "MA 2 Type (Medium)", options=["EMA", "SMA", "WMA"], group="Moving Averages")
ma_length2 = input.int(50, "MA 2 Length", minval=1, group="Moving Averages")
ma_color2 = input.color(color.yellow, "MA 2 Color", group="Moving Averages")

ma_type3 = input.string("EMA", "MA 3 Type (Slow)", options=["EMA", "SMA", "WMA"], group="Moving Averages")
ma_length3 = input.int(200, "MA 3 Length", minval=1, group="Moving Averages")
ma_color3 = input.color(color.purple, "MA 3 Color", group="Moving Averages")

ma_timeframe = input.string("", "MA Timeframe (e.g., 1m, 5m, 1H, D)", group="Moving Averages")

// ====== HHLL Strategy Logic ======
ph = ta.pivothigh(lb, rb)
pl = ta.pivotlow(lb, rb)

hl = not na(ph) ? 1 : not na(pl) ? -1 : na
zz = not na(ph) ? ph : not na(pl) ? pl : na

// Boolean conditions for ta.valuewhen
is_hl_minus1 = hl == -1
is_hl_plus1 = hl == 1
is_zz_valid = not na(zz)

prev_hl = ta.valuewhen(is_hl_minus1 or is_hl_plus1, hl, 1)
prev_zz = ta.valuewhen(is_zz_valid, zz, 1)

zz := not na(pl) and hl == -1 and prev_hl == -1 and pl > prev_zz ? na : zz
zz := not na(ph) and hl == 1 and prev_hl == 1 and ph < prev_zz ? na : zz

hl := hl == -1 and prev_hl == 1 and zz > prev_zz ? na : hl
hl := hl == 1 and prev_hl == -1 and zz < prev_zz ? na : hl
zz := na(hl) ? na : zz

findprevious() =>
ehl = hl == 1 ? -1 : 1
loc1 = 0.0, loc2 = 0.0, loc3 = 0.0, loc4 = 0.0
xx = 0
for x = 1 to 1000
if hl[x] == ehl and not na(zz[x])
loc1 := zz[x]
xx := x + 1
break
ehl := hl
for x = xx to 1000
if hl[x] == ehl and not na(zz[x])
loc2 := zz[x]
xx := x + 1
break
ehl := hl == 1 ? -1 : 1
for x = xx to 1000
if hl[x] == ehl and not na(zz[x])
loc3 := zz[x]
xx := x + 1
break
ehl := hl
for x = xx to 1000
if hl[x] == ehl and not na(zz[x])
loc4 := zz[x]
break
[loc1, loc2, loc3, loc4]

// Calling findprevious on each bar
[loc1, loc2, loc3, loc4] = findprevious()

var float a = na
var float b = na
var float c = na
var float d = na
var float e = na
if not na(hl)
a := zz
b := loc1
c := loc2
d := loc3
e := loc4

// ====== Twin Range Filter Logic ======
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng

smrng1 = smoothrng(source, per1, mult1)
smrng2 = smoothrng(source, per2, mult2)
smrng = (smrng1 + smrng2) / 2

rngfilt(x, r) =>
var float rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? (x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r) :
(x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r)
rngfilt

filt = rngfilt(source, smrng)

var float upward = 0.0
var float downward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

// ====== Moving Average Logic ======
ma_source = ma_timeframe == "" ? close : request.security(syminfo.tickerid, ma_timeframe, close, lookahead=barmerge.lookahead_on)

ma1 = ma_type1 == "EMA" ? ta.ema(ma_source, ma_length1) :
ma_type1 == "SMA" ? ta.sma(ma_source, ma_length1) :
ta.wma(ma_source, ma_length1)

ma2 = ma_type2 == "EMA" ? ta.ema(ma_source, ma_length2) :
ma_type2 == "SMA" ? ta.sma(ma_source, ma_length2) :
ta.wma(ma_source, ma_length2)

ma3 = ma_type3 == "EMA" ? ta.ema(ma_source, ma_length3) :
ma_type3 == "SMA" ? ta.sma(ma_source, ma_length3) :
ta.wma(ma_source, ma_length3)

// ====== Combined Strategy Conditions ======
_hh = not na(zz) and (a > b and a > c and c > b and c > d)
_ll = not na(zz) and (a < b and a < c and c < b and c < d)
_hl = not na(zz) and ((a >= c and (b > c and b > d and d > c and d > e)) or (a < b and a > c and b < d))
_lh = not na(zz) and ((a <= c and (b < c and b < d and d < c and d < e)) or (a > b and a < c and b > d))

hband = filt + smrng
lband = filt - smrng

longCond = source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0
shortCond = source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0

var int CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : nz(CondIni[1])

long = longCond and CondIni[1] == -1
short = shortCond and CondIni[1] == 1

// ====== Plotting Section ======
var float res = na
var float sup = na
res := _lh ? zz : res[1]
sup := _hl ? zz : sup[1]

var int trend = na
trend := close > res ? 1 : close < sup ? -1 : nz(trend[1])

res := (trend == 1 and _hh) or (trend == -1 and _lh) ? zz : res
sup := (trend == 1 and _hl) or (trend == -1 and _ll) ? zz : sup
rechange = res != res[1]
suchange = sup != sup[1]

var line resline = na
var line supline = na
if showsupres
if rechange
line.set_x2(resline, bar_index)
line.set_extend(id=resline, extend=extend.none)
resline := line.new(bar_index - rb, res, bar_index, res, color=rescol, extend=extend.right, style=srlinestyle == "solid" ? line.style_solid : srlinestyle == "dashed" ? line.style_dashed : line.style_dotted, width=srlinewidth)

if suchange
line.set_x2(supline, bar_index)
line.set_extend(id=supline, extend=extend.none)
supline := line.new(bar_index - rb, sup, bar_index, sup, color=supcol, extend=extend.right, style=srlinestyle == "solid" ? line.style_solid : srlinestyle == "dashed" ? line.style_dashed : line.style_dotted, width=srlinewidth)

// Plot HHLL signals
plotshape(_hl, text="HL", title="Higher Low", style=shape.labelup, color=color.lime, textcolor=color.black, location=location.belowbar, offset=-rb)
plotshape(_hh, text="HH", title="Higher High", style=shape.labeldown, color=color.lime, textcolor=color.black, location=location.abovebar, offset=-rb)
plotshape(_ll, text="LL", title="Lower Low", style=shape.labelup, color=color.red, textcolor=color.white, location=location.belowbar, offset=-rb)
plotshape(_lh, text="LH", title="Lower High", style=shape.labeldown, color=color.red, textcolor=color.white, location=location.abovebar, offset=-rb)

// Plot Range Filter signals
plotshape(long, title="Long", text="Long", style=shape.labelup, textcolor=color.black, size=size.tiny, location=location.belowbar, color=color.new(color.lime, 0))
plotshape(short, title="Short", text="Short", style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=color.new(color.red, 0))

// Plot Moving Averages
plot(ma1, title="MA Fast (12)", color=ma_color1, linewidth=2)
plot(ma2, title="MA Medium (50)", color=ma_color2, linewidth=2)
plot(ma3, title="MA Slow (200)", color=ma_color3, linewidth=2)

barcolor(changebarcol ? (trend == 1 ? bcolup : bcoldn) : na)

// ====== Alerts Section ======
alertcondition(long, title="Long", message="Long")
alertcondition(short, title="Short", message="Short")
Notas de Lançamento
3Signal Strategy

Tired of indicators giving false or delayed signals?
This 3-in-1 strategy combines price action, intelligent filters, and moving averages to deliver clear, fast, and highly accurate buy/sell signals.

✨ What makes this indicator different?

🔹 Support / Resistance
Detects market structure in real time.
Identifies trend shifts through high/low patterns.
Automatically plots dynamic support and resistance levels.

🔹 Buy / Sell Signal
Filters out market noise with an advanced range algorithm.
Spots clean breakouts and reversals earlier than most indicators.
Provides clear Long and Short signals directly on the chart.

🔹 3 Configurable Moving Averages
Fast MA (12) for quick entries.
Medium MA (50) to confirm the trend.
Slow MA (200) for macro market direction.

Compatible with EMA, SMA, WMA and any timeframe.

🚀 Key Advantages

✅ Crystal-clear entry and exit signals.
✅ Smart filters that cut down noise and false positives.
✅ Adaptable to any style: scalping, day trading, or swing trading.
✅ Power and simplicity combined in a single tool.

With InteliCryptos Tri-Signal Strategy, the market becomes clear, predictable, and profitable.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.