Repaints B4 Balanced BB Breakout For ThinkOrSwim

Repaints
Status
Not open for further replies.
Hey, Joe
Have you had any success reaching out? Just curious.
Hey Chuck, I was waiting on Cos251 to get back to me on a different script and then I was going to ask him...I could maybe try reaching out to DiazLaz...There is no PM on here and to get in touch with Cos I had to contact Ben10 and set up a PM...I'll give it till the weekend and if I don't hear back I'll reach out to Ben10 and see if he could PM Diazlaz or suggest someone for you. SuryaKiran is another coder that helped out on the RSM study. I didn't forget about you...I'll keep you posted...
 
Thanks Joe, Thanks for getting back with me. I appreciate all you do around here.
Happy Trading
Np anytime, I'll let you know by Sunday the latest if I hear back, if not then I'll reach out to Ben10. Thanks, I'm learning little by little, everyone is super helpful on here, I just try to help out whenever I can and try to keep learning :)
 
Thanks Joe, Thanks for getting back with me. I appreciate all you do around here.
Happy Trading
Hi @Chuck , I have reached out to BenTen, Cos251 and DiazLaz who are all well versed in the type of script you are trying to fine tune...Hopefully one of them reach out to you shortly.

Hopefully I explained it correctly to them. Take care
Joe

@BenTen @cos251 @diazlaz

Sorry to bother you guys but if someone has any free time to help out a fellow member @Chuck with his Balance BB Breakout (Balance of Power) Indicator that he has combined with @cos251 RSM indicator, EMA and TEMA, Keltner Channels, Bolinger Bands, Multiple labels all in a lower indicator which lets you check your P/L just by tweaking the time frames to see which time frames are most profitable...

Maybe @diazlaz and @cos251 (who have experience combinng and incorporating multiple indicators and scans) can help @Chuck tweak his settings,help fine tuning and have any suggestion for his Balance of Power (Balance BB Breakout) lower indicator and also helping setting up a scan and watchlist for the Balance BB Breakout.

Any help for @Chuck would be greatly appreciated. I know you guys are super busy but I figured I'd at least reach out and try to help him out. Thanks in advance, hope all you guys and your families are/stay safe :)

Here is the link, pic and the script...

Link: https://tos.mx/GaYtlPX

Pic:




Script:
# Balanced BB Breakout Indicator

# Assembled by Chuck Edwards

# V1.2

# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.

#################################################################
#################### TOS MARKET FORECAST #######################
#################################################################
#Edited by Chuck_E
declare lower;

def pIntermediate = MarketForecast()."Intermediate" ;

DefineGlobalColor("Pre_Cyan", CreateColor(204, 255, 204)) ;
DefineGlobalColor("LabelGreen", CreateColor(0, 165, 0)) ;

AddLabel(yes,
if pIntermediate >= 80 then "Market Forecast Bullish" else
if pIntermediate <= 20 then "Market Forecast Bearish" else
if pIntermediate > pIntermediate[1] then "Market Forecast Rising" else
if pIntermediate < pIntermediate[1] then "Market Forecast Falling" else " ",
if pIntermediate >= 80 then GlobalColor("Pre_Cyan") else
if pIntermediate <= 20 then Color.RED else
if pIntermediate > pIntermediate[1] then GlobalColor("LabelGreen") else
if pIntermediate < pIntermediate[1] then Color.RED else Color.LIGHT_GRAY);


################################################################
#################### MACD_BB ##########################
################################################################
# By Eric Purdy, Thinkscripter LLC
# Modification to color scheme by Rick_K 12/26/20.
# Edited color scheme Chuck_E 02/23/21.

###### MACD
input price = close;
input BBlength = 15;
input BBNum_Dev = 1.0;
input MACDfastLength = 12;
input MACDslowLength = 26;
input fastLengthMACD = 12;
input slowLengthMACD = 26;
input MACDLength = 25;
input averageTypeMACD = AverageType.WEIGHTED;
input showBreakoutSignals = no;

