3 wawes RS2021
3 wawes RS2021
3 wawes RS2021
//------------------------------------------------------------------------------
// Symbol Inputs
//-----------------------------------------------------------------------------{
sym1 = input.symbol('BINANCE:BTCUSDT', 'Symbol 1', group = 'Symbols')
sym2 = input.symbol('BINANCE:ETHUSDT', 'Symbol 2', group = 'Symbols')
sym3 = input.symbol('BINANCE:BNBUSDT', 'Symbol 3', group = 'Symbols')
sym4 = input.symbol('BINANCE:XRPUSDT', 'Symbol 4', group = 'Symbols')
sym5 = input.symbol('BINANCE:ADAUSDT', 'Symbol 5', group = 'Symbols')
sym6 = input.symbol('BINANCE:DOGEUSDT', 'Symbol 6', group = 'Symbols')
sym7 = input.symbol('BINANCE:LTCUSDT', 'Symbol 7', group = 'Symbols')
sym8 = input.symbol('BINANCE:SOLUSDT', 'Symbol 8', group = 'Symbols')
sym9 = input.symbol('BINANCE:DOTUSDT', 'Symbol 9', group = 'Symbols')
sym10 = input.symbol('BINANCE:LINKUSDT', 'Symbol 10', group = 'Symbols')
outofchannel = slope > 0 and close < y2_ - dev * devlen ? 0 : slope < 0 and close >
y2_ + dev * devlen ? 2 : -1
var label sidelab = label.new(x = bar_index - (len - 1), y = y1_, text = 'S', size
= size.large)
txt = slope > 0 ? slope > slope[1] ? '⇑' : '⇗' : slope < 0 ? slope < slope[1] ? '⇓'
: '⇘' : '⇒'
stl = slope > 0 ? slope > slope[1] ? label.style_label_up :
label.style_label_upper_right : slope < 0 ? slope < slope[1] ?
label.style_label_down : label.style_label_lower_right : label.style_label_right
label.set_style(sidelab, stl)
label.set_text(sidelab, txt)
label.set_x(sidelab, bar_index - (len - 1))
label.set_y(sidelab, slope > 0 ? y1_ - dev * devlen : slope < 0 ? y1_ + dev *
devlen : y1_)
label.set_color(sidelab, slope > 0 ? upcol : slope < 0 ? dncol : color.blue)
// direction
trendisup = math.sign(slope) != math.sign(slope[1]) and slope > 0
trendisdown = math.sign(slope) != math.sign(slope[1]) and slope < 0
alertcondition(trendisup, title = 'Up trend', message = 'Up trend')
alertcondition(trendisdown, title = 'Down trend', message = 'Down trend')
symbols = array.from(sym1, sym2, sym3, sym4, sym5, sym6, sym7, sym8, sym9, sym10)
var trend_durations = array.new_int(array.size(symbols))
var previous_slopes = array.new_float(array.size(symbols))
// Create table
table_bg_color = chart.bg_color == color.black ? color.white : color.black
table_border_color = color.white
table_text_color = color.white
//symbols = array.from(sym1, sym2, sym3, sym4, sym5, sym6, sym7, sym8, sym9, sym10)
// Update table every bar
if barstate.islast
for i = 0 to array.size(symbols) - 1 by 1
sym = array.get(symbols, i)
if str.length(sym) > 0
[trend, signal, trendisup, trendisdown, position] =
get_trend_status(sym, i)
symbol_name = array.get(str.split(sym, ':'), 1)
table.cell(statusTable, 0, i + 1, symbol_name, bgcolor =
table_bg_color, text_color = table_text_color, text_font_family =
font.family_monospace)
table.cell(statusTable, 1, i + 1, trend, bgcolor = table_bg_color,
text_color = trend == 'Bullish' ? upcol : dncol, text_font_family =
font.family_monospace)
table.cell(statusTable, 2, i + 1, position, bgcolor = table_bg_color,
text_color = position == 'Above' ? upcol : dncol, text_font_family =
font.family_monospace)
// alerts
if trendisup
alert(symbol_name + ' Up trend', alert.freq_once_per_bar_close)
else if trendisdown
alert(symbol_name + ' Down trend', alert.freq_once_per_bar_close)
// check if there is possible 3rd wave and show breakout if there is any
if array.size(zigzag) >= 8 and can_check_it
w12 = math.abs(array.get(zigzag, 2) - array.get(zigzag, 4)) /
math.abs(array.get(zigzag, 4) - array.get(zigzag, 6))
if w12 >= ret_rate_min and w12 <= ret_rate_max and (dir == 1 and high >
array.get(zigzag, 4) or dir == -1 and low < array.get(zigzag, 4))
can_check_it := false
if vol_support
thereisbo := true
// draw bo
if showbo
box.new(left=math.round(array.get(zigzag, 7)),
top=array.get(zigzag, 4), right=bar_index, bottom=array.get(zigzag, 6),
border_color=color.blue, border_width=1, border_style=line.style_dotted,
bgcolor=dir == 1 ? bupcol : bdncol)
if showwave12
line.new(x1=math.round(array.get(zigzag, 7)), y1=array.get(zigzag,
6), x2=math.round(array.get(zigzag, 5)), y2=array.get(zigzag, 4))
line.new(x1=math.round(array.get(zigzag, 5)), y1=array.get(zigzag,
4), x2=math.round(array.get(zigzag, 3)), y2=array.get(zigzag, 2))
label.new(x=math.round(array.get(zigzag, 7)), y=array.get(zigzag,
6), text='0', color=color.new(color.white, 100), textcolor=color.blue, style=dir ==
1 ? label.style_label_up : label.style_label_down)
label.new(x=math.round(array.get(zigzag, 5)), y=array.get(zigzag,
4), text='1', color=color.new(color.white, 100), textcolor=color.blue, style=dir ==
1 ? label.style_label_down : label.style_label_up)
label.new(x=math.round(array.get(zigzag, 3)), y=array.get(zigzag,
2), text='2', color=color.new(color.white, 100), textcolor=color.blue, style=dir ==
1 ? label.style_label_up : label.style_label_down)
// draw label
label.new(x=bar_index, y=array.get(zigzag, 6), color=dir == 1 ? upcol01
: dncol01, style=dir == 1 ? label.style_triangleup : label.style_triangledown,
size=size.small)
base = array.get(zigzag, 2)
wave1 = math.abs(array.get(zigzag, 4) - array.get(zigzag, 6))
if target1_enb
line.new(x1=bar_index, y1=math.max(base + dir * wave1 *
target1_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir *
wave1 * target1_ret, 0), style=line.style_dashed)
if target2_enb
line.new(x1=bar_index, y1=math.max(base + dir * wave1 *
target2_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir *
wave1 * target2_ret, 0), style=line.style_dashed)
if target3_enb
line.new(x1=bar_index, y1=math.max(base + dir * wave1 *
target3_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir *
wave1 * target3_ret, 0), style=line.style_dashed)
if target4_enb
line.new(x1=bar_index, y1=math.max(base + dir * wave1 *
target4_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir *
wave1 * target4_ret, 0), style=line.style_dashed)