xmd79

[blackcat] L2 Reversal Labels

Jan 14th, 2022
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. // ____ __ ___ ________ ___________ ___________ __ ____ ___
  2. // / __ )/ / / | / ____/ //_/ ____/ |/_ __< / // / / __ |__ \
  3. // / __ / / / /| |/ / / ,< / / / /| | / / / / // /_/ / / __/ /
  4. // / /_/ / /___/ ___ / /___/ /| / /___/ ___ |/ / / /__ __/ /_/ / __/
  5. // /_____/_____/_/ |_\____/_/ |_\____/_/ |_/_/ /_/ /_/ \____/____/
  6.  
  7. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  8. // © blackcat1402
  9. //@version=5
  10.  
  11. indicator('[blackcat] L2 Reversal Labels', overlay=true, max_bars_back=5000, max_labels_count=500)
  12.  
  13. [diff, dea, macd] = ta.macd(close,12, 26, 9)
  14. a1 = ta.barssince(ta.crossover(diff,dea)[1])
  15. a2 = ta.barssince(ta.crossunder(diff,dea)[1])
  16. bottom_zone = (close[a1+1]>close) and (diff>diff[a1+1]) and ta.crossover(diff,dea)
  17. top_zone = (close[a2+1]<close) and (diff[a2+1]>diff) and ta.crossunder(diff,dea)
  18. long =false
  19. short =false
  20.  
  21.  
  22. // Plot labels
  23. l0 = top_zone ? label.new(bar_index, high * 1.0, 'Near Top', color=color.new(color.red, 50), textcolor=color.white, style=label.style_label_down, yloc=yloc.price, size=size.small) : bottom_zone ? label.new(bar_index, low * 1.0, 'Near Bottom', color=color.new(color.green, 50), textcolor=color.white, style=label.style_label_up, yloc=yloc.price, size=size.small) : na
  24.  
  25. if long
  26. longmsg = 'Bottom Reversal Soon!'
  27. alert(message=longmsg, freq=alert.freq_once_per_bar_close)
  28. else if short
  29. shortmsg = 'Top Reversal Soon!'
  30. alert(message=shortmsg, freq=alert.freq_once_per_bar_close)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment