Dynamic Levels Breakouts For ThinkOrSwim

hi group! happy sunday to all!
i found this great indicator, i hope one of the greatest coder here can help me! thank you in advance

https://www.tradingview.com/v/FwJOjpzv/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// Angel Algo
//@version=5
indicator("Dynamic Levels Breakouts", overlay = true)

// Script inputs

length = input.int(defval=20, title="Period", minval=2, maxval=30) // 20 or 15


// Calculate maximum and minimum price in the rolling window

max_level = ta.highest(high, length)

min_level = ta.lowest(low, length)


// Define condtions for dynamic support and resistance levels detection and plotting

max_color_cond = (max_level[1]==max_level[2]) and (close[1]<=max_level[1])
and (close[1]>=min_level[1])

min_color_cond = (min_level[1]==min_level[2]) and (close[1]<=max_level[1])
and (close[1]>=min_level[1])


// Define conditional coloring for dynamic support and resistance levels

max_level_color = max_color_cond ? color.new(color.red,70):na

min_level_color = min_color_cond ? color.new(color.green,70):na


// Define bullish and bearish breakouts condition

bullish_breakout = ta.crossover (close, max_level[1])

bearish_breakout = ta.crossunder (close, min_level[1])


//Plot dynamic support and resistance levels

plot(max_level[1], color = max_level_color,linewidth=2)

plot(min_level[1], color = min_level_color,linewidth=2)


// Define a current market regime condition

not_bullish = ta.barssince(bullish_breakout[1])>ta.barssince(bearish_breakout[1])

not_bearish = ta.barssince(bullish_breakout[1])<ta.barssince(bearish_breakout[1])


// Plot dynamic support and resistance levels breakout signals

plotshape(bullish_breakout and not_bullish, text="▲", style=shape.labelup,
color=color.green, textcolor=color.white, location=location.belowbar, size=size.small)

plotshape(bearish_breakout and not_bearish, text="▼", style=shape.labeldown,
color=color.red, textcolor=color.white, location=location.abovebar, size=size.small)
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// Angel Algo
# indicator("Dynamic Levels Breakouts", overlay = true)
# Converted by Sam4Cok@Samer800    - 08/2023

input showHiLoLines = yes;
input length = 20;#, title="Period", minval=2, maxval=30) // 20 or 15

def na = Double.NaN;
#// Calculate maximum and minimum price in the rolling window

def max_level = highest(high, length);
def min_level = lowest(low , length);

#// Define condtions for dynamic support and resistance levels detection and plotting

def max_color_cond = (max_level[1]==max_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1]);
def min_color_cond = (min_level[1]==min_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1]);

#// Define conditional coloring for dynamic support and resistance levels
def max_level_color = max_color_cond and showHiLoLines;# ? color.new(color.red,70):na
def min_level_color = min_color_cond and showHiLoLines;# ? color.new(color.green,70):na

#// Define bullish and bearish breakouts condition
def bullish_breakout = crosses(close, max_level[1], CrossingDirection.ABOVE) and atr(1) > atr(10);
def bearish_breakout = crosses(close, min_level[1], CrossingDirection.BELOW) and atr(1) > atr(10);

#/ Define a current market regime condition
def barBull = if bullish_breakout[1] then 0 else barBull[1] + 1;
def barBear = if bearish_breakout[1] then 0 else barBear[1] + 1;

def not_bullish = barBull > barBear;
def not_bearish = barBull < barBear;

#//Plot dynamic support and resistance levels
plot maxLevel = if max_level_color then max_level[1] else na;#, color = max_level_color,linewidth=2)
plot minLevel = if min_level_color then min_level[1] else na;#, color = min_level_color,linewidth=2)

maxLevel.SetDefaultColor(Color.DARK_RED);
minLevel.SetDefaultColor(Color.DARK_GREEN);
#// Plot dynamic support and resistance levels breakout signals
AddChartBubble(bullish_breakout and not_bullish, low, "B", Color.GREEN, no);#, text="?", style=shape.labelup,
AddChartBubble(bearish_breakout and not_bearish, high, "S", Color.RED, yes);#text="?", style=shape.labeldown,


#-- END of CODE
 
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// Angel Algo
# indicator("Dynamic Levels Breakouts", overlay = true)
# Converted by Sam4Cok@Samer800    - 08/2023

input showHiLoLines = yes;
input length = 20;#, title="Period", minval=2, maxval=30) // 20 or 15

def na = Double.NaN;
#// Calculate maximum and minimum price in the rolling window

def max_level = highest(high, length);
def min_level = lowest(low , length);

#// Define condtions for dynamic support and resistance levels detection and plotting

def max_color_cond = (max_level[1]==max_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1]);
def min_color_cond = (min_level[1]==min_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1]);

#// Define conditional coloring for dynamic support and resistance levels
def max_level_color = max_color_cond and showHiLoLines;# ? color.new(color.red,70):na
def min_level_color = min_color_cond and showHiLoLines;# ? color.new(color.green,70):na

#// Define bullish and bearish breakouts condition
def bullish_breakout = crosses(close, max_level[1], CrossingDirection.ABOVE) and atr(1) > atr(10);
def bearish_breakout = crosses(close, min_level[1], CrossingDirection.BELOW) and atr(1) > atr(10);

#/ Define a current market regime condition
def barBull = if bullish_breakout[1] then 0 else barBull[1] + 1;
def barBear = if bearish_breakout[1] then 0 else barBear[1] + 1;

def not_bullish = barBull > barBear;
def not_bearish = barBull < barBear;

#//Plot dynamic support and resistance levels
plot maxLevel = if max_level_color then max_level[1] else na;#, color = max_level_color,linewidth=2)
plot minLevel = if min_level_color then min_level[1] else na;#, color = min_level_color,linewidth=2)

maxLevel.SetDefaultColor(Color.DARK_RED);
minLevel.SetDefaultColor(Color.DARK_GREEN);
#// Plot dynamic support and resistance levels breakout signals
AddChartBubble(bullish_breakout and not_bullish, low, "B", Color.GREEN, no);#, text="?", style=shape.labelup,
AddChartBubble(bearish_breakout and not_bearish, high, "S", Color.RED, yes);#text="?", style=shape.labeldown,


#-- END of CODE
thank you some much @samer800
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
233 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top