Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. //@version=2
  2. study(title="MACD Histogram Direction Evaluator Alerts")
  3. //src = security(tickerid, "1W", close)
  4. src = close
  5. fastLength = input(20, minval=1)
  6. slowLength=input(52,minval=1)
  7. signalLength=input(9,minval=1)
  8. fastMA = ema(src, fastLength)
  9. slowMA = ema(src, slowLength)
  10. macd = fastMA - slowMA
  11. signal = sma(macd, signalLength)
  12. hist = macd - signal
  13. pos_hist = max(0, hist)
  14. neg_hist = min(0, hist)
  15. plot(pos_hist, color=green, style=histogram, linewidth=2, title='')
  16. plot(neg_hist, color=red, style=histogram, linewidth=2, title='')
  17. oscMins= neg_hist > neg_hist[1] and neg_hist[1] < neg_hist[2] // this line identifies bottoms
  18. oscMax = pos_hist < pos_hist[1] and pos_hist[1] > pos_hist[2] // this line identifies tops
  19. plot(oscMax ? hist : na, title="Top", style=circles, linewidth=2, color=maroon)
  20. plot(oscMins ? hist : na, title="Bottom", style=circles, linewidth=2, color=green)
  21.  
  22. // Only trade in the direction of the overall trend. IMPORTANT! If uptrend is true then it's an upward trend.
  23. uptrend = if hist > 0
  24. true
  25. else
  26. false
  27. //plot(uptrend)
  28.  
  29. //plot(macd, color=teal)
  30. //plot(signal, color=orange)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement