luxalgo 1
luxalgo 1
// © LuxAlgo
//@version=5
//---------------------------------------------------------------------------------------------------------------------}
//Tooltips
//---------------------------------------------------------------------------------------------------------------------{
hammer_tt = "The Hammer pattern appears at the bottom of a downtrend. It is identified by a small
upper wick (or no upper wick) with a small body, and an elongated lower wick whose length is 2X greater
than the candle body’s width."
ihammer_tt = "The Inverted Hammer pattern appears at the bottom of a downtrend. It is identified by a
small lower wick (or no lower wick) with a small body, and an elongated upper wick whose length is 2X
greater than the candle body’s width."
hman_tt = "The Hanging Man pattern appears at the top of an uptrend. It is identified by a small upper
wick (or no upper wick) with a small body, and an elongated lower wick whose length is 2X greater than
the candle body’s width."
sstar_tt = "The Shooting Star pattern appears at the top of an uptrend. It is identified by a small lower
wick (or no lower wick) with a small body, and an elongated upper wick whose length is 2X greater than
the candle body’s width."
bulle_tt = "The Bullish Engulfing pattern appear at the bottom of a downtrend. It is a 2 bar pattern,
identified by a large bullish candle body fully encapsulating (opening lower and closing higher) the
previous small (bearish) candle body."
beare_tt = "The Bearish Engulfing pattern appear at the top of a downtrend. It is a 2 bar pattern,
identified by a large bearish candle body fully encapsulating (opening higher and closing lower) the
previous small (bullish) candle body."
r3_tt = "The Rising Three Method Pattern is an indicator of continuation for the current trend. It is a 5
bar pattern, identified by an initial full-bodied bullish candle, followed by 3 bearish candles who trade
within the high and low of the initial candle, followed by another full-bodied bullish candle closing above
the high of the initial candle."
f3_tt = "The Falling Three Method Pattern is an indicator of continuation for the current trend. It is a 5
bar pattern, identified by an initial full-bodied bearish candle, followed by 3 bullish candles who trade
within the high and low of the initial candle, followed by another full-bodied bearish candle closing
below the low of the initial candle."
tws_tt = "The Three White Soldiers Pattern appears at the bottom of a downtrend. It is identified by 3
full-bodied bullish candles, each opening within the body and closing below the high, of the previous
candle."
tbc_tt = "The Three Black Crows Pattern appears at the top of an uptrend. It is identified by 3 full-bodied
bearish candles, each open within the body and closing below the low, of the previous candle."
mstar_tt = "The Morning Star Pattern appears at the bottom of a downtrend. It is a 3 bar pattern,
identified by a full-bodied bearish candle, followed by a small-bodied bearish candle, followed by a full-
bodied bullish candle that closes above the halfway point of the first candle."
estar_tt = "The Evening Star Pattern appears at the top of an uptrend. It is a 3 bar pattern, identified by a
full-bodied bullish candle, followed by a small-bodied bullish candle, followed by a full-bodied bearish
candle that closes below the halfway point of the first candle."
bullh_tt = "The Bullish Harami Pattern appears at the bottom of a downtrend. It is a 2 bar pattern,
identified by an initial bearish candle, followed by a small bullish candle whose range is entirely
contained within the body of the initial candle."
bearh_tt = "The Bearish Harami Pattern appears at the top of an uptrend. It is a 2 bar pattern, identified
by an initial bullish candle, followed by a small bearish candle whose range is entirely contained within
the body of the initial candle."
tweezer_top_tt = "The Tweezer Top bearish reversal candlestick pattern is identified by an initial bullish
candle, followed by a bearish candle, both having equal highs."
tweezer_btm_tt = "The Tweezer Bottom bullish reversal candlestick pattern is identified by an initial
bullish candle, followed by a bearish candle, both having equal lows."
//---------------------------------------------------------------------------------------------------------------------}
//User Inputs
//---------------------------------------------------------------------------------------------------------------------{
twsTog = input.bool(true, "3 White Soldiers ", group = group1, inline = "5")
//Bearish
//Trend Options
minorDCLength = input.int(10, title = "Minor Trend Length", group = "Minor Trend", tooltip = "Minor
Trend determined by Donchian Channels.")
majorEma1Length = input.int(50, title = "Short EMA Length", minval = 1, group = "EMA Parameters")
majorEma2Length = input.int(200, title = "Long EMA Length", minval = 1, group = "EMA Parameters")
majorSTFactor = input.float(4, title = "Super Trend Factor", group = "Super Trend Parameters")
//Style
bcTog = input.bool(false, title = "Color Candles", group = "Style", tooltip = "Color Candles to visualize
minor trend.")
//Dashboard
dashLoc = input.string('Bottom Right' , 'Location' , options = ['Top Right', 'Bottom Right', 'Bottom Left'] ,
group = 'Dashboard')
textSize = str.lower( input.string('Tiny', 'Size', options = ['Tiny', 'Small', 'Normal'], group = 'Dashboard') )
//---------------------------------------------------------------------------------------------------------------------}
//Functions
//---------------------------------------------------------------------------------------------------------------------{
invis = color.new(chart.bg_color,100)
//Counting
count(condition, filter)=>
var reversals = 0
var total = 0
total += condition ? 1 : 0
//SuperTrend Detection
[st,s_dir] = ta.supertrend(_factor,_length)
float no_data = na
[st,st,(s_dir*-1)]
get_ema(_len1,_len2) =>
s_ema = ta.ema(close,_len1)
l_ema = ta.ema(close,_len2)
var int s_dir = 0
s_dir := 1
s_dir := -1
[s_ema,l_ema,s_dir]
get_dc(_length) =>
upper = ta.highest((_length>0?_length:1))
lower = ta.lowest((_length>0?_length:1))
s_dir := 1
s_dir := -1
[lower,upper,s_dir]
get_choch(len)=>
var os = 0
upper = ta.highest(len)
lower = ta.lowest(len)
t = not na(top)
b = not na(btm)
if t
t_bar := bar_index-len
t_val := top
t_count := 1
if b
b_bar := bar_index-len
b_val := btm
b_count := 1
rev_up = false
rev_down = false
t_count := 0
s_dir := 1
rev_up := true
b_count := 0
s_dir := -1
rev_down := true
float no_data = na
[no_data,no_data,s_dir]
//Decodes User-Inputs into Actual values used by the script
get_trend(_type,swingLength,ema1Length,ema2Length,STFactor,STLength,DCLength) =>
switch
get_pattern_data(_signal,_bias,_dir) =>
same_trend += 1
diff_trend += 1
total = same_trend+diff_trend
[(same_trend/total),total]
//---------------------------------------------------------------------------------------------------------------------}
//Trends
//---------------------------------------------------------------------------------------------------------------------{
major_color = major_bear?bearColor:major_bull?bullColor:na
minor_color = minor_bear?bearColor:minor_bull?bullColor:na
//---------------------------------------------------------------------------------------------------------------------}
//Candestick Patterns
//---------------------------------------------------------------------------------------------------------------------{
hw_per = ((high - c_top)/hl_width)*100 //Percent of total candle width that is occupied by the upper
wick
lw_per = ((c_bot - low)/hl_width)*100 //Percent of total candle width that is occupied by the lower wick
b_per = (bod_width/hl_width)*100 //Percent of total candle width that is occupied by the candle body
//Bullish patterns
(lw_per > (b_per*2) and b_per < 50 and hw_per < 2 and not doji)
, minor_bear)
(hw_per > (b_per*2) and b_per < 50 and lw_per < 2 and not doji)
,minor_bear)
and (rc[3] and c_top[3] <= high[4] and c_bot[3] >= low[4])
and (rc[2] and c_top[2] <= high[4] and c_bot[2] >= low[4])
and (rc[1] and c_top[1] <= high[4] and c_bot[1] >= low[4])
and (gc and close > high[4] and b_per > 50)
,minor_bull[4])
rc[1] and gc and (bod_width > (bod_width[1]/2)) and (open < close[1]) and c_top > c_top[1] and (not
rising_3) and (not doji[1])
,minor_bear)
and (gc[1] and b_per[1]>70 and c_bot[1] >= c_bot[2] and c_bot[1] <= c_top[2] and close[1] > high[2])
and (gc and b_per>70 and c_bot >= c_bot[1] and c_bot <= c_top[1] and close > high[1])
,minor_bear[2])
and (rc[1] and bod_width[1] < (bod_width[2]/2) and open[1] < close[2])
,minor_bear[2])
gc and (high <= c_top[1] and low >= c_bot[1]) and rc[1]
,minor_bear[1])
,minor_bear[1])
//Bearish Patterns
(hw_per > (b_per*2) and b_per < 50 and lw_per < 2 and not doji)
,minor_bull)
(lw_per > (b_per*2) and b_per < 50 and hw_per < 2 and not doji)
,minor_bull)
and (gc[3] and c_top[3] <= high[4] and c_bot[3] >= low[4])
and (gc[2] and c_top[2] <= high[4] and c_bot[2] >= low[4])
and (gc[1] and c_top[1] <= high[4] and c_bot[1] >= low[4])
and (rc and close < low[4] and b_per > 50)
,minor_bear[4])
gc[1] and rc and (bod_width > (bod_width[1]/2)) and (open > close[1]) and c_bot < c_bot[1] and (not
falling_3 )and (not doji[1])
,minor_bull)
and (rc[1] and b_per[1]>70 and c_top[1] <= c_top[2] and c_top[1] >= c_bot[2] and close[1] < low[2])
and (rc and b_per>70 and c_top <= c_top[1] and c_top >= c_bot[1] and close < low[1])
,minor_bull[2])
and (gc[1] and bod_width[1] < (bod_width[2]/2) and open[1] > close[2])
,minor_bull[2])
rc and (high <= c_top[1] and low >= c_bot[1]) and gc[1]
,minor_bull[1])
,minor_bull[1])
//---------------------------------------------------------------------------------------------------------------------}
//Labels
//---------------------------------------------------------------------------------------------------------------------{
//Table
//---------------------------------------------------------------------------------------------------------------------{
: position.bottom_right
var t = table.new(table_position, 4, 10
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
//Table setup
if showDash
t.merge_cells(0,0,1,0)
t.merge_cells(2,0,3,0)
//Titles
// Bullish Stats
if hammerTog
if ihammerTog
if bulleTog
if r3Tog
if twsTog
t.cell(0,6, "3 White Soldiers (3WS)", text_halign = text.align_left, text_color = color.white, text_size
= textSize)
if mstarTog
if bullhTog
if btmTweezTog
// Bearish Stats
if hmanTog
if beareTog
if f3Tog
if tbcTog
t.cell(2,6, "3 Black Crows (3BC)", text_halign = text.align_left, text_color = color.white, text_size =
textSize)
if estarTog
if topTweezTog
//---------------------------------------------------------------------------------------------------------------------}
//Plots
//---------------------------------------------------------------------------------------------------------------------{
ma1 = plot(major_up, color = major_up_col, title = "Major Uptrend", style = plot.style_linebr, editable =
false)
fill(ma1,ma2,
math.max(major_up,major_down),
math.min(major_up,major_down),
//---------------------------------------------------------------------------------------------------------------------}