I downloaded the following code - which I don’t know how to code - and when I tried to compile it I received a number of single quote missing errors.
I am not asking to be spoon fed but if someone could point me in the direction of a website or thread that would be great!
TX,
KC
//@version=4
// hull trend taken from Hull Trend — Indicator by jaggedsoft — TradingView
study(“Hull Trend MTF”, shorttitle=“HMA Trend MTF”,overlay=true)
tf = input(“240”, title = “Timeframe”, type = input.resolution, options = [“1”, “5”, “15”, “30”, “60”,“120”, “240”,“360”,“720”, “D”, “W”])
src = input(hl2)
length = input(24, title = “Period”, type = input.integer)
shift = input(0, title = “Shift”, type = input.integer)
showcross = input(true, “Show cross over/under”)
hma(_src, _length)=>
wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length)))
hma3(_src, _length)=>
p = length/2
wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p)
a = security(syminfo.tickerid, tf, hma(src, length)[shift])
b =security(syminfo.tickerid, tf, hma3(src, length)[shift])
c = b > a ? color.lime : color.red
p1 = plot(a,color=c,linewidth=1,transp=75)
p2 = plot(b,color=c,linewidth=1,transp=75)
fill(p1,p2,color=c,transp=55)
crossdn = a > b and a[1] < b[1]
crossup = b > a and b[1] < a[1]
plotshape(showcross and crossdn ? a : na, location=location.absolute, style=shape.labeldown, color=color.red, size=size.tiny, text=“Sell”, textcolor=color.white, transp=0, offset=0)
plotshape(showcross and crossup ? a : na, location=location.absolute, style=shape.labelup, color=color.green, size=size.tiny, text=“Buy”, textcolor=color.white, transp=0, offset=0)
alertcondition(showcross and crossdn ? a : na, title = ‘hma long’, message = 'hma: long ')
alertcondition(showcross and crossup ? a : na, title = ‘hma short’, message = 'hma: short ')
//
src1 = input(close)
len = input(30)
len2=input(100)
calcSlope(src1, len2) =>
if not barstate.islast
[float(na), float(na), float(na)]
else
sumX = 0.0
sumY = 0.0
sumXSqr = 0.0
sumXY = 0.0
for i = 0 to len2 - 1
val = src1[i]
per = i + 1.0
sumX := sumX + per
sumY := sumY + val
sumXSqr := sumXSqr + per * per
sumXY := sumXY + val * per
slope = (len2 * sumXY - sumX * sumY) / (len2 * sumXSqr - sumX * sumX)
average = sumY / len2
intercept = average - slope * sumX / len2 + slope
[slope, average, intercept]
[s, a1, i] = calcSlope(src1, len2)
startPrice = i + s * (len2 - 1)
endPrice = i
var line baseLine = na
if na(baseLine)
baseLine := line.new(bar_index - len2 + 1, startPrice, bar_index, endPrice, width=4, extend=extend.right)
else
line.set_xy1(baseLine, bar_index - len2 + 1, startPrice)
line.set_xy2(baseLine, bar_index, endPrice)
na //
//
// Draw channel.
channelType = input(defval=“Donchian”, title=“Channel Type”, options=[“NONE”, “Donchian”, “Bollinger”, “Envelope”])
channelLen = input(14, minval=1, title=“Channel Length”)
envPer = input(4, title=“Envelope %”, type=input.float, minval=0) / 100
getChannels(src, len) =>
if channelType == "Bollinger"
ma = ema(src, len)
dev = stdev(src, len)
bbUp = ma + 2dev
bbDown = ma - 2dev
[bbUp, bbDown]
else
if channelType == "Donchian"
donUp = highest(high[1], len)
donDown = lowest(low[1], len)
[donUp, donDown]
else
if channelType == "Envelope"
ma = ema(src, len)
envUp = ma * (1 + envPer)
envDown = ma * (1 - envPer)
[envUp, envDown]
else
[na, na]
[upperchannel, lowerchannel] = getChannels(src, len)
u = plot(upperchannel, linewidth=1, color=color.gray, title=“Upper”)
plot(avg(upperchannel, lowerchannel), linewidth=1, color=color.maroon, title=“Middle”)
l = plot(lowerchannel, linewidth=1, color=color.gray, title=“Lower”)