SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=3
  2. study(title="GOD MACD", shorttitle="GOD MACD", overlay=true)
  3.  
  4. fast = input(12, minval=1, title="Fast MA")
  5. slow = input(26, minval=2, title="Slow MA")
  6.  
  7. signalLength = input(9, minval=1, title="Signal MA")
  8.  
  9. src = input(close, title="Source")
  10.  
  11. maType = input(title="MACD Type", defval="EMA", options=["EMA", "SMA", "VWMA"])
  12. signalType = input(title="Signal Type", defval="EMA", options=["EMA", "SMA", "VWMA"])
  13.  
  14.  
  15. ma(maType, src, length) =>
  16.     if maType =="SMA"
  17.         sma(src, length)
  18.     else
  19.         if maType == "EMA"
  20.             ema(src, length)
  21.         else
  22.             if maType == "VWMA"
  23.                 vwma(src, length)
  24.             else
  25.                 src
  26.  
  27. bigmac = ma(maType, src, fast) - ma(maType, src, slow)
  28. signal = ma(signalType, bigmac, signalLength)
  29.  
  30. plot1Color = bigmac > signal ? #80DEEA : #F06292
  31.  
  32. macdPlot = plot (bigmac, color=plot1Color, transp=0, title="MACD")
  33. signalPlot = plot (signal, color=plot1Color, transp=0, title="Signal")
  34.  
  35. fill(macdPlot, signalPlot, color=plot1Color, transp=50)
  36.  
  37. hist = bigmac - signal
  38.  
  39. color_grow_above = #4DB6AC
  40. color_grow_below = #00796B
  41. color_fall_above = #EF9A9A
  42. color_fall_below = #D32F2F
  43.  
  44. plot(hist, title="Histogram", style=columns, color=(hist >= 0 ? (hist[1] < hist ? color_grow_above : color_fall_above) : (hist[1] < hist ? color_grow_below : color_fall_below) ), transp = 25)
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. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top