Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //@version=2
  2. // Modified from magic moving averages
  3. // Right click on the candles and click send to front for your viewing pleasure
  4.  
  5. study(title="Moving Averages", shorttitle='MAs', overlay=true)
  6.  
  7. // functions
  8. ave_one = ema(close, 9)
  9. ave_two = ema(close, 20)
  10. ave_three = ema(close, 50)
  11. ave_four = ema(close, 200)
  12.  
  13. MA4 = plot(ave_four, color=red, linewidth=3, title="EMA200")
  14. MA3 = plot(ave_three, color=purple,linewidth=5, title="EMA50")
  15. MA2 = plot(ave_two, color=black,linewidth=5, title="EMA20")
  16. MA1 = plot(ave_one, color=white,linewidth=3, title="EMA9")
  17.  
  18. // Reverse for tether, might flip
  19. reverse = input(false, title='Reverse for Tether', type=bool)
  20.  
  21. cloud_regular() =>
  22. cloud_fill_color = ave_four<=ave_three ? #00ffab : red
  23.  
  24. cloud_reverse() =>
  25. cloud_fill_color = ave_three>=ave_four ? #00ffab : red
  26.  
  27. buy_regular() =>
  28. buy_zone_color = ave_two<=ave_three ? purple : #fef65b
  29.  
  30. buy_reverse() =>
  31. buy_zone_color = ave_two>=ave_three ? purple : #fef65b
  32.  
  33. cloud_fill_color = reverse == false ? cloud_regular() : cloud_reverse()
  34. buy_zone_color = reverse == false ? buy_regular() : buy_reverse()
  35.  
  36. fill(MA3,MA4,color = cloud_fill_color, transp=65)
  37. fill(MA2,MA3,color = buy_zone_color, transp=20)
  38.  
  39. percent_diff() =>
  40. abs(sma(close, 150) - close) / ((sma(close, 150) + close) / 2) * 100
  41.  
  42. madb = percent_diff() >= 21 and close <= ave_three and close <= ave_two and close > ave_one ? true : false
  43.  
  44. // red exclamation =
  45. plotchar(madb, char='!', color=red, location=location.top, size=size.small)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement