EWE_1
EWE_1
outofchannel_lrgc = slope > 0 and close < y2_ - dev * devlen_lrgc ? 0 : slope < 0
and close > y2_ + dev * devlen_lrgc ? 2 : -1
// direction
trendisup_lrgc = math.sign(slope) != math.sign(slope[1]) and slope > 0
trendisdown_lrgc = math.sign(slope) != math.sign(slope[1]) and slope < 0
alertcondition(trendisup_lrgc, title = 'Up trend', message = 'Up trend')
alertcondition(trendisdown_lrgc, title = 'Down trend', message = 'Down trend')
// Color Scheme
bullcolor_obf = colors_obf == 'DARK' ? color.white : color.green
bearcolor_obf = colors_obf == 'DARK' ? color.blue : color.red
int upcandles_obf = 0
for i = 1 to periods_obf by 1
upcandles_obf := upcandles_obf + (close[i] > open[i] ? 1 : 0) // Determine
color of subsequent candles (must all be green to identify a valid Bearish OB)
upcandles_obf
int downcandles_obf = 0
for i = 1 to periods_obf by 1
downcandles_obf := downcandles_obf + (close[i] < open[i] ? 1 : 0) // Determine
color of subsequent candles (must all be red to identify a valid Bearish OB)
downcandles_obf
// Plotting
line.delete(linebull2_obf)
linebull2_obf := line.new(x1 = bar_index, y1 = OB_bull_high_obf, x2 = bar_index
- 1, y2 = OB_bull_high_obf, extend = extend.left, color = bullcolor_obf, style =
line.style_dashed, width = 1)
line.delete(linebull3_obf)
linebull3_obf := line.new(x1 = bar_index, y1 = OB_bull_low_obf, x2 = bar_index
- 1, y2 = OB_bull_low_obf, extend = extend.left, color = bullcolor_obf, style =
line.style_dashed, width = 1)
linebull3_obf
line.delete(linebear2_obf)
linebear2_obf := line.new(x1 = bar_index, y1 = OB_Bear_high_obf, x2 = bar_index
- 1, y2 = OB_Bear_high_obf, extend = extend.left, color = bearcolor_obf, style =
line.style_dashed, width = 1)
line.delete(linebear3_obf)
linebear3_obf := line.new(x1 = bar_index, y1 = OB_Bear_low_obf, x2 = bar_index
- 1, y2 = OB_Bear_low_obf, extend = extend.left, color = bearcolor_obf, style =
line.style_dashed, width = 1)
linebear3_obf
if OB_bull_avg_obf > 0
latest_bull_avg_obf := OB_bull_avg_obf
latest_bull_avg_obf
if OB_bull_low_obf > 0
latest_bull_low_obf := OB_bull_low_obf
latest_bull_low_obf
if OB_Bear_high_obf > 0
latest_bear_high_obf := OB_Bear_high_obf
latest_bear_high_obf
if OB_Bear_avg_obf > 0
latest_bear_avg_obf := OB_Bear_avg_obf
latest_bear_avg_obf
if OB_Bear_low_obf > 0
latest_bear_low_obf := OB_Bear_low_obf
latest_bear_low_obf
// Plot invisible characters to be able to show the values in the Data Window
plotchar(latest_bull_high_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bull High')
plotchar(latest_bull_avg_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bull Avg')
plotchar(latest_bull_low_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bull Low')
plotchar(latest_bear_high_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bear High')
plotchar(latest_bear_avg_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bear Avg')
plotchar(latest_bear_low_obf, char = ' ', location = location.abovebar, color =
color.new(#777777, 100), size = size.tiny, title = 'Latest Bear Low')
if info_pan_obf
draw_InfoPanel(panel_text_obf, info_panel_x_obf, info_panel_y_obf, size.normal)
if showdocu_obf
l_docu := label.new(x = time + chper_obf * 35, y = close, text = 'DOCU OB',
color = color.gray, textcolor = color.white, style = label.style_label_center, xloc
= xloc.bar_time, yloc = yloc.price, size = size.tiny, textalign = text.align_left,
tooltip = vartooltip_obf)
l_docu
//----
length_ex_p_conn = input(100)
astart_ex_p_conn = input(1, 'A-High Position')
aend_ex_p_conn = input(0, 'B-High Position')
bstart_ex_p_conn = input(1, 'A-Low Position')
bend_ex_p_conn = input(0, 'B-Low Position')
csrc_ex_p_conn = input(false, 'Use Custom Source ?')
src_ex_p_conn = input(close, 'Custom Source')
//----
up_ex_p_conn = ta.pivothigh(csrc_ex_p_conn ? src_ex_p_conn : high,
length_ex_p_conn, length_ex_p_conn)
dn_ex_p_conn = ta.pivotlow(csrc_ex_p_conn ? src_ex_p_conn : low, length_ex_p_conn,
length_ex_p_conn)
//----
n_ex_p_conn = bar_index
a1_ex_p_conn = ta.valuewhen(not na(up_ex_p_conn), n_ex_p_conn, astart_ex_p_conn)
b1_ex_p_conn = ta.valuewhen(not na(dn_ex_p_conn), n_ex_p_conn, bstart_ex_p_conn)
a2_ex_p_conn = ta.valuewhen(not na(up_ex_p_conn), n_ex_p_conn, aend_ex_p_conn)
b2_ex_p_conn = ta.valuewhen(not na(dn_ex_p_conn), n_ex_p_conn, bend_ex_p_conn)
//----
line upper_ex_p_conn = line.new(n_ex_p_conn[n_ex_p_conn - a1_ex_p_conn +
length_ex_p_conn], up_ex_p_conn[n_ex_p_conn - a1_ex_p_conn],
n_ex_p_conn[n_ex_p_conn - a2_ex_p_conn + length_ex_p_conn],
up_ex_p_conn[n_ex_p_conn - a2_ex_p_conn], extend = extend.right, color =
color.blue, width = 2)
line lower_ex_p_conn = line.new(n_ex_p_conn[n_ex_p_conn - b1_ex_p_conn +
length_ex_p_conn], dn_ex_p_conn[n_ex_p_conn - b1_ex_p_conn],
n_ex_p_conn[n_ex_p_conn - b2_ex_p_conn + length_ex_p_conn],
dn_ex_p_conn[n_ex_p_conn - b2_ex_p_conn], extend = extend.right, color =
color.orange, width = 2)
line.delete(upper_ex_p_conn[1])
line.delete(lower_ex_p_conn[1])
//----
label ahigh_ex_p_conn = label.new(n_ex_p_conn[n_ex_p_conn - a1_ex_p_conn +
length_ex_p_conn], up_ex_p_conn[n_ex_p_conn - a1_ex_p_conn], 'A-High', color =
color.blue, style = label.style_label_down, textcolor = color.white, size =
size.small)
label bhigh_ex_p_conn = label.new(n_ex_p_conn[n_ex_p_conn - a2_ex_p_conn +
length_ex_p_conn], up_ex_p_conn[n_ex_p_conn - a2_ex_p_conn], 'B-High', color =
color.blue, style = label.style_label_down, textcolor = color.white, size =
size.small)
label alow_ex_p_conn = label.new(n_ex_p_conn[n_ex_p_conn - b1_ex_p_conn +
length_ex_p_conn], dn_ex_p_conn[n_ex_p_conn - b1_ex_p_conn], 'A-Low', color =
color.orange, style = label.style_label_up, textcolor = color.white, size =
size.small)
label blow_ex_p_conn = label.new(n_ex_p_conn[n_ex_p_conn - b2_ex_p_conn +
length_ex_p_conn], dn_ex_p_conn[n_ex_p_conn - b2_ex_p_conn], 'B-Low', color =
color.orange, style = label.style_label_up, textcolor = color.white, size =
size.small)
label.delete(ahigh_ex_p_conn[1])
label.delete(bhigh_ex_p_conn[1])
label.delete(alow_ex_p_conn[1])
label.delete(blow_ex_p_conn[1])
//----
plot(up_ex_p_conn, 'Pivot High\'s', color.new(color.blue, 0), 4, style =
plot.style_circles, offset = -length_ex_p_conn, join = true)
plot(dn_ex_p_conn, 'Pivot Low\'s', color.new(color.orange, 0), 4, style =
plot.style_circles, offset = -length_ex_p_conn, join = true)
//#!
showTF = input.bool(true, 'show time frame', inline = '24')
showpf = input.bool(true, 'show prefix title', inline = '24')
string i_tableYpos = input.string('bottom', 'Position', inline = '12', options =
['top', 'middle', 'bottom'])
string i_tableXpos = input.string('center', '', inline = '12', options = ['left',
'center', 'right'])
size1 = input.string('huge', 'title', inline = '14', options = ['tiny', 'small',
'normal', 'large', 'huge', 'auto'])
size2 = input.string('auto', 'extra', inline = '14', options = ['tiny', 'small',
'normal', 'large', 'huge', 'auto'])
color = input.color(#999999, 'color')
string = input.string('by EarnWithEnigma', 'your signature')
seperator = input.string('/', 'seperator')
cur = syminfo.currency
base = syminfo.basecurrency
exchange = syminfo.prefix
getTimeFrame() =>
tf = timeframe.multiplier
tfstr = ''
if timeframe.isseconds
tfstr := 's'
tfstr
if timeframe.isminutes
if tf >= 60
tf := tf / 60
tfstr := 'h'
tfstr
else
tfstr := 'm'
tfstr
if timeframe.isdaily
tfstr := 'D'
tfstr
if timeframe.isweekly
tfstr := 'W'
tfstr
if timeframe.ismonthly
tfstr := 'M'
tfstr
[tfstr, str.tostring(tf)]
if barstate.islast
// ================================== //
// ------------> Tips <-------------- //
// ================================== //
leftTip = 'Look left for swing high/low in x number of bars to form pivot'
rightTip = 'Look right for swing high/low in x number of bars to form pivot'
nPivTip = 'This sets the array size, or the number of pivots to track at a time (x
highs, and x number of lows)'
atrLenTip = 'Number of bars to average. ATR is used to standardize zone width
between assets and timeframes'
multTip = 'ATR multiplier to set zone width. Default is half of one ATR from box
bottom to box top'
perTip = 'Max zone size as a percent of price. Some assets can be too volatile at
low prices creating an unreasonably sized zone'
srcTip = 'Source input for pivots. Default tracks the highest and lowest bodies of
HA candles to average price action, whcih can result in a level that sits in the
overlap of support and resistance'
alignZonesTip = 'Alligns recurring zones whos edges overlap an existing zone
creating a zone that ages in time and intensifies visually'
// ================================== //
// ---------> User Input <----------- //
// ================================== //
moveBull = input.color(#64b5f6, '', inline = '5', group = 'Moves From S&R Color')
moveBear = input.color(#ffeb3b, '', inline = '5', group = 'Moves From S&R Color')
moveBullTransp = input.int(40, '', inline = '5', group = 'Moves From S&R Color')
moveBearTransp = input.int(40, '', inline = '5', group = 'Moves From S&R Color',
tooltip = moveTip)
// ================================== //
// -----> Immutable Constants <------ //
// ================================== //
sync = bar_index
confirmed = barstate.isconfirmed
var pivotHigh = array.new_box(nPiv)
var pivotLows = array.new_box(nPiv)
var highBull = array.new_bool(nPiv)
var lowsBull = array.new_bool(nPiv)
var bullBorder = color.new(bullCol, bordTransp)
var bullBgCol = color.new(bullCol, bgTransp)
var bearBorder = color.new(bearCol, bordTransp)
var bearBgCol = color.new(bearCol, bgTransp)
var upCol = color.new(bullBreak, bullTransp)
var dnCol = color.new(bearBreak, bearTransp)
var supCol = color.new(resBreakCol, resBreakTransp)
var resCol = color.new(supBreakCol, supBreakTransp)
var fBull = color.new(falseBullCol, falseBullTransp)
var fBear = color.new(falseBearCol, falseBearTransp)
var moveBullCol = color.new(moveBull, moveBullTransp)
var moveBearCol = color.new(moveBear, moveBearTransp)
// ================================== //
// ---> Functional Declarations <---- //
// ================================== //
_haBody() =>
haClose = (open + high + low + close) / 4
haOpen = float(na)
haOpen := na(haOpen[1]) ? (open + close) / 2 : (nz(haOpen[1]) + nz(haClose[1]))
/ 2
[haOpen, haClose]
_extend(_x) =>
for i = 0 to array.size(_x) - 1 by 1
box.set_right(array.get(_x, i), sync)
falseBreak(_l) =>
bool _d = false
bool _u = false
for i = 1 to lookback by 1
if _l[i] < _l and _l[i + 1] >= _l and _l[1] < _l
_d := true
_d
if _l[i] > _l and _l[i + 1] <= _l and _l[1] > _l
_u := true
_u
[_d, _u]
// ================================== //
// ----> Variable Calculations <----- //
// ================================== //
HH = pivot_high + band
HL = pivot_high - band
LH = pivot_low + band
LL = pivot_low - band
// ================================== //
// --------> Logical Order <--------- //
// ================================== //
_extend(pivotHigh)
_extend(pivotLows)
// ================================== //
// ----> Conditional Parameters <---- //
// ================================== //
bullCheck = not resBreak and not resBreak[1] and (fh or fl) and close > open and
(hb or lb)
bearCheck = not supBreak and not supBreak[1] and (fh or fl) and close < open and
not(hb or lb)
// ================================== //
// ------> Graphical Display <------- //
// ================================== //
// ================================== //
// -----> Alert Functionality <------ //
// ================================== //
if plotResBreak
alert('Resistance broke on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
if plotSupBreak
alert('Resistance broke on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
if plotBullCheck
alert('Pushing Off Key Level Support on ' + timeframe.period + ' chart. Price
is ' + str.tostring(close), alertMode)
if plotBearCheck
alert('Pushing Off Key Level Resistance on ' + timeframe.period + ' chart.
Price is ' + str.tostring(close), alertMode)
if plotFalseDn
alert('False Break Down on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
if plotFalseUp
alert('False Break Up on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
if plotBreakOut
alert('Breakout on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
if plotBreakDn
alert('Breakdown on ' + timeframe.period + ' chart. Price is ' +
str.tostring(close), alertMode)
//~~ Inputs {
int prd = input.int(12, 'Period', minval = 1, inline = 'setting')
float mult1 = input.float(2.0, 'Mult', minval = 0.1, step = .1, inline = 'setting',
tooltip = 'Set the Bollinger Band period. \n\nSet the multiplier.')
bool showZigZag = input.bool(true, 'ZigZag', inline = 'zigzag')
string signal = input.string('Signal', '', ['Signal', 'Peak Distance'], inline =
'zigzag')
string dev1 = input.string('ZigZag', '', ['ZigZag', 'High/Low', 'Close'], inline =
'zigzag', tooltip = 'Enable the ZigZag Bollinger Signals. \n\nSelect if you only
want to display the signals or the Peak Signal Distance between each signal. \n\
nThe Signal Distance can be calculated using the ZigZag, High/Low, or Close.')
bool showTable = input.bool(false, 'Average/Median Distance', inline = '', tooltip
= 'Enable the Table that displays the Average or Median ZigZag move.')
bool showTP = input.bool(false, 'Take Profit', inline = 'tp')
string Tp = input.string('Median', '', ['Median', 'Average'], inline = 'tp',
tooltip = 'Enable the Take-Profit line. \n\nSelect if the TP should be based on the
Average or Median move.')
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
//~~ Methods{
//ZigZag
method zigzag(ZigZag z, c, p, l) =>
y2 = dev1 == 'ZigZag' ? sbt.s : dev1 == 'High/Low' ? p : close
if z.x1.size() > 0
x1 = z.x1.get(0)
y1 = z.y1.get(0)
z.diff.unshift(math.abs(y2 - y1))
line.new(x1, y1, b, y2, color = color.new(color.gray, 0), style =
line.style_dashed)
style = signal == 'Signal' ? l ? label.style_triangleup :
label.style_triangledown : l ? label.style_label_up : label.style_label_down
txt = signal == 'Signal' ? na : str.tostring(y2 - y1, format.mintick) + 'p'
label.new(b, sbt.s, txt, color = c, size = size.small, style = style,
textcolor = chart.bg_color)
z.x1.unshift(b)
z.y1.unshift(y2)
//SuperBollingerTrend Calculation
method SBT(SuperBollingerTrend s, cond, val, col, p, l) =>
s.s := na(bbdn) or na(bbup) ? 0.0 : close > sbt.s ? math.max(sbt.s, bbdn) :
close < sbt.s ? math.min(sbt.s, bbup) : 0.0
if cond
s.s := val
s.c := col
if showZigZag
zz.zigzag(col, p, l)
alerted.Long := l ? true : false
alerted.Short := l ? false : true
alerted.Short
//Run Methods
sbt.SBT(ta.crossover(close, sbt.s), bbdn, color.lime, low, true)
sbt.SBT(ta.crossunder(close, sbt.s), bbup, color.red, high, false)
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
//TP Line
var tp = line.new(na, na, na, na, color = color.lime)
var ltp = label.new(na, na, 'TP', color = color(na), style =
label.style_label_left, textcolor = chart.fg_color, size = size.normal)
dist = Tp == 'Median' ? zz.diff.median() : zz.diff.avg()
if showTP and zz.y1.size() > 0
pos = close > sbt.s ? true : false
x = zz.x1.get(0)
y = pos ? zz.y1.get(0) + dist : zz.y1.get(0) - dist
tp.set_xy1(x, y)
tp.set_xy2(b + 10, y)
ltp.set_xy(b + 10, y)
alerted.LongTp := pos ? high >= y and high[1] < y : false
alerted.ShortTp := pos ? false : low <= y and low[1] > y
alerted.ShortTp
//Table
var table tbl = na
if barstate.islast and showZigZag and showTable
tbl := table.new(position.top_right, 1, 1, chart.bg_color, frame_color =
color.new(color.gray, 50), frame_width = 3, border_width = 1)
tbl.cell(0, 0, Tp == 'Median' ? 'Median ZigZag Distance: ' + str.tostring(dist,
format.mintick) + 'p' : 'Avg ZigZag Distance: ' + str.tostring(dist,
format.mintick) + 'p', text_color = chart.fg_color)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
//~~ Alerts {
alertcondition(alerted.Long, 'Long Alert', 'Long Signal')
alertcondition(alerted.Short, 'Short Alert', 'Short Signal')
alertcondition(alerted.LongTp, 'Long TP Alert', 'Long TP')
alertcondition(alerted.ShortTp, 'Short TP Alert', 'Short TP')
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// Delta calculations
uptop = high - close
upbot = open - low
dntop = high - open
dnbot = close - low
// Identify outliers
huntingup = pos_delta >= wickdevup
huntingdn = neg_delta <= wickdevdn
// Alert conditions
alertcondition(huntingup, title = 'Buy Pressure Alert', message = 'Buy pressure
detected!')
alertcondition(huntingdn, title = 'Sell Pressure Alert', message = 'Sell pressure
detected!')
// End of script.
// END