• API
• FAQ
• Tools
• Archive
daily pastebin goal
41%
SHARE
TWEET

# TTM squeeze clone [LazyBear]

a guest Sep 29th, 2014 25,738 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //
2. // @author LazyBear
3. // List of all my indicators:
5. // v2 - fixed a typo, where BB multipler was always stuck at 1.5. [Thanks @ucsgears]
6. //
7. study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator [LazyBear]", overlay=false)
8.
9. length = input(20, title="BB Length")
10. mult = input(2.0,title="BB MultFactor")
11. lengthKC=input(20, title="KC Length")
12. multKC = input(1.5, title="KC MultFactor")
13.
14. useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)
15.
16. // Calculate BB
17. source = close
18. basis = sma(source, length)
19. dev = mult * stdev(source, length)
20. upperBB = basis + dev
21. lowerBB = basis - dev
22.
23. // Calculate KC
24. ma = sma(source, lengthKC)
25. range = useTrueRange ? tr : (high - low)
26. rangema = sma(range, lengthKC)
27. upperKC = ma + rangema * multKC
28. lowerKC = ma - rangema * multKC
29.
30. sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
31. sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
32. noSqz  = (sqzOn == false) and (sqzOff == false)
33.
34. val = linreg(source  -  avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),
35.             lengthKC,0)
36.
37. bcolor = iff( val > 0,
38.             iff( val > nz(val[1]), lime, green),
39.             iff( val < nz(val[1]), red, maroon))
40. scolor = noSqz ? blue : sqzOn ? black : gray
41. plot(val, color=bcolor, style=histogram, linewidth=4)
42. plot(0, color=scolor, style=cross, linewidth=2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top