// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.
0
at [Link]
//@version=5
indicator("Indicator [Signals and Trends]", overlay=true,
max_labels_count=500,explicit_plot_zorder = 1000,max_lines_count =
500,max_boxes_count = 500,precision = 10)
// Control Colors
sky = [Link]([Link](0, 219, 255), 60)
PunkCyan = #2157f3
PunkPink = #ff1100
PunkBuy = [Link]([Link](0, 255, 100), 50)
PunkSell = [Link]([Link](255, 17, 0), 50)
// Get user settings
showBuySell = input(true, "Smart Signals", group="Smart Signals",
tooltip="Confirm that the price will move strongly in the direction that the trend
points")
sensitivity = 1.3
float percentStop = na
offsetSignal = 5
smooth1 = 35
smooth2 = 45
lineColor = sky
labelColor = sky
showEmas = false
srcEma1 = close
lenEma1 = 55
srcEma2 = close
lenEma2 = 200
//showSwing = input(false, "Show SFP Signals", group="SFP SIGNALS")
//prdSwing = [Link](10, "SFP Period", 2, group="SFP SIGNALS")
colorPos = input([Link](PunkBuy, 50), "Buy Signal Color")
colorNeg = input([Link](PunkSell, 50), "Sell Signal Color")
showDashboard = input(true, "Show Dashboard", group="TREND DASHBOARD")
locationDashboard = [Link]("Top Right", "Table Location", ["Top Right",
"Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center",
"Top Left", "Middle Left", "Bottom Left"], group="TREND DASHBOARD")
tableTextColor = input([Link], "Table Text Color", group="TREND DASHBOARD")
tableBgColor = input(#000000, "Table Background Color", group="TREND
DASHBOARD")
sizeDashboard = [Link]("Small", "Table Size", ["Large", "Normal",
"Small", "Tiny"], group="TREND DASHBOARD")
// Functions
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = [Link]([Link](x - x[1]), t)
smoothrng = [Link](avrng, wper) * m
rngfilt(x, r) =>
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
percWidth(len, perc) => ([Link](len) - [Link](len)) * perc / 100
securityNoRep(sym, res, src) => [Link](sym, res, src, barmerge.gaps_off,
barmerge.lookahead_on)
swingPoints(prd) =>
pivHi = [Link](prd, prd)
pivLo = [Link] (prd, prd)
last_pivHi = [Link](pivHi, pivHi, 1)
last_pivLo = [Link](pivLo, pivLo, 1)
hh = pivHi and pivHi > last_pivHi ? pivHi : na
lh = pivHi and pivHi < last_pivHi ? pivHi : na
hl = pivLo and pivLo > last_pivLo ? pivLo : na
ll = pivLo and pivLo < last_pivLo ? pivLo : na
[hh, lh, hl, ll]
f_chartTfInMinutes() =>
float _resInMinutes = [Link] * (
[Link] ? 1 :
[Link] ? 1. :
[Link] ? 60. * 24 :
[Link] ? 60. * 24 * 7 :
[Link] ? 60. * 24 * 30.4375 : na)
f_kc(src, len, sensitivity) =>
basis = [Link](src, len)
span = [Link](len)
[basis + span * sensitivity, basis - span * sensitivity]
wavetrend(src, chlLen, avgLen) =>
esa = [Link](src, chlLen)
d = [Link]([Link](src - esa), chlLen)
ci = (src - esa) / (0.015 * d)
wt1 = [Link](ci, avgLen)
wt2 = [Link](wt1, 3)
[wt1, wt2]
f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and
src[2] > src[0]
f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and
src[2] < src[0]
f_fractalize (src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0
f_findDivs(src, topLimit, botLimit) =>
fractalTop = f_fractalize(src) > 0 and src[2] >= topLimit ? src[2] : na
fractalBot = f_fractalize(src) < 0 and src[2] <= botLimit ? src[2] : na
highPrev = [Link](fractalTop, src[2], 0)[2]
highPrice = [Link](fractalTop, high[2], 0)[2]
lowPrev = [Link](fractalBot, src[2], 0)[2]
lowPrice = [Link](fractalBot, low[2], 0)[2]
bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev
bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev
[bearSignal, bullSignal]
// Get components
source = close
smrng1 = smoothrng(source, 27, 1.5)
smrng2 = smoothrng(source, 55, sensitivity)
smrng = (smrng1 + smrng2) / 2
filt = rngfilt(source, smrng)
up = 0.0, up := filt > filt[1] ? nz(up[1]) + 1 : filt < filt[1] ? 0 :
nz(up[1])
dn = 0.0, dn := filt < filt[1] ? nz(dn[1]) + 1 : filt > filt[1] ? 0 :
nz(dn[1])
bullCond = bool(na), bullCond := source > filt and source > source[1] and up > 0
or source > filt and source < source[1] and up > 0
bearCond = bool(na), bearCond := source < filt and source < source[1] and dn > 0
or source < filt and source > source[1] and dn > 0
lastCond = 0, lastCond := bullCond ? 1 : bearCond ? -1 : lastCond[1]
bull = bullCond and lastCond[1] == -1
bear = bearCond and lastCond[1] == 1
countBull = [Link](bull)
countBear = [Link](bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
rsi = [Link](close, 21)
rsiOb = rsi > 70 and rsi > [Link](rsi, 10)
rsiOs = rsi < 30 and rsi < [Link](rsi, 10)
dHigh = securityNoRep([Link], "D", high [1])
dLow = securityNoRep([Link], "D", low [1])
dClose = securityNoRep([Link], "D", close[1])
ema1 = [Link](srcEma1, lenEma1)
ema2 = [Link](srcEma2, lenEma2)
ema = [Link](close, 144)
emaBull = close > ema
equal_tf(res) => [Link](res) == f_chartTfInMinutes() and not
[Link]
higher_tf(res) => [Link](res) > f_chartTfInMinutes() or [Link]
too_small_tf(res) => ([Link] and res=="1") or ([Link] and
[Link](res) < 10)
securityNoRep1(sym, res, src) =>
bool bull_ = na
bull_ := equal_tf(res) ? src : bull_
bull_ := higher_tf(res) ? [Link](sym, res, src, barmerge.gaps_off,
barmerge.lookahead_on) : bull_
bull_array = request.security_lower_tf([Link], higher_tf(res) ?
[Link](f_chartTfInMinutes()) + ([Link] ? "S" : "") :
too_small_tf(res) ? ([Link] ? "3" : "10") : res, src)
if [Link](bull_array) > 1 and not equal_tf(res) and not higher_tf(res)
bull_ := [Link](bull_array)
[Link](bull_array)
bull_
TF1Bull = securityNoRep1([Link], "1" , emaBull)
TF3Bull = securityNoRep1([Link], "3" , emaBull)
TF5Bull = securityNoRep1([Link], "5" , emaBull)
TF15Bull = securityNoRep1([Link], "15" , emaBull)
TF30Bull = securityNoRep1([Link], "30" , emaBull)
TF60Bull = securityNoRep1([Link], "60" , emaBull)
TF120Bull = securityNoRep1([Link], "120" , emaBull)
TF240Bull = securityNoRep1([Link], "240" , emaBull)
TF480Bull = securityNoRep1([Link], "480" , emaBull)
TFDBull = securityNoRep1([Link], "1440", emaBull)
[wt1, wt2] = wavetrend(hlc3, 9, 12)
[wtDivBear1, wtDivBull1] = f_findDivs(wt2, 15, -40)
[wtDivBear2, wtDivBull2] = f_findDivs(wt2, 45, -65)
wtDivBull = wtDivBull1 or wtDivBull2
wtDivBear = wtDivBear1 or wtDivBear2
// Colors
white = #ffffff, white30 = [Link](white, 70)
grey = #9598a1, grey30 = [Link](grey, 70)
cyan = #2157f3, cyan30 = [Link](cyan, 70)
pink = #ff1100, pink30 = [Link](pink, 70)
red = #FF5252, red30 = [Link](red , 70)
PunkGrey = [Link]([Link](93, 96, 107), 50)
// Plot
off = percWidth(300, offsetSignal)
plotshape(showBuySell and bull ? low - off : na, "Bullish Signal" , [Link]
, [Link], PunkBuy, 0, "▲" , [Link], size=[Link])
plotshape(showBuySell and bear ? high + off : na, "Bearish Signal",
[Link], [Link], PunkSell, 0, "▼", [Link], size=[Link])
plotshape([Link](wt1, wt2) and wt2 <= -53, "TP" , [Link],
[Link], cyan, size=[Link])
plotshape([Link](wt1, wt2) and wt2 >= 53, "TP", [Link],
[Link], pink, size=[Link])
srcStop = close
atrBand = srcStop * (percentStop / 100)
atrStop = trigger ? srcStop - atrBand : srcStop + atrBand
lastTrade(src) => [Link](bull or bear, src, 0)
entry_y = lastTrade(srcStop)
stop_y = lastTrade(atrStop)
tp1_y = (entry_y - lastTrade(atrStop)) * 1 + entry_y
tp2_y = (entry_y - lastTrade(atrStop)) * 2 + entry_y
tp3_y = (entry_y - lastTrade(atrStop)) * 3 + entry_y
labelTpSl(y, txt, color) =>
label labelTpSl = percentStop != 0 ? [Link](bar_index + 1, y, txt,
xloc.bar_index, [Link], color, label.style_label_left, [Link],
[Link]) : na
[Link](labelTpSl[1])
labelTpSl(entry_y, "Entry: " + [Link](math.round_to_mintick(entry_y)),
[Link])
labelTpSl(stop_y , "Stop Loss: " + [Link](math.round_to_mintick(stop_y)),
[Link])
labelTpSl(tp1_y, "Take Profit 1: " + [Link](math.round_to_mintick(tp1_y)),
[Link])
labelTpSl(tp2_y, "Take Profit 2: " + [Link](math.round_to_mintick(tp2_y)),
[Link])
labelTpSl(tp3_y, "Take Profit 3: " + [Link](math.round_to_mintick(tp3_y)),
[Link])
lineTpSl(y, color) =>
line lineTpSl = percentStop != 0 ? [Link](bar_index - (trigger ? countBull :
countBear) + 4, y, bar_index + 1, y, xloc.bar_index, [Link], color,
line.style_solid) : na
[Link](lineTpSl[1])
lineTpSl(entry_y, [Link])
lineTpSl(stop_y, [Link])
lineTpSl(tp1_y, [Link])
lineTpSl(tp2_y, [Link])
lineTpSl(tp3_y, [Link])
var dashboard_loc = locationDashboard == "Top Right" ? position.top_right :
locationDashboard == "Middle Right" ? position.middle_right : locationDashboard ==
"Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ?
position.top_center : locationDashboard == "Middle Center" ? position.middle_center
: locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard
== "Top Left" ? position.top_left : locationDashboard == "Middle Left" ?
position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? [Link] : sizeDashboard ==
"Normal" ? [Link] : sizeDashboard == "Small" ? [Link] : [Link]
var dashboard = showDashboard ? [Link](dashboard_loc, 2, 15, tableBgColor,
#000000, 2, tableBgColor, 1) : na
dashboard_cell(column, row, txt, signal=false) => [Link](dashboard, column,
row, txt, 0, 0, signal ? #000000 : tableTextColor, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column,
row, col)
if [Link] and showDashboard
dashboard_cell(0, 0 , "Punk Signals")
dashboard_cell(0, 1 , "Current Position")
dashboard_cell(0, 2 , "Current Trend")
dashboard_cell(0, 3 , "Volume")
dashboard_cell(0, 4 , "Timeframe")
dashboard_cell(0, 10, "1 H:")
dashboard_cell(0, 11, "2 H:")
dashboard_cell(0, 12, "4 H:")
dashboard_cell(0, 13, "8 H:")
dashboard_cell(0, 14, "Daily:")
dashboard_cell(1, 0 , "V.1")
dashboard_cell(1, 1 , trigger ? "Buy" : "Sell", true), dashboard_cell_bg(1, 1,
trigger ? [Link] : [Link])
dashboard_cell(1, 2 , emaBull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 2, emaBull ? [Link] : [Link])
dashboard_cell(1, 3 , [Link](volume))
dashboard_cell(1, 4 , "Trends")
dashboard_cell(1, 10, TF60Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 10, TF60Bull ? [Link] : [Link])
dashboard_cell(1, 11, TF120Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 11, TF120Bull ? [Link] : [Link])
dashboard_cell(1, 12, TF240Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 12, TF240Bull ? [Link] : [Link])
dashboard_cell(1, 13, TF480Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 13, TF480Bull ? [Link] : [Link])
dashboard_cell(1, 14, TFDBull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 14, TFDBull ? [Link] : [Link])
// Alerts
alert02 = bull
alert03 = wtDivBull
alert04 = wtDivBear
alert05 = bull or bear
alert06 = [Link](wt1, wt2) and wt2 <= -53
alert07 = [Link](wt1, wt2) and wt2 >= 53
alert09 = rsiOb or rsiOs
alert10 = bear
alerts(sym) =>
if alert02 or alert03 or alert04 or alert06 or alert07 or alert10
alert_text = alert02 ? "Strong Bullish PunkAlgo" : alert03 ? "Strong
Bearish Signal PunkAlgo" : alert04 ? "Strong Bearish Signal PunkAlgo" : alert06 ?
"TP Short Signal PunkAlgo" : alert07 ? "TP Long Signal PunkAlgo" : "Sell Signal
PunkAlgo"
alert(alert_text, alert.freq_once_per_bar_close)
alerts([Link])
alertcondition(alert02, "Buy Signal", "Buy Signal PunkAlgo")
alertcondition(alert05, "Either Buy or Sell Signal", "PunkAlgo Signal")
alertcondition(alert06, "Mild Buy Alert", "TP Long Signal PunkAlgo,
TimeFrame={{interval}}")
alertcondition(alert07, "Mild Sell Alert", "TP Short Signal PunkAlgo,
TimeFrame={{interval}}")
alertcondition(alert10, "Sell Signal", "Sell Signal PunkAlgo")
// Intelligent Trend
showIndicator = input(true,"Show Intelligent Trend", group ="Intelligent Trend
Function", tooltip="A powerful tool capable of predicting support and resistance
automatically.")
inp1 = input(5.00, "Trend Multiplier")
inp2 = input(34, "Trend Length")
inp3 = input(1.00, "Trend Zone Width")
atrs = [Link](inp2)
[showIndicator3, direction2] = [Link]([Link]([Link](7, inp1)), inp2*2)
hullup = [Link](high, [Link]([Link](21, inp2))) + atrs*[Link](inp1/2.5)
hulldown = [Link](low, [Link]([Link](21, inp2))) - atrs*[Link](inp1/2.5)
up2 = [Link](high, inp2) + atrs*[Link](inp1/3)
lo = [Link](low, inp2) - atrs*[Link](inp1/3)
supert = 0.00
supert := if close > showIndicator3
[Link](showIndicator3, hulldown, showIndicator3, up2)
else if close < showIndicator3
[Link](showIndicator3, hullup, showIndicator3, lo)
supert2 = 0.00
supert2 := if close > supert
supert + atrs*inp3
else if close < supert
supert - atrs*inp3
tool1 = plot(showIndicator ? supert : na, "Intelligent Trend line", color = close >
supert ? #2962ff : #e91e63)
tool2 = plot(showIndicator ? supert2 : na, "Intelligent Trend Zone line", color =
[Link]([Link], 95))
fill(tool1, tool2, color = close > supert ? [Link](#2962ff, 80) :
[Link](#e91e63, 80), fillgaps=false)
// MOMENTUM CANDLES
factor = [Link](0.8, "Factor", step = 0.01, group="Smart Candles", inline="z")
atrPeriod = [Link](1, "ATR Period", step = 20, group="Smart Candles",
inline="z")
smartOverlay = [Link](true, title="[Smart Overlay]", inline="z",
group="Candle Colors")
bullColor1 = [Link](#00db0a, title="[-Bull Candle-]", inline="z",
group="Candle Colors")
bearColor1 = [Link](#e10000, title="[Bear Candle]", inline="z",
group="Candle Colors")
momentumSwitch = [Link](true, title="[Momentum Switch]", inline="z",
group="Candle Colors")
momentumSwitchBull = [Link](#56328f, title="[--Switch Bull--]",
inline="z", group="Candle Colors")
momentumSwitchBear = [Link](#56328f, title="[--Switch Bear--]",
inline="z", group="Candle Colors")
closeRrealtime = true
barState = (closeRrealtime == true) ? [Link] : [Link]
[supertrend, direction] = [Link](factor, atrPeriod)
bull_STC = close > supertrend and close[1] < supertrend[1]
bear_STC = close < supertrend and close[1] > supertrend[1]
bar_DEX =(bar_index > 10)
howManyGB = ([Link](bull_STC)) + 1
howManyRB = ([Link](bear_STC)) + 1
howManyGBX = [Link](bull_STC)
howManyRBX =[Link](bear_STC)
howManyGBText = [Link](howManyGBX)
howManyRBText = [Link](howManyRBX)
// lookbackperiod so i dont get ZEROS in my look back period
lookBack = howManyGB > howManyRB ? howManyGB : howManyRB
// change color based on current charts momentum
trendColor = bull_STC and momentumSwitch and smartOverlay ? momentumSwitchBull :
bear_STC and momentumSwitch and smartOverlay ? momentumSwitchBear : close >
supertrend and smartOverlay ? bullColor1 : close < supertrend and smartOverlay ?
bearColor1 : na
barcolor(trendColor, title="Current Chart Momentum",editable=false)
//
===================================================================================
=======
var table myTable = [Link](position.top_center, 1, 1, border_width=1,
frame_color=[Link], bgcolor=[Link])