def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
plot MACD_Dots = MACD_Data;
plot MACD_Line = MACD_Data;

plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand;
plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband;
plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine;

BB_Upper.SetDefaultColor(Color.RED);
BB_Lower.SetDefaultColor(Color.GREEN);
BB_Midline.SetDefaultColor(Color.LIGHT_RED);
BB_Midline.SetStyle(Curve.FIRM);

MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.GREEN else Color.RED);
MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line >= BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line >= BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line <= BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line <= BB_Lower then Color.DARK_RED else Color.GRAY);
MACD_Line.SetLineWeight(1);

MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.GREEN else Color.RED);
MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED else Color.GRAY);

MACD_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACD_Dots.SetLineWeight(1);

def zero = 0;



###### Keltner Channels


input displace = 0;
input factor = 1.5;
input length = 20;
input averageType = AverageType.EXPONENTIAL;
input trueRangeAverageType = AverageType.EXPONENTIAL;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);
#def Avg = average[-displace];

def Upper_Band = average[-displace] + shift[-displace];
def Lower_Band = average[-displace] - shift[-displace];


###### Bollinger Bands


input BBLength2 = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input bb_averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = BBLength2);
def MidLine = MovingAverage(bb_averageType, data = price[-displace], length = BBLength2);
def LowerBand = MidLine + Num_Dev_Dn * sDev;
def UpperBand = MidLine + Num_Dev_up * sDev;


###### Add Cloud


AddCloud(if UpperBand <= Upper_Band and LowerBand >= Lower_Band then BB_Upper else BB_Lower, BB_Lower, Color.YELLOW);
AddCloud( BB_Upper, BB_Lower, Color.LIGHT_RED );


###### Add Alert


def bull_cross = MACD_Line crosses above zero;
def bear_cross = MACD_Line crosses below zero;

Alert(bull_cross, "Time to Buy", Alert.BAR, Sound.Chimes);
Alert(bear_cross, "Time to Sell", Alert.BAR, Sound.Bell);


################################################################
########## RSI/STOCASTIC/MACD CONFLUENCE COMBO #############
################################################################
#CHANGELOG
# 2020.10.27 V1.0 @cos251 - Added RSI, StochasticSlow and MACD to same indicator; this will plot only MACD but also
# - calculates RSI and Sotchasit; Will shade the lower plot area of the following conditions are met
# Shade GREEN = RSI > 50 and SlowK > 50 and (macd)Value > (macd)Avg
# Shade RED = RSI < 50 and SlowK < 50 and (macd)Value < (macd)Avg
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
# Stoch Slow 5(not14) and 3 WILDERS
# MACD 12,26,9 WEIGHTED
#CREDITS
# requesed by "@Joseph Patrick 18"
#LINK
# https://rockwell-files.s3.amazonaws.com/PXCompanionGuide2ndEd_cover.pdf
# Markus Heikoetter who is the author of the Power X Strategy
# https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#Edited by Chuck_E


def Value = MovingAverage(averageTypeMACD, close, fastLengthMACD) - MovingAverage(averageTypeMACD, close, slowLengthMACD);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignalMACD = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignalMACD = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignalMACD.SetHiding(!showBreakoutSignals);
DownSignalMACD.SetHiding(!showBreakoutSignals);

#Value.SetDefaultColor(Color.GREEN);
#Avg.SetDefaultColor(Color.RED);
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(4);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

ZeroLine.SetDefaultColor(Color.RED);

UpSignalMACD.SetDefaultColor(Color.UPTICK);
UpSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

DownSignalMACD.SetDefaultColor(Color.DOWNTICK);
DownSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


###### RSI


input lengthRSI = 7;
input over_BoughtRSI = 70;
input over_SoldRSI = 30;
input averageTypeRSI = AverageType.EXPONENTIAL;


def NetChgAvg = MovingAverage(averageTypeRSI, price - price[1], lengthRSI);
def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(price - price[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);


###### Stochastic Slow


input over_boughtSt = 80;
input over_soldSt = 20;
input KPeriod = 5;#5
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.WILDERS;
input showBreakoutSignalsStoch = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

def SlowK = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullD;


###### Check for signals > 50 and macd Value > Avg


def rsiGreen = if RSI >= 50 then 1 else Double.NaN;
def rsiRed = if RSI < 50 then 1 else Double.NaN;
def stochGreen = if SlowK >= 50 then 1 else Double.NaN;
def stochRed = if SlowK < 50 then 1 else Double.NaN;
def macdGreen = if Value > Avg then 1 else Double.NaN;
def macdRed = if Value < Avg then 1 else Double.NaN;


###### Shade areas based on criteria; adjust as needed


AddCloud(if rsiGreen and stochGreen and macdGreen then Double.POSITIVE_INFINITY else Double.NaN, if rsiGreen and stochGreen then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);
AddCloud(if rsiRed and stochRed and macdRed then Double.POSITIVE_INFINITY else Double.NaN, if rsiRed and stochRed then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED);


################################################################
########## Variables #########
################################################################
#input aggPeriod = AggregationPeriod.MIN;
def aggPeriod = GetAggregationPeriod();
input paintBars = yes;
input showRSMShade = no;
input tradetype = { "long", "short", default "both" };
input showTrendLabels = no;
input showIndLabels = no;
input rangeType = { default "ADR", "ATR" };
input plotADR = yes;
input showADRZones = no;
input showADRLabels = no;


################################################################
########## Assign Price Color #########
################################################################
#AssignPriceColor
AssignPriceColor(if paintBars and RSI >= 50 and SlowK >= 50 and Value > Avg then Color.GREEN else if paintBars and RSI < 50 and SlowK < 50 and Value < Avg then Color.RED else if paintBars then Color.DARK_GRAY else Color.CURRENT);


#################################################################
############ BALANCE OF POWER TREND ############################
#################################################################
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/XldP1lmA/


input EMA = 20;
input TEMA = 20;
input high_l = 0.1;
input low_l = -0.1;

def THL = If(high != low, high - low, 0.01);
def BullOpen = (high - open) / THL;
def BearOpen = (open - low) / THL;
def BullClose = (close - low) / THL;
def BearClose = (high - close) / THL;
def BullOC = If(close > open, (close - open) / THL, 0);
def BearOC = If(open > close, (open - close) / THL, 0);
def BullReward = (BullOpen + BullClose + BullOC) / 1;
def BearReward = (BearOpen + BearClose + BearOC) / 1;

def BOP = BullReward - BearReward;
def SmoothBOP = ExpAverage(BOP, EMA);
def xPrice = SmoothBOP;
def xEMA1 = ExpAverage(SmoothBOP, TEMA);
def xEMA2 = ExpAverage(xEMA1, TEMA);
def xEMA3 = ExpAverage(xEMA2, TEMA);
def nRes = 3 * xEMA1 - 3 * xEMA2 + xEMA3;

def SmootherBOP = nRes;
def s1 = SmoothBOP;
def s2 = SmootherBOP;
def s3 = SmootherBOP[2];


####### Vertical Lines
def short = s2 < s3 and s2[1] > s3[1];
def long = s2 > s3 and s2[1] < s3[1];

AddVerticalLine(short, close, Color.RED, Curve.SHORT_DASH);
AddVerticalLine(long, close, Color.GREEN, Curve.SHORT_DASH);

###### P/L Statement
input PandL_Label = Yes;

def orderDir = CompoundValue(1, if s2 < s3 then 1 else if s2 > s3 then -1 else orderDir[1], 0);
def isOrder = orderDir crosses 0;

def orderCount = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then orderCount[1] + 1 else orderCount[1], 0);

def noBar = IsNaN(open[-1]);

def orderPrice = if isOrder then if noBar then close else open[-1] else orderPrice[1];
def profitLoss = if !isOrder or orderCount == 1
then 0
else if orderDir < 0 then orderPrice[1] - orderPrice
else if orderDir > 0 then orderPrice - orderPrice[1] else 0;
#else if orderDir > 0 then orderPrice[1] - orderPrice
#else if orderDir < 0 then orderPrice - orderPrice[1] else 0;
#def profitLoss = if !isOrder or orderCount == 1 then 0 else orderPrice - orderPrice[1];
def profitLossSum = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then profitLossSum[1] + profitLoss else profitLossSum[1], 0);

def orderWinners = CompoundValue(1, if IsNaN(isOrder) then orderWinners[1] else if orderCount > 1 and profitLoss > 0 then orderWinners[1] + 1 else orderWinners[1], 0);


###### Add Label

AddLabel(PandL_Label, orderCount + " orders (" + AsPercent(orderWinners / orderCount) + ") | P/L " + AsDollars ((profitLossSum / TickSize()) * TickValue()), if profitLossSum > 0 then Color.GREEN else if profitLossSum < 0 then Color.RED else Color.GRAY);






#------ End Balanced BB Breakout Indicator




Thanks
Joe
 
@Chuck I don't know if you've looked at Renko bars with this indicator on, but at first glance, it looks incredibly promising. I just discovered this indicator so I am curious: the P/L is going off of the green/red vertical lines as entry/exit signals, correct? I'm looking at a 4-tick Renko on the /ES and it just looks too good to be true. Granted, you'd almost need a bot to trade for you because of how quick the trades come and go.
 
@Chuck I don't know if you've looked at Renko bars with this indicator on, but at first glance, it looks incredibly promising. I just discovered this indicator so I am curious: the P/L is going off of the green/red vertical lines as entry/exit signals, correct? I'm looking at a 4-tick Renko on the /ES and it just looks too good to be true. Granted, you'd almost need a bot to trade for you because of how quick the trades come and go.
@The Bataylor,
The strat tester is true as far as I can tell. The only problem is it shakes me out on the /ES because I don't have enough money to stomach the drawdown. On a paper trade with plenty capital and no risk, I get those results. (Close)The buy or sell line will change sometimes back and forth on whatever time frame you trade until the candle is closed. But the end results you see are true as far as I can tell.
 
@Chuck Thank you for putting this together. I have been watching it all day today and pretty cool.

Here is a summary of my understanding, and questions.

Market Forecast: This is provided by ToS. Script is showing when the intermediate level being greater than 80, less than 20, if between, increasing or decreasing. Intermediate level is the monthly outlook.

Question:
  1. If we are going to day trade, should we be using momentum instead?
  2. ToS docs say that we should be looking to reversals from highs and lows for this indicator. Do you find that rate of change is good?
MACD BB: Self explanatory. Dots, colors, line, channel etc.

Keltner Channel and BB: This seems to be used in conjunction with another BB and shades when BB is inside of the Keltner channel.

Question:
  1. Is this to show squeeze?
RSM: Self explanatory. Colors, go long, short, etc.

Balance of Power: It seems like the PnL is only calculated using Balance of Power.

Overall Question:

When do you take trades? How to you sort priority of these indicators? Do you wait for certain levels to line up?

I appreciate all your help.
 
I use the Market Forecast to find buying and selling opportunities based on several timeframes. It gauges “Momentum”, in this case Intermediate. It cycles on daily, weekly, and monthly basis, respectively.

This indicator as I understand is the Intermediate term, that would be the monthly outlook. As far as the rate of change I start all of my trades starting with a monthly outlook, so that is always my priority……It would be nice to be able to show near term and immediate as well, I don’t have the coding skill. That would allow for full timeframe continuity.

I will probably replace that in the near future with Pelonsax’s Study

NEW_STRAT_MTF_LABEL_w_REVERSALS-INTRADAY

I am quickly becoming a believer in “#TheStrat” style of trading. Just entered my first trade using it today and was very impressed. Every instrument I chose took off today.

Concerning Momentum, that is used in just about every trading document you can find. However, it is a subjective term…. Let me explain:

Linear momentum is defined as the product of a system's mass multiplied by its velocity.

Price action does not have all of the requirements typically used for the formulas for oscillators.

Price aggregates. No mass involved. But ideally as you mentioned most people rould want to enter trades when you have the potential for a long move. Areas of consolidation will chop you to pieces. Those are areas of new price discovery of as some call them balanced areas, Non-Trending etc.

Some people use the volume profile to spot areas where not much trade has accorded to spot places where price will jump from one place of equilibrium to the next. Some use the Ichimoku system to gauge areas of equilibrium and potintioal long trend movement and reversals. Ichimoku plots these areas of consolidation as flat lines in the SSA,SSB,Kijun and Tenkin. When Chiku is clear pointing up above price and out of the it is typically a Blue-Sky Breakout.

For a swing trade entry:

I use a top-down process starting with the monthly chart

I then look at the weekly chart

Then I go to the daily chart

Then on to the hourly chart

In my opinion that should be the process involved in a day trade as well. The Balanced BB Breakout is a good resource in my opinion to confirm buy signals on all timeframes prior to entry.

I typically Find my trade edge on a smaller timeframe like 5 min etc. I am converting to the Strat entry style from now on.

Please don’t consider any ticker symbols or comments as trading advice.
 
And I still, use the top ultimate as well. love it... I am trying to clear all the indicators off my charts. I use too many lol
Same here. I used to use the UBI but it needs a good directional indicator. I paired it with MACD, BTD and many others but had a hard time to make it a consistent winner.
 
Hey Chuck, I was waiting on Cos251 to get back to me on a different script and then I was going to ask him...I could maybe try reaching out to DiazLaz...There is no PM on here and to get in touch with Cos I had to contact Ben10 and set up a PM...I'll give it till the weekend and if I don't hear back I'll reach out to Ben10 and see if he could PM Diazlaz or suggest someone for you. SuryaKiran is another coder that helped out on the RSM study. I didn't forget about you...I'll keep you posted...
Hey guys. I was trying to read through the thread quickly, not all caught up though. Happy to try and lend a hand where I can although I have been pretty slammed at work for the last couple months. Can you guys catch me up on where you are trying to go with this script?
 
Hey guys. I was trying to read through the thread quickly, not all caught up though. Happy to try and lend a hand where I can although I have been pretty slammed at work for the last couple months. Can you guys catch me up on where you are trying to go with this script?
@cos251, I am not a coder, I am just now learning. I jumbled this indicator together from a few of my favorite indicators here on the forum. I was able to make it work and find it to be pretty dependable. It uses a lot of memory so I am sure it has some syntax errors and a few lines of code not being used.

I used the BOP indicator stratigy in connection with the indicator as a way to check profitability against timeframes to choose the most profitable time frame for trading what ever instrument you wish. As of now I tweet the settings once I find the optimal timeframe.

I was just hoping someone like yourself could take a quick look at it and tighten it up a notch or two. The market forecast could use a long term /mid term and short term lable, I am not sure how to do that and the Balance of Power is what is used for entry confirmation as of now. It could probably be linked to the macd,bolinger band, fvo, stocastic for a true signal that is in confluence. That would really be awesome. Any help at all in any capacity would be greatly appreciated.
 
@cos251, I am not a coder, I am just now learning. I jumbled this indicator together from a few of my favorite indicators here on the forum. I was able to make it work and find it to be pretty dependable. It uses a lot of memory so I am sure it has some syntax errors and a few lines of code not being used.

I used the BOP indicator stratigy in connection with the indicator as a way to check profitability against timeframes to choose the most profitable time frame for trading what ever instrument you wish. As of now I tweet the settings once I find the optimal timeframe.

I was just hoping someone like yourself could take a quick look at it and tighten it up a notch or two. The market forecast could use a long term /mid term and short term lable, I am not sure how to do that and the Balance of Power is what is used for entry confirmation as of now. It could probably be linked to the macd,bolinger band, fvo, stocastic for a true signal that is in confluence. That would really be awesome. Any help at all in any capacity would be greatly appreciated.
Which version are you using? the one in post #1 or Post #6?
 
