Skip to content

Instantly share code, notes, and snippets.

@bkawk
Created February 25, 2018 04:20
Show Gist options
  • Save bkawk/c20e9fc233fbd5c0dc11327a252cf8f1 to your computer and use it in GitHub Desktop.
Save bkawk/c20e9fc233fbd5c0dc11327a252cf8f1 to your computer and use it in GitHub Desktop.
GHOST indicator
study(title="GHOST Indicator [@Bkawk]", shorttitle="GHOST Indicator [@bkawk]", overlay=true)
slime = #B7ED0A
blood = #FF4167
inputBigTrend1 = input(850, minval=1, title="EMA1")
inputBigTrend2 = 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")
inputLong = input(3, minval=1, title="LAST CHANCE LONG")
inputShort = input(6, minval=1, title="LAST CHANCE SHORT")
bigTrend1 = ema(close, inputBigTrend1)
bigTrend2 = ema(close, 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-(inputLong*atr(inputShort)),goLong[1]) : hl2-(inputLong*atr(inputShort))
goShort=close[1]<goShort[1]? min(hl2+(inputLong*atr(inputShort)),goShort[1]) : hl2+(inputLong*atr(inputShort))
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