Bull Bear Power Trend For ThinkOrSwim

ApoZee

New member
Any additions or modifications to the indicator is welcome.

Code:
#####
## Bull Bear Power Trend by Dreadblitz
## https://www.tradingview.com/v/wjlDy5tV/
##
##Converted by Zurika (ApoZee)
##
####

declare lower;

# I took the length out because I am not using the Reg_Trend
# input length = 8;

def bulltr_hist = 0.0;
def beartr_hist = 0.0;

def bullTrend = (close - Lowest(low, 50)) / ATR(5);
def bearTrend = (Highest(high, 50) - close) / ATR(5);
def bearTrend2 = -1 * bearTrend;
def trend =  bullTrend - bearTrend;

plot bull = bullTrend;
bull.SetDefaultColor(color = Color.GREEN);
plot bear = bearTrend2;
bear.SetDefaultColor(color = Color.RED);

def bullComp = if bullTrend < 2 then bulltr_hist else bullTrend - 2;
plot bull_hist = bullComp;
bull_hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
bull_hist.SetDefaultColor(GetColor(6));
bull_hist.SetLineWeight(3);

def bearComp = if bearTrend2 > -2 then beartr_hist else bearTrend2 + 2;
plot bear_hist = bearComp;
bear_hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
bear_hist.SetDefaultColor(GetColor(5));
bear_hist.SetLineWeight(3);

plot trendline = trend;
trendline.SetDefaultColor(GetColor(1));
trendline.SetLineWeight(2);

plot zline = 0;
zline.SetDefaultColor(GetColor(4));
plot pline = 2;
pline.SetDefaultColor(GetColor(3));
pline.SetStyle(Curve.SHORT_DASH);
plot nline = -2;
nline.SetDefaultColor(GetColor(4));
nline.SetStyle(Curve.SHORT_DASH);

#Bull Cloud
AddCloud(bull, pline,Color.GREEN, Color.LIME, yes);

#Bear Cloud
AddCloud(bear, nline, Color.PINK, Color.RED, yes);



#def x = barNumber();
#def y = trend;
 
202212252330-Bull-Bear-Power-Trend-TV.jpg


202212252247-Bull-Bear-Power-Trend-TOS.jpg


Code:
#####
## Bull Bear Power Trend by Dreadblitz
## https://www.tradingview.com/v/wjlDy5tV/
##
## Converted by Zurika (ApoZee)
## Additional Translation by @netarchitech
##
####

declare lower;

input reg_trend_on = no; #yes;
input length = 8;

def bullTrend = (close - Lowest(low, 50)) / ATR(5);
def bearTrend = (Highest(high, 50) - close) / ATR(5);
def bearTrend2 = -1 * bearTrend;

def trend =  bullTrend - bearTrend;

# Approximation of alexgrover's Regression Line Formula
def x = barnumber();
def y = trend;
def x_ = Average(x, length);
def y_ = Average(y, length);
def mx = StDev(x, length);
def my = StDev(y, length);
def c = Correlation(x, y, length);
def slope = c * (my / mx);
def inter = y_ - slope * x_;
def reg_trend =  x * slope + inter;
plot result = if reg_trend_on then reg_trend else Double.NaN;

def bulltr_hist = 0.0;
def beartr_hist = 0.0;

plot zline = 0;
zline.SetDefaultColor(GetColor(4));
plot pline = 2;
pline.SetDefaultColor(GetColor(6));
#pline.SetStyle(Curve.SHORT_DASH);
plot nline = -2;
nline.SetDefaultColor(GetColor(5));
#nline.SetStyle(Curve.SHORT_DASH);

plot bull = bullTrend;
bull.SetDefaultColor(Color.GREEN);
plot bear = bearTrend2;
bear.SetDefaultColor(Color.RED);

AddCloud(bull, pline, Color.GREEN, Color.GREEN);
AddCloud(bear, nline, Color.RED, Color.RED);
AddCloud(nline, pline, Color.BLACK, Color.BLACK);

def bullComp = if bullTrend < 2 then bullTrend - 2 else bulltr_hist;
plot bull_hist = bullComp;
bull_hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
bull_hist.SetDefaultColor(GetColor(5));
bull_hist.SetLineWeight(5);

def bearComp = if bearTrend2 > -2 then bearTrend2 + 2 else beartr_hist;
plot bear_hist = bearComp;
bear_hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
bear_hist.SetDefaultColor(GetColor(6));
bear_hist.SetLineWeight(5);

plot trendline = trend;
trendline.SetDefaultColor(Color.WHITE);
trendline.SetLineWeight(1);

Thanks to ApoZee for the initial conversion...

Good Luck and Good Trading :cool:
 

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
410 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