Currently I am using:
http://tos.mx/2PlKyRd

Code:
# Assembled by Chuck Edwards

# V1.1

# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Author not responsible for errors or use of tool.

#################################################################
####################  TOS MARKET FORECAST #######################
#################################################################
#Edited by Chuck_E
declare lower;

def pIntermediate = MarketForecast()."Intermediate" ;

DefineGlobalColor("Pre_Cyan", CreateColor(204, 255, 204)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

AddLabel(yes,
if pIntermediate >= 80 then "Market Forecast Bullish" else
if pIntermediate <= 20 then "Market Forecast Bearish" else
if pIntermediate > pIntermediate[1] then "Market Forecast Rising" else
if pIntermediate < pIntermediate[1] then "Market Forecast Falling" else " ",
if pIntermediate >= 80 then GlobalColor("Pre_Cyan") else
if pIntermediate <= 20 then Color.RED else
if pIntermediate > pIntermediate[1] then GlobalColor("LabelGreen") else
if pIntermediate < pIntermediate[1] then Color.RED else Color.LIGHT_GRAY);


################################################################
####################      MACD_BB     ##########################
################################################################
# By Eric Purdy, Thinkscripter LLC
# Modification to color scheme by Rick_K 12/26/20.
# Edited color scheme Chuck_E 02/23/21.

###### MACD
input price = close;
input BBlength = 15;
input BBNum_Dev = 1.0;
input MACDfastLength = 12;
input MACDslowLength = 26;
input fastLengthMACD = 12;
input slowLengthMACD = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.WEIGHTED;
input showBreakoutSignals = no;

def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
plot MACD_Dots = MACD_Data;
plot MACD_Line = MACD_Data;

plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand;
plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband;
plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine;

BB_Upper.SetDefaultColor(Color.RED);
BB_Lower.SetDefaultColor(Color.GREEN);
BB_Midline.SetDefaultColor(Color.LIGHT_RED);
BB_Midline.SetStyle(Curve.FIRM);

MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.GREEN else Color.RED);
MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line >= BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line >= BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line <= BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line <= BB_Lower then Color.DARK_RED else Color.GRAY);
MACD_Line.SetLineWeight(1);

MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.GREEN else Color.RED);
MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED else Color.GRAY);

MACD_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACD_Dots.SetLineWeight(1);

def zero = 0;


###### Keltner Channels
input displace = 0;
input factor = 1.5;
input length = 20;
input averageType = AverageType.EXPONENTIAL;
input trueRangeAverageType = AverageType.EXPONENTIAL;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);
def Avg1 = average[-displace];

def Upper_Band = average[-displace] + shift[-displace];
def Lower_Band = average[-displace] - shift[-displace];


###### Bollinger Bands
input BBLength2 = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input bb_averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = BBLength2);
def MidLine = MovingAverage(bb_averageType, data = price[-displace], length = BBLength2);
def LowerBand = MidLine + Num_Dev_Dn * sDev;
def UpperBand = MidLine + Num_Dev_up * sDev;


###### Add Cloud
AddCloud(if UpperBand <= Upper_Band and LowerBand >= Lower_Band then BB_Upper else BB_Lower,  BB_Lower,  Color.YELLOW);
AddCloud( BB_Upper, BB_Lower, Color.LIGHT_RED );


###### Add Alert
def bull_cross = MACD_Line crosses above zero;
def bear_cross = MACD_Line crosses below zero;

Alert(bull_cross, "Bullish Breakout", Alert.BAR, Sound.Chimes);
Alert(bear_cross, "Bearish Breakdown", Alert.BAR, Sound.Bell);


################################################################
##########   RSI/STOCASTIC/MACD CONFLUENCE COMBO   #############
################################################################
#CHANGELOG
# 2020.10.27 V1.0 [USER=6343]@cos251[/USER] - Added RSI, StochasticSlow and MACD to same indicator; this will plot only MACD but also
#                   - calculates RSI and Sotchasit; Will shade the lower plot area of the following conditions are met
#                    Shade GREEN = RSI > 50 and SlowK > 50 and (macd)Value > (macd)Avg
#                    Shade RED = RSI < 50 and SlowK < 50 and (macd)Value < (macd)Avg         
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 5(not14) and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#CREDITS
# requesed by "[USER=4682]@Joseph Patrick 18[/USER]"
#LINK
# [URL]https://rockwell-files.s3.amazonaws.com/PXCompanionGuide2ndEd_cover.pdf[/URL]
# Markus Heikoetter who is the author of the Power X Strategy
# [URL]https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/[/URL]
#Edited by Chuck_E


def Value = MovingAverage(averageTypeMACD, close, fastLengthMACD) - MovingAverage(averageTypeMACD, close, slowLengthMACD);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);

plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignalMACD = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignalMACD = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignalMACD.SetHiding(!showBreakoutSignals);
DownSignalMACD.SetHiding(!showBreakoutSignals);

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(4);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

ZeroLine.SetDefaultColor(Color.RED);

UpSignalMACD.SetDefaultColor(Color.UPTICK);
UpSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

DownSignalMACD.SetDefaultColor(Color.DOWNTICK);
DownSignalMACD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


###### RSI    
input lengthRSI = 7;
input over_BoughtRSI = 70;
input over_SoldRSI = 30;
input averageTypeRSI = AverageType.EXPONENTIAL;


def NetChgAvg = MovingAverage(averageTypeRSI, price - price[1], lengthRSI);
def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(price - price[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);


###### Stochastic Slow      
input over_boughtSt = 80;
input over_soldSt = 20;
input KPeriod = 12;#5
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.WILDERS;
input showBreakoutSignalsStoch = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

def SlowK = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullD;


######  Check for signals > 50 and macd Value > Avg
def rsiGreen = if RSI >= 50 then 1 else Double.NaN;
def rsiRed = if RSI < 50 then 1 else Double.NaN;
def stochGreen = if SlowK >= 50 then 1 else Double.NaN;
def stochRed = if SlowK < 50 then 1 else Double.NaN;
def macdGreen = if Value > Avg1 then 1 else Double.NaN;
def macdRed = if Value < Avg1 then 1 else Double.NaN;


###### Shade areas based on criteria; adjust as needed 
AddCloud(if rsiGreen and stochGreen and macdGreen then Double.POSITIVE_INFINITY else Double.NaN, if rsiGreen and stochGreen then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_GREEN);
AddCloud(if rsiRed and stochRed and macdRed then Double.POSITIVE_INFINITY else Double.NaN, if rsiRed and stochRed then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED);


###### Variables    
def aggPeriod = GetAggregationPeriod();

input paintBars = yes;
input showRSMShade = no;
input tradetype = { "long", "short", default "both" };
input showTrendLabels = no;
input showIndLabels = no;
input rangeType = { default "ADR", "ATR" };
input plotADR = yes;
input showADRZones = no;
input showADRLabels = no;


###### Assign Price Color             
AssignPriceColor(if paintBars and RSI >= 50 and SlowK >= 50 and Value > Avg then Color.GREEN else if paintBars and RSI < 50 and SlowK < 50 and Value < Avg then Color.RED else if paintBars then Color.DARK_GRAY else Color.CURRENT);


#################################################################
############  BALANCE OF POWER TREND ############################
#################################################################
# Assembled by BenTen at useThinkScript.com
# Converted from [URL]https://www.tradingview.com/script/XldP1lmA/[/URL]


input EMA = 20;
input TEMA = 20;
input high_l = 0.1;
input low_l = -0.1;

def THL = If(high != low, high - low, 0.01);
def BullOpen = (high - open) / THL;
def BearOpen = (open - low) / THL;
def BullClose = (close - low) / THL;
def BearClose = (high - close) / THL;
def BullOC = If(close > open, (close - open) / THL, 0);
def BearOC = If(open > close, (open - close) / THL, 0);
def BullReward = (BullOpen + BullClose + BullOC) / 1;
def BearReward = (BearOpen + BearClose + BearOC) / 1;

def BOP = BullReward - BearReward;
def SmoothBOP = ExpAverage(BOP, EMA);
def xPrice = SmoothBOP;
def xEMA1 = ExpAverage(SmoothBOP, TEMA);
def xEMA2 = ExpAverage(xEMA1, TEMA);
def xEMA3 = ExpAverage(xEMA2, TEMA);
def nRes = 3 * xEMA1 - 3 * xEMA2 + xEMA3;

def SmootherBOP = nRes;
def s1 = SmoothBOP;
def s2 = SmootherBOP;
def s3 = SmootherBOP[2];


####### Vertical Lines
def short = s2 < s3 and s2[1] > s3[1];
def long = s2 > s3 and s2[1] < s3[1];

AddVerticalLine(short, close, Color.RED, Curve.SHORT_DASH);
AddVerticalLine(long, close, Color.GREEN, Curve.SHORT_DASH);

######  P/L Statement
input PandL_Label = Yes;

def orderDir = CompoundValue(1, if  s2 < s3 then 1 else if s2 > s3 then -1 else orderDir[1], 0);
def isOrder = orderDir crosses 0;

def orderCount = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then orderCount[1] + 1 else orderCount[1], 0);

