Advertisement
xmd79

[SHK] Schaff Trend Cycle (STC)

Jan 15th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. //@version=5
  2. //[SHK] STC colored indicator
  3. //https://www.tradingview.com/u/shayankm/
  4.  
  5. indicator(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)
  6. EEEEEE = input(12, 'Length')
  7. BBBB = input(26, 'FastLength')
  8. BBBBB = input(50, 'SlowLength')
  9.  
  10. AAAA(BBB, BBBB, BBBBB) =>
  11. fastMA = ta.ema(BBB, BBBB)
  12. slowMA = ta.ema(BBB, BBBBB)
  13. AAAA = fastMA - slowMA
  14. AAAA
  15.  
  16. AAAAA(EEEEEE, BBBB, BBBBB) =>
  17. AAA = input(0.5)
  18. var CCCCC = 0.0
  19. var DDD = 0.0
  20. var DDDDDD = 0.0
  21. var EEEEE = 0.0
  22. BBBBBB = AAAA(close, BBBB, BBBBB)
  23. CCC = ta.lowest(BBBBBB, EEEEEE)
  24. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  25. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  26. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  27. DDDD = ta.lowest(DDD, EEEEEE)
  28. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  29. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  30. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  31. EEEEE
  32.  
  33. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  34. mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
  35. _mColor = mAAAAA > mAAAAA[1]
  36. alertcondition((not _mColor[1] and _mColor), "Red to Green", "Red to Green")
  37. alertcondition((_mColor[1] and not _mColor), "Green to Red", "Green to Red")
  38.  
  39.  
  40. if mAAAAA[3] <= mAAAAA[2] and mAAAAA[2] > mAAAAA[1] and mAAAAA > 75
  41. alert("Red", alert.freq_once_per_bar)
  42. if mAAAAA[3] >= mAAAAA[2] and mAAAAA[2] < mAAAAA[1] and mAAAAA < 25
  43. alert("Green", alert.freq_once_per_bar)
  44.  
  45.  
  46. plot(mAAAAA, color=mColor, title='STC', linewidth=2)
  47.  
  48. ul = plot(25, color=color.new(color.gray, 70))
  49. ll = plot(75, color=color.new(color.gray, 70))
  50. fill(ul, ll, color=color.new(color.gray, 96))
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement