TradingView
kobaltttt
21 sept. 2018 02:29

3/9/27/9 Zero Lag EMA / EMA / Pivots / Dynamic Support (Fixed) 

Description

// Fixed error message "Index should not be negative(-8)"

//
// @Author lonestar108
//
study(title = "3/9/27/9 Zero Lag EMA / EMA / Pivots / Dynamic Support", shorttitle="3/9/27/9 ZLEMA/EMA/Pivots/Support", overlay=true)

src=close
lengths=input(3, title="Short Period Length")
length=input(9, title="Fast Period Length")
length2=input(27, title="Slow Period Length")
plen=input(9, minval=1, title="Pivot Period Length")

// ema, zero lag ema
ema1=ema(src, length)
ema2=ema(ema1, length)
d=ema1-ema2
zlema=ema1+d
ema3=ema(src, length2)

// ema, zero lag ema
ema4=ema(src, length)
ema5=ema(ema4, length)
d2=ema4-ema5
zlema2=ema4+d
ema6=ema(src, length2)

// pivot points
highest_high = highest(high, plen)
highest_dev = dev(highest_high, plen) ? na : highest_high
high_pivot = highest_dev[-plen+1]
high_series = fixnan(high_pivot)
lowest_low = lowest(low, plen)
lowest_dev = dev(lowest_low, plen) ? na : lowest_low
low_pivot = lowest_dev[-plen + 1]
low_series = fixnan(low_pivot)


// Sell Setup
priceflip = barssince(close<close[4])
sellsetup = close>close[4] and priceflip
sell = sellsetup and barssince(priceflip!=9)
sell8 = sellsetup and barssince(priceflip!=8)
sellovershoot = sellsetup and barssince(priceflip!=13)
sellovershoot1 = sellsetup and barssince(priceflip!=14)
sellovershoot2 = sellsetup and barssince(priceflip!=15)
sellovershoot3 = sellsetup and barssince(priceflip!=16)

// Buy setup
priceflip1 = barssince(close>close[4])
buysetup = close<close[4] and priceflip1
buy = buysetup and barssince(priceflip1!=9)
buy8 = buysetup and barssince(priceflip1!=8)
buyovershoot = barssince(priceflip1!=13) and buysetup
buyovershoot1 = barssince(priceflip1!=14) and buysetup
buyovershoot2 = barssince(priceflip1!=15) and buysetup
buyovershoot3 = barssince(priceflip1!=16) and buysetup

// TD lines
val= buy !=sell[9]
TDhigh = valuewhen(val,high[9],0)
val1= sell !=buy[9]
TDlow = valuewhen(val1,low[9],0)

////////////////////////////
// PLOTTING

icolor=rising(zlema,1) ? lime : red

plot(zlema, color=yellow, linewidth=1)
plot(ema3, color=lime, linewidth=1)

plot(high_series, style=circles, color=lime, linewidth=1)
plot(low_series, style=circles, color=red, linewidth=1)

plot(high_pivot + 1, color=red, style=circles, linewidth=3)
plot(low_pivot - 1, color=lime, style=circles, linewidth=3)

plot(cross(zlema, ema3) ? rising(zlema,1) ? low - 1 : high + 1 : na, color=icolor, style=cross, linewidth=2)
plot(cross(zlema2, ema3) ? rising(zlema2,1) ? low - 1.25 : high + 1.25 : na, color=yellow, style=circles, linewidth=2)
plot(cross(zlema2, ema6) ? rising(zlema2,1) ? low - 1.35 : high + 1.35 : na, color=orange, style=circles, linewidth=2)
plot(cross(close, ema3) ? rising(zlema,1) ? low - 1.15 : high + 1.15 : na, color=fuchsia, style=circles, linewidth=2)

plotchar(buy,'9b','9',location.belowbar,color=lime,transp=0)
plotchar(sell,'9s','9',location.abovebar,color=red,transp=0)
plotchar(buy8,'8b','8',location.belowbar,color=lime,transp=0)
plotchar(sell8,'8s','8',location.abovebar,color=red,transp=0)

plot(TDhigh ? TDhigh : na ,style=circles, linewidth=1, color=lime,offset=-9)
plot(TDlow ? TDlow : na ,style=circles, linewidth=1, color=red, offset=-9)

barcolor(sellovershoot? #FF66A3 : sellovershoot1? #FF3385 : sellovershoot2? #FF0066 : sellovershoot3? #CC0052 : buyovershoot? #D6FF5C : buyovershoot1? #D1FF47 : buyovershoot2? #B8E62E : buyovershoot3? #8FB224 : na)

// Uncode for line chart with indicators //
c = sell? #FF0000 : buy? #00FF00 : sellovershoot? #FF66A3 : sellovershoot1? #FF3385 : sellovershoot2? #FF0066 : sellovershoot3? #CC0052 : buyovershoot? #D6FF5C : buyovershoot1? #D1FF47 : buyovershoot2? #B8E62E : buyovershoot3? #8FB224 : #c0c0c0
plot(close, color=c, linewidth=1)
Commentaires
MaximusGains
IVincentVega
@MaximusGains, did you remove it?
MaximusGains
@MaximusGains,
// Sell Setup
priceflip = ta.barssince(close < close[4])
sellsetup = close > close[4] and priceflip
sell = sellsetup and ta.barssince(priceflip != 9)
sell8 = sellsetup and ta.barssince(priceflip != 6)
sellovershoot = sellsetup and ta.barssince(priceflip != 13)
sellovershoot1 = sellsetup and ta.barssince(priceflip != 14)
sellovershoot2 = sellsetup and ta.barssince(priceflip != 15)
sellovershoot3 = sellsetup and ta.barssince(priceflip != 16)

// Buy setup
priceflip1 = ta.barssince(close > close[4])
buysetup = close < close[4] and priceflip1
buy = buysetup and ta.barssince(priceflip1 != 9)
buy8 = buysetup and ta.barssince(priceflip1 != 6)
buyovershoot = ta.barssince(priceflip1 != 13) and buysetup
buyovershoot1 = ta.barssince(priceflip1 != 14) and buysetup
buyovershoot2 = ta.barssince(priceflip1 != 15) and buysetup
buyovershoot3 = ta.barssince(priceflip1 != 16) and buysetup

// TD lines
val = buy != sell[9]
TDhigh = ta.valuewhen(val, high[9], 0)
val1 = sell != buy[9]
TDlow = ta.valuewhen(val1, low[9], 0)

////////////////////////////
// PLOTTING

icolor = ta.rising(zlema, 1) ? color.lime : color.red

plot(zlema, color=color.new(color.yellow, 0), linewidth=1)
plot(ema3, color=color.new(color.lime, 0), linewidth=1)

plot(high_series, style=plot.style_circles, color=color.new(color.lime, 0), linewidth=2)
plot(low_series, style=plot.style_circles, color=color.new(color.red, 0), linewidth=2)

plot(high_pivot + 1, color=color.new(color.red, 0), style=plot.style_circles, linewidth=7, offset=-(plen + plen))
plot(low_pivot - 1, color=color.new(color.lime, 0), style=plot.style_circles, linewidth=7, offset=-(plen + plen))

rising_1 = ta.rising(zlema, 1)
plot(ta.cross(zlema, ema3) ? rising_1 ? low - 1 : high + 1 : na, color=icolor, style=plot.style_cross, linewidth=2)
rising_2 = ta.rising(zlema2, 1)
plot(ta.cross(zlema2, ema3) ? rising_2 ? low - 1.25 : high + 1.25 : na, color=color.new(color.yellow, 0), style=plot.style_circles, linewidth=4)
rising_3 = ta.rising(zlema2, 1)
plot(ta.cross(zlema2, ema6) ? rising_3 ? low - 1.35 : high + 1.35 : na, color=color.new(color.orange, 0), style=plot.style_circles, linewidth=4)
rising_4 = ta.rising(zlema, 1)
plot(ta.cross(close, ema3) ? rising_4 ? low - 1.15 : high + 1.15 : na, color=color.new(color.fuchsia, 0), style=plot.style_cross, linewidth=4)

plotchar(buy, '9b', '9', location.belowbar, color=color.new(color.lime, 0))
plotchar(sell, '9s', '⛔', location.abovebar, color=color.new(color.red, 0))
plotchar(buy8, '6b', '🔎', location.belowbar, color=color.new(color.lime, 0))
plotchar(sell8, '6s', '6', location.abovebar, color=color.new(color.red, 0))

plot(TDhigh ? TDhigh : na, style=plot.style_cross, linewidth=1, color=color.new(color.lime, 0), offset=-9)
plot(TDlow ? TDlow : na, style=plot.style_cross, linewidth=1, color=color.new(color.red, 0), offset=-9)

barcolor(sellovershoot ? #FF66A3 : sellovershoot1 ? #FF3385 : sellovershoot2 ? #FF0066 : sellovershoot3 ? #CC0052 : buyovershoot ? #D6FF5C : buyoversho
MaximusGains
@MaximusGains, barcolor(sellovershoot ? #FF66A3 : sellovershoot1 ? #FF3385 : sellovershoot2 ? #FF0066 : sellovershoot3 ? #CC0052 : buyovershoot ? #D6FF5C : buyovershoot1 ? #D1FF47 : buyovershoot2 ? #B8E62E : buyovershoot3 ? #8FB224 : na)

// Uncode for line chart with indicators //
c = sell ? #FF0000 : buy ? #00FF00 : sellovershoot ? #FF66A3 : sellovershoot1 ? #FF3385 : sellovershoot2 ? #FF0066 : sellovershoot3 ? #CC0052 : buyovershoot ? #D6FF5C : buyovershoot1 ? #D1FF47 : buyovershoot2 ? #B8E62E : buyovershoot3 ? #8FB224 : #c0c0c0
plot(close, color=c, linewidth=1)
MaximusGains
Thanks for sharing
mrgr888n
the author of it visited TV half of a year ago.. Maybe U will further develop this?)) I love TD part of it. Very useful.
kobaltttt
@mrgr888n, What did you have in mind? I personally don't often use it, (script hoarder here and many alternatives:

Like this idea by glaz: //Glaz.

study(title="Glaz Daily Pivot Line", shorttitle="Glaz DP", overlay=true)
TradingHours = input(24)
min = TradingHours * 60
pivot = (high + low + close ) / 3.0
dtime = security(tickerid, 'D', pivot )
offs = isintraday ? round(min / interval) : 1
plot(offset(dtime,offs), color=green,linewidth=3)

Also these indicators tradingview.com/script/2rZDPyaC-Leledc-Exhaustion-Bar/

One almost can't stop collecting, if i need to unwind:.. I scroll Ricardo Santos scripts, it's a script hoarders mantra... yo_Op
Plus