xmd79

Multi Timeframe MACD

May 22nd, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. study("Multi Timeframe MACD", shorttitle="MTF_MACD")
  2. fast = input(12, title="Fastline", type=integer)
  3. slow = input(26, title="Slowline", type=integer)
  4. smoothing = input(9, title="Smoothing", type=integer)
  5. src = input(close, title="Source", type=source)
  6. show5m = input(true, title="show 5m", type=bool)
  7. show15m = input(true, title="show 15m", type=bool)
  8. show30m = input(true, title="show 30m", type=bool)
  9. show1h = input(true, title="show 1h", type=bool)
  10. show2h = input(true, title="show 2h", type=bool)
  11. show4h = input(true, title="show 4h", type=bool)
  12.  
  13. fastMACurrent = ema(src, fast)
  14. slowMACurrent = ema(src, slow)
  15. macdCurrent = fastMACurrent - slowMACurrent
  16.  
  17. fastMA5m = security(ticker,"5",ema(src, fast))
  18. slowMA5m = security(ticker,"5",ema(src, slow))
  19. macd5m = sma(fastMA5m - slowMA5m,smoothing)
  20.  
  21. fastMA15m = security(ticker,"15",ema(src, fast))
  22. slowMA15m = security(ticker,"15",ema(src, slow))
  23. macd15m = sma(fastMA15m - slowMA15m,smoothing*2)
  24.  
  25. fastMA30m = security(ticker,"30",ema(src, fast))
  26. slowMA30m = security(ticker,"30",ema(src, slow))
  27. macd30m = sma(fastMA30m - slowMA30m,smoothing*4)
  28.  
  29. fastMA1h = security(ticker,"60",ema(src, fast))
  30. slowMA1h = security(ticker,"60",ema(src, slow))
  31. macd1h = sma(fastMA1h - slowMA1h,smoothing*6)
  32.  
  33. fastMA2h = security(ticker,"120",ema(src, fast))
  34. slowMA2h = security(ticker,"120",ema(src, slow))
  35. macd2h = sma(fastMA2h - slowMA2h,smoothing*12)
  36.  
  37. fastMA4h = security(ticker,"240",ema(src, fast))
  38. slowMA4h = security(ticker,"240",ema(src, slow))
  39. macd4h = sma(fastMA4h - slowMA4h,smoothing*24)
  40.  
  41. plot(macdCurrent, color=blue, title="fl current")
  42.  
  43.  
  44. plot(show5m ? macd5m : na, color=interval < 5 and not isdaily and not isweekly and not ismonthly ? #aaaaaa : na, title="MACD 5m")
  45. plot(show15m ? macd15m : na, color=interval < 15 and not isdaily and not isweekly and not ismonthly ? #999999 : na, title="MACD 15m")
  46. plot(show30m ? macd30m : na, color=interval < 30 and not isdaily and not isweekly and not ismonthly ? #888888 : na, title="MACD 30m")
  47. plot(show1h ? macd1h : na, color=interval < 60 and not isdaily and not isweekly and not ismonthly ? #777777 : na, title="MACD 1h")
  48. plot(show2h ? macd2h : na, color=interval < 120 and not isdaily and not isweekly and not ismonthly ? #666666 : na, title="MACD 2h")
  49. plot(show4h ? macd4h : na, color=interval < 240 and not isdaily and not isweekly and not ismonthly ? #555555 : na, title="MACD 4h")
  50. //plot(show1D ? macd1D : na, color=not isdaily and not isweekly and not ismonthly ? #444444 : na, title="MACD 1D")
Advertisement
Add Comment
Please, Sign In to add comment