def noBar = IsNaN(open[-1]);

def orderPrice = if isOrder then if noBar then close else open[-1] else orderPrice[1];
def profitLoss = if !isOrder or orderCount == 1
then 0 else if orderDir < 0 then orderPrice[1] - orderPrice else if orderDir > 0 then orderPrice - orderPrice[1] else 0;
def profitLossSum = CompoundValue(1, if IsNaN(isOrder) then 0 else if isOrder then profitLossSum[1] + profitLoss else profitLossSum[1], 0);
def orderWinners = CompoundValue(1, if IsNaN(isOrder) then orderWinners[1] else if orderCount > 1 and profitLoss > 0 then orderWinners[1] + 1 else orderWinners[1], 0);


###### Add Label
AddLabel(PandL_Label, orderCount + " orders (" + AsPercent(orderWinners / orderCount) + ") | P/L " + AsDollars ((profitLossSum / TickSize()) * TickValue()), if profitLossSum > 0 then Color.GREEN else if profitLossSum < 0 then Color.RED else Color.GRAY);



#------ End Balanced BB Breakout Indicator
 
Last edited by a moderator:
@cos251, I am not a coder, I am just now learning. I jumbled this indicator together from a few of my favorite indicators here on the forum. I was able to make it work and find it to be pretty dependable. It uses a lot of memory so I am sure it has some syntax errors and a few lines of code not being used.

I used the BOP indicator stratigy in connection with the indicator as a way to check profitability against timeframes to choose the most profitable time frame for trading what ever instrument you wish. As of now I tweet the settings once I find the optimal timeframe.

I was just hoping someone like yourself could take a quick look at it and tighten it up a notch or two. The market forecast could use a long term /mid term and short term lable, I am not sure how to do that and the Balance of Power is what is used for entry confirmation as of now. It could probably be linked to the macd,bolinger band, fvo, stocastic for a true signal that is in confluence. That would really be awesome. Any help at all in any capacity would be greatly appreciated.
@Chuck - can you shed a little light on this statement - "check profitability against timeframes to choose the most profitable time frame for trading"? How are you doing this exactly. Is this in real time? or through back testing? Just trying to understand how to look for improvements.

Personally, I like to have a series of checks to look for, sort of like a sequence of events to indicate direction and probability.

One initial recommendation would be to replace the Balance of Power Trend for something like an Inverse RSI or Stochastic. I personally like the IFT RSI signal. It is clear and cleans up the noise.

Let me know your thoughts.

Some screenshots below:
dg2jSFv.png


QlEfXGf.png
 
Last edited:
Status
Not open for further replies.

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
264 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