EDIT 3
EDIT 3
direction = na
superTrend = na
prevSuperTrend = superTrend[1]
if prevSuperTrend == prevUpperBand
direction := close > upperBand ? 1 : -1
else
direction := close < lowerBand ? -1 : 1
direction = na
stop = na
prevSuperTrend = stop[1]
if prevSuperTrend == prevUpperBand
direction := buy ? 1 : -1
else
direction := sell ? -1 : 1
for y = 0 to array.size(pivotvals) - 1 by 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= lo ? hi - cpp : cpp - lo
if ret > 0
for i = array.size(sr_strength) - 1 to 0 by 1
if strength <= array.get(sr_strength, i)
break
ret := i // Update return value
// Get components
rsi = ta.rsi(close, 14)
vosc = ta.obv - ta.ema(ta.obv, 20)
bs = ta.ema(nz(math.abs((open - close) / (high - low) * 100)), 3)
ema = ta.ema(close, 200)
emaBull = close > ema
equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes()
higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes()
too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and
str.tonumber(res) < 10)
securityNoRep(sym, res, src) =>
var bool bull = na // Use `var` to retain value across bars
if zz_[x]
if na(pp)
pp := zz_[x]
else
if (dir[x] == 1 and zz_[x] > pp)
pp := zz_[x]
if (dir[x] == -1 and zz_[x] < pp)
pp := zz_[x]
if pp != pp[1]
if consCnt > lenCons
if pp > condHi
breakUp := true
if pp < condLo
breakDn := true
if array.size(pvh1_price) > 2
temp_pv_0 = array.get(pvh1_price, 0)
temp_pv_1 = array.get(pvh1_price, 1)
temp_pv_2 = array.get(pvh1_price, 2)
if pvl
array.pop(pvl1_price)
array.pop(pvl1_time)
array.unshift(pvl1_price, pv1_low)
array.unshift(pvl1_time, pv1_time)
if array.size(pvl1_price) > 2
temp_pv_0 := array.get(pvl1_price, 0)
temp_pv_1 := array.get(pvl1_price, 1)
temp_pv_2 := array.get(pvl1_price, 2)
for i = 0 to array.size(pvh1_time) - 1 by 1
temp_htcmrll_time := array.get(pvh1_time, i) // Use ':=' for
reassignment
else
box.set_bgcolor(tbox, color.rgb(192, 192, 192, 80))
box.set_border_color(tbox, color.rgb(192, 192, 192, 80))
if trigger_high > top and box.get_left(tbox) + box_fill_delay <
bar_index
if box_stop_sv
box.set_right(tbox, bar_index)
box.set_extend(tbox, extend.none)
array.remove(short_boxes, i)
if array.size(long_boxes) > 0
for i = array.size(long_boxes) - 1 to 0 by 1
lbox = array.get(long_boxes, i)
top = box.get_top(lbox)
bottom = box.get_bottom(lbox)
if trigger_low < top and box.get_left(lbox) + box_test_delay <
bar_index and box_test_sv
if box_hide_gray
box.set_bgcolor(lbox, #00000000)
box.set_border_color(lbox, #00000000)
else
box.set_bgcolor(lbox, color.rgb(192, 192, 192, 80))
box.set_border_color(lbox, color.rgb(192, 192, 192, 80))
if trigger_low < bottom and box.get_left(lbox) + box_fill_delay <
bar_index
if box_stop_sv
box.set_right(lbox, bar_index)
box.set_extend(lbox, extend.none)
array.remove(long_boxes, i)
if barstate.islast and eliteVP
for i = 0 to levelNum - 1
histogramLow = rangeLow + histogramHeight * i
histogramHigh = rangeLow + histogramHeight * (i + 1)
array.set(histogramLowList, i, histogramLow)
array.set(histogramHighList, i, histogramHigh)
for i = 0 to lookback - 1
currentBarHeight = high[i] - low[i]
currentBuyVolume = high[i] == low[i] ? 0 : volume[i] * (close[i] - low [i])
/ currentBarHeight
currentSellVolume = high[i] == low[i] ? 0 : volume[i] * (high [i] -
close[i]) / currentBarHeight
for j = 0 to levelNum - 1
histogramLow = array.get(histogramLowList, j)
histogramHigh = array.get(histogramHighList, j)
target = math.max(histogramHigh, high[i]) - math.min(histogramLow,
low[i]) - (math.max(histogramHigh, high[i]) - math.min(histogramHigh, high[i])) -
(math.max(histogramLow, low[i]) - math.min(histogramLow, low[i]))
histogramVolumePercentage = target / currentBarHeight
histogramBuyVolume = array.get(histogramBuyVolumeList, j)
histogramSellVolume = array.get(histogramSellVolumeList, j)
if histogramVolumePercentage > 0
array.set(histogramBuyVolumeList, j, histogramBuyVolume +
currentBuyVolume * histogramVolumePercentage)
array.set(histogramSellVolumeList, j, histogramSellVolume +
currentSellVolume * histogramVolumePercentage)
highestHistogramVolume = 0.0
for i = 0 to levelNum - 1
histogramBuyVolume = array.get(histogramBuyVolumeList, i)
histogramSellVolume = array.get(histogramSellVolumeList, i)
histogramVolume = histogramBuyVolume + histogramSellVolume
highestHistogramVolume := math.max(highestHistogramVolume, histogramVolume)
highestHistogramVolume
for i = 0 to levelNum - 1
histogramLow = array.get(histogramLowList, i)
histogramHigh = array.get(histogramHighList, i)
histogramBuyVolume = array.get(histogramBuyVolumeList, i)
histogramSellVolume = array.get(histogramSellVolumeList, i)
histogramVolume = histogramBuyVolume + histogramSellVolume
histogramWidth = levelWidth * histogramVolume / highestHistogramVolume
histogramBuyWidth = math.floor(histogramWidth * histogramBuyVolume /
histogramVolume)
histogramSellWidth = math.floor(histogramWidth * histogramSellVolume /
histogramVolume)
array.set(buyBars , i, box.new(bar_index + offset + levelWidth - 1 -
histogramBuyWidth, histogramHigh, bar_index + offset + levelWidth - 1,
histogramLow, colorBorderVP, bgcolor=colorBuyVP ))
array.set(sellBars, i, box.new(bar_index + offset + levelWidth - 1 -
histogramBuyWidth, histogramHigh, bar_index + offset + levelWidth - 1 -
histogramBuyWidth - histogramSellWidth, histogramLow, colorBorderVP,
bgcolor=colorSellVP))
barcolor(momentumCandles and candlesMom() ? color.purple : candleColors ? (strategy
== "Trend scalper" ? colorBar : na(countBull) and na(countBear) ? color.gray :
trigger ? green : red) : na, editable=false)
fill(plot(showTrendCloud and periodTrendCloud == "New" ? ema150 : na, "", na,
editable=false), plot(showTrendCloud and periodTrendCloud == "New" ? ema250 : na,
"", na, editable=false), ema150 > ema250 ? color.new(color.green, 70) : ema150 <
ema250 ? color.new(color.red, 70) : na)
plot(enableTrailingSL and trigger and nz(ta.barssince(low < trailingStop),
bar_index) > countBull ? trailingStop : na, "", green, 1, plot.style_linebr,
editable=false)
plot(enableTrailingSL and not trigger and nz(ta.barssince(high > trailingStop),
bar_index) > countBear ? trailingStop : na, "", red , 1, plot.style_linebr,
editable=false)
p0 = plot(avgOC, "", na , editable=false)
p1 = plot(ema5 , "", colorEma5 , editable=false)
p2 = plot(ema9 , "", colorEma9 , editable=false)
p3 = plot(ema21, "", colorEma21, editable=false)
fill(p0, p1, fillEma5 )
fill(p1, p2, fillEma9 )
fill(p2, p3, fillEma21)
fill(plot(showTrendCloud and periodTrendCloud != "New" and trendcloud != 0 and
close > trendcloud ? trendcloud : na, "", color.green, 1, plot.style_linebr,
editable=false), p0, color.new(color.green, 90))
fill(plot(showTrendCloud and periodTrendCloud != "New" and trendcloud != 0 and
close < trendcloud ? trendcloud : na, "", color.red , 1, plot.style_linebr,
editable=false), p0, color.new(color.red , 90))
fill(plot(hma, "", hma > hma[2] ? green : hma < hma[2] ? red : na, editable=false),
plot(hma[2], "", hma > hma[2] ? green : hma < hma[2] ? red : na, editable=false),
hma > hma[2] ? green : hma < hma[2] ? red : na)
// Alerts
f_crossed_over() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by
1
float mid = math.round_to_mintick((array.get(sr_up_level, x) +
array.get(sr_dn_level, x)) / 2)
if close[1] <= mid and close > mid
ret := true
ret
ret
f_crossed_under() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by
1
float mid = math.round_to_mintick((array.get(sr_up_level, x) +
array.get(sr_dn_level, x)) / 2)
if close[1] >= mid and close < mid
ret := true
ret
ret
f_sl_crossed() =>
ret = false
stop = enableTrailingSL ? 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 <= smartFilter) or (bear and close >= smartFilter)
alert02 = bull or bear
alert03 = (bull and close > smartFilter) or (bear and close < smartFilter)
alert04 = bull and close <= smartFilter
alert05 = f_crossed_over()
alert06 = bear and close >= smartFilter
alert07 = bull and close > smartFilter
alert08 = bear and close < smartFilter
alert09 = f_sl_crossed()
alert10 = f_crossed_under()
alert11 = f_tp_crossed(tp1_y)
alert12 = f_tp_crossed(tp2_y)
alert13 = f_tp_crossed(tp3_y)
alert14 = periodTrendCloud == "New" ? ta.crossunder(ema150, ema250) : (close <
trendcloud) and (close > trendcloud)[1]
alert15 = periodTrendCloud == "New" ? 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)
alertcondition(alert01, "Any Signal Buy / sell", "Buy or Sell")
alertcondition(alert02, "Any signal Buy/Smart Buy or Sell/Smart Sell", "Buy/Smart
Buy or Sell/Smart Sell")
alertcondition(alert03, "Any signal Smart Buy / Smart Sell", "Smart Buy or Smart
Sell")
alertcondition(alert04, "Buy alert", "Buy")
alertcondition(alert05, "Resistance Broken", "Resistance Broken")
alertcondition(alert06, "Sell alert", "Sell")
alertcondition(alert07, "Smart Buy", "Smart Buy")
alertcondition(alert08, "Smart Sell", "Smart Sell")
alertcondition(alert09, "Stop loss", "Stop loss")
alertcondition(alert10, "Support Broken", "Support Broken")
alertcondition(alert11, "Target 1", "Target 1")
alertcondition(alert12, "Target 2", "Target 2")
alertcondition(alert13, "Target 3", "Target 3")
alertcondition(alert14, "Trend cloud Bearish Alert", "Trend cloud Bearish")
alertcondition(alert15, "Trend cloud Bullish Alert", "Trend cloud Bullish")