Guest User

Untitled

a guest
Dec 30th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. study(title="2020_DL_1_JUL", shorttitle="2020_DL_1_JUL_MADCC-CMU2")
  2. source = close
  3. useCurrentRes = input(true, title="Use Current Chart Resolution?")
  4. resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60")
  5. smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
  6. sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
  7. sh = input(true, title="Show Histogram?")
  8. macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
  9. hist_colorChange = input(true,title="MacD Histogram 4 Colors?")
  10.  
  11. res = useCurrentRes ? period : resCustom
  12.  
  13. fastLength = input(12, minval=1), slowLength=input(26,minval=1)
  14. signalLength=input(9,minval=1)
  15.  
  16. fastMA = ema(source, fastLength)
  17. slowMA = ema(source, slowLength)
  18.  
  19. macd = fastMA - slowMA
  20. signal = sma(macd, signalLength)
  21. hist = macd - signal
  22.  
  23. outMacD = security(tickerid, res, macd)
  24. outSignal = security(tickerid, res, signal)
  25. outHist = security(tickerid, res, hist)
  26.  
  27. histA_IsUp = outHist > outHist[1] and outHist > 0
  28. histA_IsDown = outHist < outHist[1] and outHist > 0
  29. histB_IsDown = outHist < outHist[1] and outHist <= 0
  30. histB_IsUp = outHist > outHist[1] and outHist <= 0
  31.  
  32. //MacD Color Definitions
  33. macd_IsAbove = outMacD >= outSignal
  34. macd_IsBelow = outMacD < outSignal
  35.  
  36. plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray
  37. macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
  38. signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime
  39.  
  40. circleYPosition = outSignal
  41.  
  42. plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
  43. plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2)
  44. plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram, linewidth=4)
  45. plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=circles, linewidth=4, color=macd_color)
  46. hline(0, '0 Line', linestyle=solid, linewidth=2, color=white)
Advertisement
Add Comment
Please, Sign In to add comment