a guest
Apr 20th, 2014
10,593
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //
2. // @author LazyBear
3. //
4. // If you use this code in its original/modified form, do drop me a note.
5. //
6. study(title="COG Fibs [LazyBear]", shorttitle="COGFibs_LB", overlay=true)
7. length = input(20, "Period")
8.
9. calc_wima(src, length) =>
10. MA_s=(src + nz(MA_s[1] * (length-1)))/length
11. MA_s
12.
13. calc_ma(s, l) => sma(s,l)
14.
15. //th =iff(close[1] > high,close[1],high)
16. //tl=iff(close[1] < low,close[1],low)
17. //tr = th-tl
18.
19. median=0
20. th=linreg(high, length, median)
21. tl=linreg(low, length, median)
22. tr_c=th-tl
23. tra= calc_wima(tr_c,length)
24.
25. //mp=linreg(ohlc4, length, median)
26. mp=calc_ma( close, length)
27. ub_4p2360 = mp + ( 4.2360 * tra)
28. ub_3p6180=mp + ( 3.6180 * tra)
29. ub_2p6180=mp + ( 2.6180 * tra)
30. ub_1p6180=mp + ( 1.6180 * tra)
31. ub_0p618=mp + ( 0.618 * tra)
32.
33. lb_1p6180=mp - ( 1.6180 * tra)
34. lb_2p6180=mp - ( 2.6180 * tra)
35. lb_3p6180=mp - ( 3.6180 * tra)
36. lb_4p2360=mp - ( 4.2360 * tra)
37. lb_0p618=mp - ( 0.618 * tra)
38.
39. plot(mp, title="Middlepoint", color=green)
40. plot(lb_0p618,title="-0.618", color=teal)
41. plot(ub_0p618,title="+0.618", color=teal)
42. plot(ub_1p6180,title="+1.618", color=red)
43. plot(lb_1p6180,title="-1.618", color=red)
44. plot(ub_2p6180,title="+2.618", color=aqua)
45. plot(lb_2p6180,title="-2.618", color=aqua)
46. plot(ub_3p6180,title="+3.618", color=navy)
47. plot(lb_3p6180,title="-3.618", color=navy)
48. plot(ub_4p2360,title="+4.236", color=maroon)
49. plot(lb_4p2360,title="-4.236", color=maroon)