Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. //Created by ChrisMoody on October 23, 2014 by user request - platinumFX
  2. //Defaults to current timeframe Ability to change to different timeframe, or plot two RSI's on different timeframes.
  3. study(title="CM_Stochastic_MTF", shorttitle="CM_Stoch_MTF")
  4. len = input(14, minval=1, title="Length for Main Stochastic")
  5. smoothK = input(3, minval=1, title="SmoothK for Main Stochastic")
  6. smoothD = input(3, minval=1, title="SmoothD for Main Stochastic")
  7. upLine = input(92, minval=50, maxval=100, title="Upper Line Value?")
  8. lowLine = input(12, minval=8, maxval=50, title="Lower Line Value?")
  9. sml = input(true, title="Show Mid Line?")
  10. sbh = input(false, title="Show Back Ground Highlights When Stoch is Above/Below High/Low Lines?")
  11. sch = input(true, title="Show Back Ground Highlights When Stoch Cross - Strict Criteria - K Greater/LesThan High/Low Line - Crosses D ?")
  12. sl = input(true, title="Show 'B' and 'S' Letters When Stoch Crosses High/Low Line & D?")
  13. sac = input(false, title="Show Back Ground Highlights When Stoch Cross - Any Cross?")
  14. sacl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses - Any Cross?")
  15. useCurrentRes = input(true, title="Use Current Chart Resolution?")
  16. resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60")
  17. ssStoch = input(false, title="Show 2nd Stoch?")
  18. resCustom2 = input(title="Use 2nd Stoch? Check Box Above", type=resolution, defval="D")
  19. useCurrentRes2 = input(false, title="Use 2nd Stoch Plot On Samet Timeframe?")
  20. len2 = input(14, minval=1, title="2nd Stoch Length")
  21. smoothK2 = input(3, minval=1, title="SmoothK for 2nd Stoch")
  22. smoothD2 = input(3, minval=1, title="SmoothD for 2nd Stoch")
  23. //Resolutioon for MTF
  24. res = useCurrentRes ? period : resCustom
  25. res2 = useCurrentRes2 ? period : resCustom2
  26. //Stoch formula
  27. k = sma(stoch(close, high, low, len), smoothK)
  28. d = sma(k, smoothD)
  29. outK = security(tickerid, res, k)
  30. outD = security(tickerid, res, d)
  31. //Optional 2nd Stoch for additional plot
  32. k2 = sma(stoch(close, high, low, len2), smoothK2)
  33. d2 = sma(k2, smoothD2)
  34. outK2 = security(tickerid, res2, k2)
  35. outD2 = security(tickerid, res2, d2)
  36. //definitions for Cross
  37. aboveLine = outK > upLine ? 1 : 0
  38. belowLine = outK < lowLine ? 1 : 0
  39. crossUp = (outK[1] < outD[1] and outK[1] < lowLine[1]) and (outK > outD) ? 1 : 0
  40. crossDn = (outK[1] > outD[1] and outK[1] > upLine[1]) and (outK < outD) ? 1 : 0
  41. //Definition for Cross that doesn't have to be above or below High and Low line.
  42. crossUpAll = (outK[1] < outD[1] and outK > outD) ? 1 : 0
  43. crossDownAll = (outK[1] > outD[1] and outK < outD) ? 1 : 0
  44. //BackGroound Color Plots
  45. bgcolor(sbh and aboveLine ? red : na, transp=70)
  46. bgcolor(sbh and belowLine ? lime : na, transp=70)
  47. bgcolor(sch and crossUp ? lime : na, transp=40)
  48. bgcolor(sch and crossDn ? red : na, transp=40)
  49. //plots for Cross with no filter
  50. bgcolor(sac and crossUpAll ? lime : na, transp=40)
  51. bgcolor(sac and crossDownAll ? red : na, transp=40)
  52. //Plot main Stochastic
  53. plot(outK, title="Stoch K", style=line, linewidth=3, color=lime)
  54. plot(outD, title="Stoch D", style=line, linewidth=3, color=red)
  55. //Ability to plot 2nd Stoch
  56. plot(ssStoch and outK2 ? outK2 : na, title="2nd Stoch K - Different TimeFrame", style=line, linewidth=3, color=orange)
  57. plot(ssStoch and outD2 ? outD2 : na, title="2nd Stoch D - Different TimeFrame", style=line, linewidth=3, color=yellow)
  58.  
  59. p1 = plot(upLine, title= "Upper Line", style=solid, linewidth=3, color=red)
  60. p2 = plot(lowLine, title= "Lower Line", style=solid, linewidth=3, color=lime)
  61. plot(sml and 50 ? 50 : na, title="Mid Line", style=linebr, linewidth=2, color=gray)
  62. plotchar(sl and crossUp ? crossUp : na, title="Buy Signal Strict Criteria", char='B', location=location.bottom, color=lime, transp=0, offset=0)
  63. plotchar(sl and crossDn ? crossDn : na, title="Sell Signal Strict Criteria", char='S', location=location.top, color=red, transp=0, offset=0)
  64. plotchar(sacl and crossUpAll ? crossUpAll : na, title="Buy Signal Any Cross Up", char='B', location=location.bottom, color=lime, transp=0, offset=0)
  65. plotchar(sacl and crossDownAll ? crossDownAll : na, title="Sell Signal Any Cross Down", char='S', location=location.top, color=red, transp=0, offset=0)
  66. fill(p1, p2, color=silver, transp=70)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement