Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Zeiierman
- //Copyright by Zeiierman.
- //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.
- //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.
- //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.
- //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.
- //My scripts/indicators/ideas are only for educational purposes!
- //@version=4
- study("Adaptive Trend Lines (Expo)", overlay=true)
- // Input
- _src = close
- _lookback_positive = input(100, title="Positive Trend Length")
- _lookback_negative = input(100, title="Negative Trend Length")
- _std = input(10, title="Standard deviation Period")
- _tr = 10
- _mult = input(1, title="Multiplicator")
- _Self_Adjusts = ((tr[_tr]+stdev(_src,_std)*_mult))
- // Line 1, Line2, Line 3 = Positive
- // Line 1, Line2, Line 3 = Positive
- // Line 1
- var lowest_low_line = line.new(bar_index[0], high[0], bar_index,low,color=color.green)
- line.set_xy1(lowest_low_line,bar_index[0],lowest(low,_lookback_positive))
- line.set_xy2(lowest_low_line,bar_index[lowestbars(low,_lookback_positive)*-1],lowest(low,_lookback_positive))
- // Line 2
- var positive_trend_line = line.new(bar_index[0], high[0], bar_index,low,color=color.green,extend=extend.left)
- line.set_xy1(positive_trend_line,bar_index[0],lowest(low,_lookback_positive)+_Self_Adjusts)
- line.set_xy2(positive_trend_line,bar_index[lowestbars(low,_lookback_positive)*-1],lowest(low,_lookback_positive))
- // Line 3
- var positive_trend_channel = line.new(bar_index[0], high[0], bar_index,low,color=color.green,extend=extend.left)
- line.set_xy1(positive_trend_channel,bar_index[0],highest(high,_lookback_positive)+_Self_Adjusts/2)
- line.set_xy2(positive_trend_channel,bar_index[lowestbars(low,_lookback_positive)*-1],highest(low,_lookback_positive))
- // Line 4, Line 5, Line 6 = Negative
- // Line 4, Line 5, Line 6 = Negative
- // Line 4
- var highest_high_line = line.new(bar_index[0], high[0], bar_index,low,color=color.red)
- line.set_xy1(highest_high_line,bar_index[0],highest(high,_lookback_negative))
- line.set_xy2(highest_high_line,bar_index[highestbars(high,_lookback_negative)*-1],highest(high,_lookback_negative))
- // Line 5
- var negative_trend_line = line.new(bar_index[0], high[0], bar_index,low,color=color.red, extend=extend.left)
- line.set_xy1(negative_trend_line,bar_index[0],highest(high,_lookback_negative)-_Self_Adjusts)
- line.set_xy2(negative_trend_line,bar_index[highestbars(high,_lookback_negative)*-1],highest(high,_lookback_negative))
- // Line 6
- var negative_trend_channel = line.new(bar_index[0], high[0], bar_index,low,color=color.red, extend=extend.left)
- line.set_xy1(negative_trend_channel,bar_index[0],lowest(high,_lookback_negative)-_Self_Adjusts/2)
- line.set_xy2(negative_trend_channel,bar_index[highestbars(high,_lookback_negative)*-1],lowest(high,_lookback_negative))
Advertisement
Add Comment
Please, Sign In to add comment