xmd79

Regime Filter [CHE]

Jan 1st, 2023
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © chervolino
  3.  
  4. //@version=5
  5. indicator("Regime Filter [CHE]", "Regime Filter [CHE]", timeframe="", overlay = true)
  6.  
  7.  
  8. //------------------------------------------------------------------------------
  9. // Settings
  10. //-----------------------------------------------------------------------------{
  11. length = input(50)
  12. sig_length = input(9,'Signal Length')
  13.  
  14. //-----------------------------------------------------------------------------}
  15. // Exponential Envelopes
  16. //-----------------------------------------------------------------------------{
  17. var a1 = 2/(length+1)
  18.  
  19. var u1_1 = 0.,var u1_2 = 0.
  20. var d1_1 = 0.,var d1_2 = 0.
  21.  
  22. u1_1 := nz(math.max(close, open, u1_1[1] - (u1_1[1] - close) * a1), close)
  23. u1_2 := nz(math.max(close * close, open * open, u1_2[1] - (u1_2[1] - close * close) * a1), close * close)
  24.  
  25. d1_1 := nz(math.min(close, open, d1_1[1] + (close - d1_1[1]) * a1), close)
  26. d1_2 := nz(math.min(close * close, open * open, d1_2[1] + (close * close - d1_2[1]) * a1), close * close)
  27.  
  28. //Components
  29. bl = math.sqrt(d1_2 - d1_1 * d1_1)
  30. br = math.sqrt(u1_2 - u1_1 * u1_1)
  31.  
  32. signal = ta.ema(math.max(bl, br), sig_length)
  33. osc_color = (100 * (bl - br) / br) > 0 ?color.yellow :color.blue
  34.  
  35. plotshape(true , 'line', shape.circle , location.bottom, osc_color, show_last=233, size=size.tiny)
Advertisement
Add Comment
Please, Sign In to add comment