Lux Algo Trend
Lux Algo Trend
bullcolor = #16e045
bearcolor = #e1320f
// 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
colorZone = color.white
lbPeriod = 10
lenCons = 5
// 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 := "Buy"
StrongB := "Strong\nBuy"
SimpleSell:= "Sell"
StrongS := "Strong\nSell"
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 / length
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, "PullBack Buy" ,
shape.circle, location.belowbar, color.new(bullcolor,60), size=size.tiny)
plotshape(ta.crossunder(wt1, wt2) and Show_PR and wt2 >= 60, "PullBack 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])
trendFilter = trendcloud
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
entry_y = lastTrade(close)
stop_y = lastTrade(atrStop)
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)
buy_col = color.new(#0ac20a,0)
sell_col = color.new(#fd1605,0)
text_col = color.new(#FFFFFF,0)
// 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 = color.rgb(255, 255, 255)
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)
/////////////////////////////////////////////////////////
// Money Moves [Dashboard]
////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
/////////////
// Get user input
indicatorTF = "Chart"
// Functions
sqz(bbLen, bbMult, kcLen, kcMult, source) =>
upperBB = ta.sma(source, bbLen) + ta.stdev(source, bbLen) * bbMult
lowerBB = ta.sma(source, bbLen) - ta.stdev(source, bbLen) * bbMult
upperKC = ta.sma(source, kcLen) + ta.sma(ta.tr, kcLen) * kcMult
lowerKC = ta.sma(source, kcLen) - ta.sma(ta.tr, kcLen) * kcMult
sqzOn = lowerBB > lowerKC and upperBB < upperKC
sqzOff = lowerBB < lowerKC and upperBB > upperKC
[sqzOn, sqzOff]
qqe(rsiLen, rsiSmooth, factor, source, bbLen, bbMult) =>
rsiMa = ta.ema(ta.rsi(source, rsiLen), rsiSmooth)
delta = ta.ema(ta.ema(math.abs(ta.mom(rsiMa, 1)), rsiLen * 2 - 1), rsiLen *
2 - 1) * factor
longBand = 0.0, longBand := rsiMa > longBand[1] and rsiMa[1] >
longBand[1] ? math.max(longBand[1], rsiMa - delta) : rsiMa - delta
shortBand = 0.0, shortBand := rsiMa < shortBand[1] and rsiMa[1] <
shortBand[1] ? math.min(shortBand[1], rsiMa + delta) : rsiMa + delta
cross1 = ta.cross(rsiMa, shortBand[1])
cross2 = ta.cross(rsiMa, longBand[1])
trend = 0.0, trend := cross1 ? 1 : cross2 ? -1 : nz(trend[1], 1)
fastDelta = trend == 1 ? longBand : shortBand
_hist = rsiMa - 50
_line = fastDelta - 50
[_, upper, lower] = ta.bb(_line, bbLen, bbMult)
[_hist, _line, upper, lower]
// 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"
//---------------------------------------------------------------------------------
---------------------- Volatitiry
AvrLength = 21
PercentFilter = 144
xAavrVolume = ta.rma(volume, AvrLength)
nResLess = volume * 100 / xAavrVolume < PercentFilter ? 0 : volume
nRes = nResLess
clr = close < open ? color.red : color.green
//plot(nRes, color=clr, style=plot.style_columns, title='Volume Filter', transp=20)
VolitiText = "Inactive"
if nRes
VolitiText := "Active"
//////////////////////////////////////////
ema69 = ta.ema(close, 9)
totalSentTxt = ema69 > ema69[2] ? 'Bullish' : ema69 < ema69[2] ? 'Bearish' : 'Flat'
// INputs
//Timezones
tz_incr = 0
use_exchange = false
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
//Session A
NYSes = true
NYTxt = 'New York'
NYTime = '1300-2200'
//Session B
LDSes = true
sesb_txt = 'London'
sesb_ses = '0700-1600'
//Session C
show_sesc = true
sesc_txt = 'Tokyo'
sesc_ses = '0000-0900'
//Session D
show_sesd = true
sesd_txt = 'Sydney'
sesd_ses = '2100-0600'
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tff = timeframe.period
////////////////////////////////////////////
SessionText = "Default"
//Session a = Newyork
//Session b = London
//Session c = Tokyo
//Session d = Sydney
if is_sesd
SessionText := sesd_txt
if is_sesc
SessionText := sesc_txt
if is_sesb
SessionText := sesb_txt
if is_sesa
SessionText := NYTxt
//
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
// Middel part
dashboard_cell(1, 0 , " MONEYHACKSRWANDA STRATEGY ")
dashboard_cell(1, 2 , "🔥 Market State ")
dashboard_cell(1, 3 , "⚠️ Volatility ")
dashboard_cell(1, 4 , "🏦 Institutional Activity ")
dashboard_cell(1, 5 , "🕒 Current Session (UTC) ")
dashboard_cell(1, 6 , "🌊 Trend Pressure ")
// 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]
//alerts(sym) =>
// if alert01 or alert02 or alert03 or alert04 or alert05 or alert06 or alert07
or alert08 or alert09 or alert10 or alert11 or alert12 or alert13 or alert14 or
alert15
// alert("NEW ALERT", alert.freq_once_per_bar_close)
//alerts(syminfo.tickerid)
// 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)