Skip to content

Instantly share code, notes, and snippets.

@bkawk
Created March 3, 2018 03:14
Show Gist options
  • Save bkawk/f7d9bb9ae725a0808793277bc2c6bbc8 to your computer and use it in GitHub Desktop.
Save bkawk/f7d9bb9ae725a0808793277bc2c6bbc8 to your computer and use it in GitHub Desktop.
Locked Ghost Indicator
// =====================================
// GHOST Indicator v0.0.1
// @author @bkawk
// =====================================
study(title="GHOST Indicator [@Bkawk]", shorttitle="GHOST Indicator [@bkawk]", overlay=true)
slime = #B7ED0A
blood = #FF4167
ema_1h(length) => security(tickerid, "60", ema(close, length))
inputBigTrend1 = ema_1h(input(850, minval=1, title="EMA1"))
inputBigTrend2 = ema_1h(input(200, minval=1, title="EMA2"))
inputEma = input(50, minval=1, title="EMA3")
inputConversion = input(9, minval=1, title="Conversion")
inputBase = input(26, minval=1, title="Base")
inputTinyTrend1 = input(8, minval=1, title="EMA4")
inputTinyTrend2 = input(41, minval=1, title="EMA5")
bigTrend1 = inputBigTrend1
bigTrend2 = inputBigTrend2
tinyTrend1 = ema(close, inputTinyTrend1)
tinyTrend2 = ema(close, inputTinyTrend2)
averageLength(len) => avg(lowest(len), highest(len))
smallTrendCalc1 = averageLength(inputConversion)
smallTrendCalc2 = averageLength(inputBase)
smallTrendMiddle = ema(close, inputEma)
goLong=close[1]>goLong[1]? max(hl2-(3*atr(2)),goLong[1]) : hl2-(3*atr(2))
goShort=close[1]<goShort[1]? min(hl2+(3*atr(2)),goShort[1]) : hl2+(3*atr(2))
go = close > goShort[1] ? 1: close< goLong[1]? -1: nz(go[1],1)
bigTrendLine1 = plot(bigTrend1, style = cross, color = black, transp = 100)
tinyTrendLine1 = plot(tinyTrend1, style = cross, color = black, transp = 100)
smallTrendLine1 = plot(smallTrendCalc1, style = cross, color = black, transp = 100)
bigAbove = plot(bigTrend2 >= bigTrend1 ? bigTrend2 : na, color = black, transp = 100)
bigBelow = plot(bigTrend2 < bigTrend1 ? bigTrend2 : na, color = black, transp = 100)
tinyAbove = plot(tinyTrend2 >= tinyTrend1 ? tinyTrend2 : na, color = black, transp = 100)
tinyBelow = plot(tinyTrend2 < tinyTrend1 ? tinyTrend2 : na, color = black, transp = 100)
smallAbove = plot(smallTrendCalc2 >= smallTrendCalc1 ? smallTrendCalc2 : na, color = black, transp = 100)
smallBelow = plot(smallTrendCalc2 <= smallTrendCalc1 ? smallTrendCalc2 : na, color = black, transp = 100)
plot(smallTrendMiddle, linewidth = 2, color = white)
fill(bigTrendLine1, bigBelow, blood, transp = 90)
fill(bigTrendLine1, bigAbove, slime, transp = 90)
fill(tinyTrendLine1, tinyBelow, slime, transp = 70)
fill(tinyTrendLine1, tinyAbove, blood, transp = 70)
fill(smallTrendLine1, smallBelow, slime, transp = 70)
fill(smallTrendLine1, smallAbove, blood, transp = 70)
plotshape(go == -1 and go[1] == 1 ? go : na, style=shape.labeldown, location=location.abovebar, color=blood)
plotshape(go == 1 and go[1] == -1 ? go : na, style=shape.labelup, location=location.belowbar, color=slime)
plotarrow(go == 1 and go[1] == -1 ? go : na, title="Last chance for a long entry", colorup=slime, maxheight=1000, minheight=980, transp=0)
plotarrow(go == -1 and go[1] == 1 ? go : na, title="Last Chance for a short entry", colordown=blood, maxheight=1000, minheight=980, transp=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment