Fresh Algo Leaked.
Fresh Algo Leaked.
// Alerts Managemnt
Normalbuy_alert = input.bool(title='Buy Signal ', defval=false, inline = "NB",
group=gr_customalert)
Strongbuy_alert = input.bool(title='Strong Buy', defval=false, inline = "NB",
group=gr_customalert)
showCons = false
paintCons = false
// Signal Text
SimpleBuy = "Buy"
StrongB = "Strong\nBuy"
SimpleSell = "Sell"
StrongS = "Strong\nSell"
if TextStyle == "Normal"
SimpleBuy := "Buy"
StrongB := "Strong\nBuy"
SimpleSell:= "Sell"
StrongS := "Strong\nSell"
if TextStyle == "Minimal"
SimpleBuy := "▲"
StrongB := "▲+"
SimpleSell:= "▼"
StrongS := "▼+"
// if TextStyle == "Normal"
// bullsignalcolor := color.rgb(0, 0, 0)
// bearsignalcolor := color.rgb(0, 0, 0)
// if TextStyle == "Minimal"
// bullsignalcolor := color.rgb(0, 0, 0)
// bearsignalcolor := color.rgb(0, 0, 0)
src = close
TR = math.abs(RSII - RSII[1])
wwalpha = 1 / 50
WWMA = 0.0
ATRRSI = 0.0
TsSlow = 0.0
TsSlow := TsUP < nz(TsSlow[1]) ? TsUP : TsFast > nz(TsSlow[1]) and TsFast[1] <
nz(TsSlow[1]) ? TsDN : TsDN > nz(TsSlow[1]) ? TsDN : TsFast < nz(TsSlow[1]) and
TsFast[1] > nz(TsSlow[1]) ? TsUP : nz(TsSlow[1])
bulllim = 45
bearlim = 55
BullSignalr = ta.crossover(TsFast, TsSlow) and TsFast < bulllim
BearSignallr = ta.crossunder(TsFast, TsSlow) and TsFast > bearlim
/////////////////////////////////////////////////////////
// Trap Detector
////////////////////////////////////////////////////////
// Functions
wavetrend(src, chlLen, avgLen) =>
esa = ta.ema(src, chlLen)
d = ta.ema(math.abs(src - esa), chlLen)
ci = (src - esa) / (0.015 * d)
wt1 = ta.ema(ci, avgLen)
wt2 = ta.sma(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 = ta.valuewhen(fractalTop, src[2], 0)[2]
highPrice = ta.valuewhen(fractalTop, high[2], 0)[2]
lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2]
lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2]
bearSignal = fractalTop and high[1] > highPrice and src[1] < highPrev
bullSignal = fractalBot and low[1] < lowPrice and src[1] > lowPrev
[bearSignal, bullSignal]
// Get components
[wt1, wt2] = wavetrend(close, 5*MSTuner, 10*MSTuner)
[wtDivBear1, wtDivBull1] = f_findDivs(wt2, 10, -35)
[wtDivBear2, wtDivBull2] = f_findDivs(wt2, 40, -70)
wtDivBull = wtDivBull1 or wtDivBull2
wtDivBear = wtDivBear1 or wtDivBear2
plotshape(ta.crossover(wt1, wt2) and Show_PR and wt2 <= -60, "Reversal Dot Buy" ,
shape.circle, location.belowbar, color.new(bullcolor,60), size=size.tiny)
plotshape(ta.crossunder(wt1, wt2) and Show_PR and wt2 >= 60, "Reversal Dot Sell",
shape.circle, location.abovebar, color.new(bearcolor,60), size=size.tiny)
// Functions
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
atr(len) =>
tr = ta.tr
atr = 0.0
atr := nz(atr[1] + (tr - atr[1]) / len, tr)
supertrend(src, factor, len) =>
atr = ta.atr(len)
upperBand = src + factor * atr
lowerBand = src - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if prevSuperTrend == prevUpperBand
direction := close > upperBand ? 1 : -1
else
direction := close < lowerBand ? -1 : 1
superTrend := direction == 1 ? lowerBand : direction == -1 ? upperBand : na
dchannel(len)=>
hh = ta.highest(len)
ll = ta.lowest (len)
trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
trendScalper(show, len1, len2, len3, colorBull, colorBear, colorBarBull, colorBarBear) =>
avgOC = math.avg(open, close)
ha_o = 0.0, ha_o := na(ha_o[1]) ? avgOC : (ha_o[1] + ohlc4[1]) / 2
ema1 = ta.ema(ha_o, len1), ema2 = ta.ema(ha_o, len2), ema3 = ta.ema(ha_o, len3)
ris1 = ema1 > ema1[1], ris2 = ema2 > ema2[1], ris3 = ema3 > ema3[1]
fal1 = ema1 < ema1[1], fal2 = ema2 < ema2[1], fal3 = ema3 < ema3[1]
colorEma1 = ris1 ? colorBull : fal1 ? colorBear : na, colorEma2 = ris2 ? colorBull : fal2 ?
colorBear : na, colorEma3 = ris3 ? colorBull : fal3 ? colorBear : na
fillEma1 = avgOC > ema1 ? colorBull : avgOC < ema1 ? colorBear : na, fillEma2 = ema1
> ema2 ? colorBull : ema1 < ema2 ? colorBear : na, fillEma3 = ema2 > ema3 ? colorBull :
ema2 < ema3 ? colorBear : na
colorBar = close < ema1 and close < ema2 ? colorBarBear : colorBarBull
[avgOC, show ? ema1 : na, show ? ema2 : na, show ? ema3 : na, color.new(colorEma1, 55),
color.new(colorEma2, 45), color.new(colorEma3, 35), color.new(fillEma1, 85),
color.new(fillEma2, 80), color.new(fillEma3, 75), colorBar]
candlesMom() =>
[_, _, macd] = ta.macd(close, 2, 4, 3)
(macd > 10 and macd > macd[1]) or (macd < 10 and macd < macd[1])
// Get components
trendFilter = trendcloud
bull = (Presets == "All Signals" ? ta.crossover (close, supertrend) : confBull and not
confBull[1]) and Presets != "Trend Scalper" and (StrongSignalsOnly ? close > StrongFilter :
none) and (ContrarianOnly ? ContBull : none) and (consSignalsFilter ? consFilter : none) and
(highVolSignals ? volFilter : none) and (signalsTrendCloud ? (periodTrendCloud ==
"Smooth" ? ema150 > ema250 : close > trendFilter) : none)
bear = (Presets == "All Signals" ? ta.crossunder(close, supertrend) : confBear and not
confBear[1]) and Presets != "Trend Scalper" and (StrongSignalsOnly ? close < StrongFilter :
none) and (ContrarianOnly ? ContBear : none) and (consSignalsFilter ? consFilter : none)
and (highVolSignals ? volFilter : none) and (signalsTrendCloud ? (periodTrendCloud ==
"Smooth" ? ema150 < ema250 : close < trendFilter) : none)
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
entry_y = lastTrade(close)
stop_y = lastTrade(atrStop)
buy = showSignals and bull ? label.new(bar_index, low , close > StrongFilter ? StrongB :
SimpleBuy , xloc.bar_index, yloc.belowbar, bullcolor, label.style_label_up , #000000,
size.normal) : na
sell = showSignals and bear ? label.new(bar_index, high, close < StrongFilter ? StrongS :
SimpleSell , xloc.bar_index, yloc.abovebar, bearcolor , label.style_label_down, #000000,
size.normal) : na
tpLabels(tp) =>
tp1Bull = ta.crossover (rsi, 70), tp2Bull = ta.crossover (rsi, 75), tp3Bull = ta.crossover (rsi,
80)
tp1Bear = ta.crossunder(rsi, 30), tp2Bear = ta.crossunder(rsi, 25), tp3Bear =
ta.crossunder(rsi, 20)
tp1Bull := tp1Bull and (nz(ta.barssince(tp1Bull)[1], 9999) > countBull), tp2Bull := tp2Bull
and (ta.barssince(tp1Bull)[1] <= countBull), tp2Bull := tp2Bull and (nz(ta.barssince(tp2Bull)
[1], 9999) > countBull), tp3Bull := tp3Bull and (ta.barssince(tp2Bull)[1] <= countBull),
tp3Bull := tp3Bull and (nz(ta.barssince(tp3Bull)[1], 9999) > countBull)
tp1Bear := tp1Bear and (nz(ta.barssince(tp1Bear)[1], 9999) > countBear), tp2Bear :=
tp2Bear and (ta.barssince(tp1Bear)[1] <= countBear), tp2Bear := tp2Bear and
(nz(ta.barssince(tp2Bear)[1], 9999) > countBear), tp3Bear := tp3Bear and
(ta.barssince(tp2Bear)[1] <= countBear), tp3Bear := tp3Bear and (nz(ta.barssince(tp3Bear)[1],
9999) > countBear)
// Candle Coloring
// Input
FastteyLength = 12
SjlowLeyLength = 26
srrrc = close
signalXLength = 9
// Data reference
[MacdX, signalX, histX] = ta.macd(srrrc, FastteyLength, SjlowLeyLength, signalXLength)
// 4 level of green
// greenHigh = #eeff00
// greenMidHigh = #c7ca00
// greenMidLow = #ddb500
// greenLow = #8635ff
// // Yellow
// yellowLow = #8635ff
// // 4 level of red
// redHigh = #ffffff
// redMidHigh = #cecece
// redMidLow = #dbdbdb
// redLow = #8635ff
// // Default color
// candleBody = yellowLow
// // Ranging trend
// if histX > 0
// if histX > histX[1] and histX[1] > 0
// candleBody := greenLow
// if histX < 0
// if histX < histX[1] and histX[1] < 0
// candleBody := redLow
// // Bullish trend
// if MacdX > 0 and histX > 0
// candleBody := greenMidLow
// // Bearish trend
// if MacdX < 0 and histX < 0
// candleBody := redMidLow
//barcolor(candleBody)
//barcolor(TrendMap == 'RSI Gradient' ? barColour : na, title='Bar colors
(heatmap)',editable=false)
//barcolor(momentumCandles and candlesMom() ? color.rgb(187, 187, 187) : TrendMap ==
'Signal Based' ? (Presets == "Trend Scalper" ? colorBar : na(countBull) and na(countBear) ?
color.gray : trigger ? bullcolor : bearcolor) : TrendMap == 'RSI Gradient' ? barColour :
TrendMap == 'Trend Gradient' ? candleBody : na , editable=false)
//plotcandle(open, high, low, close , color = momentumCandles and candlesMom() ?
color.rgb(187, 187, 187) : TrendMap == 'Signal Based' ? (Presets == "Trend Scalper" ?
colorBar : na(countBull) and na(countBear) ? color.gray : trigger ? bullcolor : bearcolor) :
TrendMap == 'RSI Gradient' ? barColour : TrendMap == 'Trend Gradient' ? candleBody : na ,
editable=false , wickcolor = momentumCandles and candlesMom() ? color.rgb(187, 187,
187) : TrendMap == 'Signal Based' ? (Presets == "Trend Scalper" ? colorBar : na(countBull)
and na(countBear) ? color.gray : trigger ? bullcolor : bearcolor) : TrendMap == 'RSI
Gradient' ? barColour : TrendMap == 'Trend Gradient' ? candleBody : na , editable=false ,
bordercolor = momentumCandles and candlesMom() ? color.rgb(187, 187, 187) : TrendMap
== 'Signal Based' ? (Presets == "Trend Scalper" ? colorBar : na(countBull) and na(countBear)
? color.gray : trigger ? bullcolor : bearcolor) : TrendMap == 'RSI Gradient' ? barColour :
TrendMap == 'Trend Gradient' ? candleBody : na , editable=false , editable = false)
fill(plot(showTrendCloud and periodTrendCloud == "Smooth" ? ema150 : na, "", na,
editable=false), plot(showTrendCloud and periodTrendCloud == "Smooth" ? ema250 : na, "",
na, editable=false), ema150 > ema250 ? color.new(bullcolor, 70) : ema150 < ema250 ?
color.new(bearcolor, 70) : na)
// Get components
cond(_offset) =>
top = ta.highest(high, 10)
bot = ta.lowest(low, 10)
osc = ta.ema(hlc3, 5) - ta.ema(ohlc4, 20)
oscRis = osc > osc[1]
oscFal = osc < osc[1]
oscA0 = osc > 0
oscB0 = osc < 0
oscTop = oscFal and oscRis[1]
oscBot = oscRis and oscFal[1]
bullR = oscB0 and oscBot and ((osc > ta.valuewhen(oscB0 and oscBot, osc, 1) and bot <
ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearR = oscA0 and oscTop and ((osc < ta.valuewhen(oscA0 and oscTop, osc, 1) and top >
ta.valuewhen(oscA0 and oscTop, top, 1)))
bullH = oscB0 and oscBot and ((osc < ta.valuewhen(oscB0 and oscBot, osc, 1) and bot >
ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearH = oscA0 and oscTop and ((osc > ta.valuewhen(oscA0 and oscTop, osc, 1) and top <
ta.valuewhen(oscA0 and oscTop, top, 1)))
[sqzOn, sqzOff] = sqz(20, 2, 20, 2, close)
[_hist1, _line1, upper1, lower1] = qqe(6, 6, 3, close, 50, 0.001)
[_hist2, _line2, upper2, lower2] = qqe(6, 5, 1.618, close, 50, 1)
[_, _, tvr] = ta.dmi(14, 14)
[osc[_offset], oscRis[_offset], oscFal[_offset], oscA0[_offset], oscB0[_offset],
oscTop[_offset], oscBot[_offset], bullR[_offset], bearR[_offset], bullH[_offset],
bearH[_offset], sqzOn[_offset], sqzOff[_offset], _hist1[_offset], upper1[_offset],
lower1[_offset], _hist2[_offset], _line2[_offset], tvr[_offset]]
tf = indicatorTF == "Chart" ? timeframe.period : indicatorTF == "1 minute" ? "1" :
indicatorTF == "3 minutes" ? "3" : indicatorTF == "5 minutes" ? "5" : indicatorTF == "10
minutes" ? "10" : indicatorTF == "15 minutes" ? "15" : indicatorTF == "30 minutes" ? "30" :
indicatorTF == "45 minutes" ? "45" : indicatorTF == "1 hour" ? "60" : indicatorTF == "2
hours" ? "120" : indicatorTF == "3 hours" ? "180" : indicatorTF == "4 hours" ? "240" :
indicatorTF == "12 hours" ? "720" : indicatorTF == "1 day" ? "1D" : indicatorTF == "1
week" ? "1W" : indicatorTF == "1 month" ? "1M" : na
[osc, oscRis, oscFal, oscA0, oscB0, oscTop, oscBot, bullR, bearR, bullH, bearH, sqzOn,
sqzOff, _hist1, upper1, lower1, _hist2, _line2, tvr] = request.security(syminfo.tickerid, tf,
cond(indicatorTF != "Chart" and barstate.isrealtime ? 1 : 0))
//colorTVR = tvr < 15 ? #F6525F : tvr > 15 and tvr < 25 ? #B2B5BE : #66BB6A
// Plots
//plot(Presets == "Money Moves TrendVR" ? tvr : na, "", colorTVR, editable=false)
TrendText = "Trending"
if tvr < 15 and tvr < 25
TrendText := "No trend"
if is_sesd
SessionText := sesd_txt
if is_sesc
SessionText := sesc_txt
if is_sesb
SessionText := sesb_txt
if is_sesa
SessionText := NYTxt
if is_sesd and is_sesc
SessionText := "Sydney/Tokyo"
if is_sesb and is_sesc
SessionText := "Tokyo/London"
if is_sesb and is_sesa
SessionText := "London/Newyork"
if is_sesa and is_sesd
SessionText := "Newyork/Sydney"
//-----------------------------------------------------------------------------}
//Overlays color.green : color.red
//
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" ? size.large : sizeDashboard == "Normal" ?
size.normal : sizeDashboard == "Small" ? size.small : size.tiny
var dashboard = showDashboard ? table.new(dashboard_loc, 3, 7, color.rgb(30, 34, 45 ,
60), #3d384300, 2, color.rgb(30, 34, 45 , 60), 1) : na
dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column, row, txt, 0, 0,
signal ? #000000 : color.white, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column, row, col)
if barstate.islast and showDashboard
// MTF Trend
dashboard_cell(0, 0 , "MTF")
dashboard_cell(0, 2 , "M5") , dashboard_cell_bg(0, 2 , TF5Bull ? #00dbff : #b2b5be)
dashboard_cell(0, 3 , "M15") , dashboard_cell_bg(0, 3 , TF15Bull ? #00dbff : #b2b5be)
dashboard_cell(0, 4 , "M30") , dashboard_cell_bg(0, 4 , TF30Bull ? #00dbff : #b2b5be)
dashboard_cell(0, 5 , "1H") , dashboard_cell_bg(0, 5 , TF60Bull ? #00dbff : #b2b5be)
dashboard_cell(0, 6 , "4H") , dashboard_cell_bg(0, 6 , TF240Bull ? #00dbff : #b2b5be)
// Middel part
dashboard_cell(1, 0 , " Fresh Algo | Signals & Overlays™ ")
// End part
dashboard_cell(2, 0 , "")
dashboard_cell(2, 2 , TrendText)
dashboard_cell(2, 3 , str.tostring(percentVol, '##.##') + '%')
dashboard_cell(2, 4 , VolitiText)
dashboard_cell(2, 5 , SessionText)
dashboard_cell(2, 6 , totalSentTxt)
// Alerts
f_sl_crossed() =>
ret = false
stop = ShowTrailingSL ? trailingStop : stop_y
crossBull = low [1] >= stop[1] and low < stop[1] and ta.barssince(low [1] >= stop[1] and
low < stop[1])[1] >= countBull - 1
crossBear = high[1] <= stop[1] and high > stop[1] and ta.barssince(high[1] <= stop[1] and
high > stop[1])[1] >= countBear - 1
ret := trigger[1] ? crossBull : crossBear
f_tp_crossed(tp) =>
ret = false
profit = tp
crossBull = high[1] <= profit[1] and high > profit[1] and ta.barssince(high[1] <= profit[1]
and high > profit[1])[1] >= countBull - 1
crossBear = low [1] >= profit[1] and low < profit[1] and ta.barssince(low [1] >= profit[1]
and low < profit[1])[1] >= countBear - 1
ret := trigger[1] ? crossBull : crossBear
alert01 = (bull and close <= StrongFilter) or (bear and close >= StrongFilter)
alert02 = bull or bear
alert03 = (bull and close > StrongFilter) or (bear and close < StrongFilter)
alert04 = bull and close <= StrongFilter
alert06 = bear and close >= StrongFilter
alert07 = bull and close > StrongFilter
alert08 = bear and close < StrongFilter
alert09 = f_sl_crossed()
alert11 = f_tp_crossed(tp1_y)
alert12 = f_tp_crossed(tp2_y)
alert13 = f_tp_crossed(tp3_y)
alert14 = periodTrendCloud == "Smooth" ? ta.crossunder(ema150, ema250) : (close <
trendcloud) and (close > trendcloud)[1]
alert15 = periodTrendCloud == "Smooth" ? ta.crossover (ema150, ema250) : (close >
trendcloud) and (close < trendcloud)[1]
// Signal Alerts
if alert04 and Normalbuy_alert
alert('Buy Signal Alert !!!' , alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if alert07 and Strongbuy_alert
alert('Strong Buy Signal Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if (bear and close >= StrongFilter) and Normalsell_alert
alert('Sell Signal Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if (bear and close < StrongFilter) and Strongsell_alert
alert('Strong Sell Signal Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
// Risk Management Alerts
if alert09 and slalert
alert('SL Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if alert11 and tp1alert
alert('Target 1 Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if alert12 and tp2alert
alert('Target 2 Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if alert13 and tp3alert
alert('Target 3 Alert !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
// Cloud Alert
if alert15 and bullcrosscloud_alert
alert('Cloud Turned Bullish !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if alert14 and bearcrosscloud_alert
alert('Cloud Turned Bearish !!!', alert.freq_once_per_bar_close)
alert(syminfo.tickerid)
if hist < 0
if hist < hist[1] and hist[1] < 0
candleBodyd := redLowh
// Bullish trend
if macdda > 0 and hist > 0
candleBodyd := greenMidLowh
os = 0,max = 0.,min = 0.
os := src > upper ? 1 : src < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := ta.cross(src,spt) ? math.max(src,max[1]) : os == 1 ? math.max(src,max[1]) : spt
min := ta.cross(src,spt) ? math.min(src,min[1]) : os == 0 ? math.min(src,min[1]) : spt
math.avg(max,min)
//------------------------------------------------------------------------------
tenkan = avg(close,tenkan_len,tenkan_mult)
kijun = avg(close,kijun_len,kijun_mult)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
//------------------------------------------------------------------------------