xmd79

Adaptive Trend Lines (Expo)

May 22nd, 2023
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 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. // © Zeiierman
  3.  
  4. //Copyright by Zeiierman.
  5. //The information contained in my scripts/indicators/ideas does not constitute financial advice or a solicitation to buy or sell any securities of any type.
  6. //I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from use of or reliance on such information.
  7. //All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, or individual’s trading does not guarantee future results or returns.
  8. //Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
  9. //My scripts/indicators/ideas are only for educational purposes!
  10.  
  11. //@version=4
  12. study("Adaptive Trend Lines (Expo)", overlay=true)
  13.  
  14. // Input
  15. _src = close
  16. _lookback_positive = input(100, title="Positive Trend Length")
  17. _lookback_negative = input(100, title="Negative Trend Length")
  18. _std = input(10, title="Standard deviation Period")
  19. _tr = 10
  20. _mult = input(1, title="Multiplicator")
  21.  
  22. _Self_Adjusts = ((tr[_tr]+stdev(_src,_std)*_mult))
  23.  
  24.  
  25. // Line 1, Line2, Line 3 = Positive
  26. // Line 1, Line2, Line 3 = Positive
  27.  
  28. // Line 1
  29. var lowest_low_line = line.new(bar_index[0], high[0], bar_index,low,color=color.green)
  30. line.set_xy1(lowest_low_line,bar_index[0],lowest(low,_lookback_positive))
  31. line.set_xy2(lowest_low_line,bar_index[lowestbars(low,_lookback_positive)*-1],lowest(low,_lookback_positive))
  32.  
  33. // Line 2
  34. var positive_trend_line = line.new(bar_index[0], high[0], bar_index,low,color=color.green,extend=extend.left)
  35. line.set_xy1(positive_trend_line,bar_index[0],lowest(low,_lookback_positive)+_Self_Adjusts)
  36. line.set_xy2(positive_trend_line,bar_index[lowestbars(low,_lookback_positive)*-1],lowest(low,_lookback_positive))
  37.  
  38. // Line 3
  39. var positive_trend_channel = line.new(bar_index[0], high[0], bar_index,low,color=color.green,extend=extend.left)
  40. line.set_xy1(positive_trend_channel,bar_index[0],highest(high,_lookback_positive)+_Self_Adjusts/2)
  41. line.set_xy2(positive_trend_channel,bar_index[lowestbars(low,_lookback_positive)*-1],highest(low,_lookback_positive))
  42.  
  43.  
  44. // Line 4, Line 5, Line 6 = Negative
  45. // Line 4, Line 5, Line 6 = Negative
  46.  
  47. // Line 4
  48. var highest_high_line = line.new(bar_index[0], high[0], bar_index,low,color=color.red)
  49. line.set_xy1(highest_high_line,bar_index[0],highest(high,_lookback_negative))
  50. line.set_xy2(highest_high_line,bar_index[highestbars(high,_lookback_negative)*-1],highest(high,_lookback_negative))
  51.  
  52.  
  53. // Line 5
  54. var negative_trend_line = line.new(bar_index[0], high[0], bar_index,low,color=color.red, extend=extend.left)
  55. line.set_xy1(negative_trend_line,bar_index[0],highest(high,_lookback_negative)-_Self_Adjusts)
  56. line.set_xy2(negative_trend_line,bar_index[highestbars(high,_lookback_negative)*-1],highest(high,_lookback_negative))
  57.  
  58.  
  59. // Line 6
  60. var negative_trend_channel = line.new(bar_index[0], high[0], bar_index,low,color=color.red, extend=extend.left)
  61. line.set_xy1(negative_trend_channel,bar_index[0],lowest(high,_lookback_negative)-_Self_Adjusts/2)
  62. line.set_xy2(negative_trend_channel,bar_index[highestbars(high,_lookback_negative)*-1],lowest(high,_lookback_negative))
  63.  
  64.  
  65.  
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment