Full candle outside of Bollinger Band

kabira

Member
VIP
Hello All - I am using the following script and its giving me the close of the candle outside of the BB. How can I adjust it to get the full candle outside of BB.

close from 1 bars ago crosses above BollingerBands("average type" = "WEIGHTED")."UpperBand" from 1 bars ago
 
Solution
couldn't you just change it from close to low for upper band, or high for lower band?

Edit: sry nvm that might not work after re reading

Edit 2: I just tested this by modifying tos's built in BBCrossover study and it does work

here is the code I tested:
Code:
input length = 20;
input Std_Deviation = 2.0;
input crossingType = {default above, below};
input averageType = AverageType.SIMPLE;


def bollingerHigh = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).UpperBand;

def bollingerLow = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).LowerBand;

plot signalHigh = Crosses(low, bollingerHigh...
couldn't you just change it from close to low for upper band, or high for lower band?

Edit: sry nvm that might not work after re reading

Edit 2: I just tested this by modifying tos's built in BBCrossover study and it does work

here is the code I tested:
Code:
input length = 20;
input Std_Deviation = 2.0;
input crossingType = {default above, below};
input averageType = AverageType.SIMPLE;


def bollingerHigh = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).UpperBand;

def bollingerLow = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).LowerBand;

plot signalHigh = Crosses(low, bollingerHigh, crossingType == CrossingType.above);
signalHigh.DefineColor("Above", GetColor(1));
signalHigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

plot signalLow = Crosses(high, bollingerLow, crossingType == CrossingType.below);
signalLow.DefineColor("Below", GetColor(2));
signalLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
 
Last edited:
Solution
It worked perfect. Thank you so much.

Also similar type how can we get the same full candle outside of moving average 5EMA. (away from 5EMA) full candle outside not attaching to the EMA.
Thanks again.
 
NP, it was actually my first post on this forum so glad it was helpful.

the logic for your next question is the same as the first one, but I realized there was a slight error in my last script. If more than one candle in a row is outside the bollinger band only the first will be marked. you can change the last two statements to this if you want to fix it
Code:
plot signalHigh = low > bollingerHigh;
signalHigh.DefineColor("Above", GetColor(1));
signalHigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

plot signalLow = high < bollingerLow;
signalLow.DefineColor("Below", GetColor(2));
signalLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

here is an ema script, I changed the candle colors instead of plotting arrows this time. if you want arrows instead remove the last line and add the two statements from above and change bollingerHigh/bollingerLow to ema
Code:
input length = 5;

plot ema = ExpAverage(close, length);

AssignPriceColor(if low > ema then getColor(6) else if high < ema then getColor(5) else getColor(7));
 
Thank you so much again. Yes I saw that If more than one candle in a row is outside the bollinger band only the first will be marked. Thanks for fixing it . Also let me try the 5ema one.
 
Hello Babel - It worked. Thanks. Below is my BB startegy is there a way we can get alert on this.

Bollinger band with standard deviation = 1.5

when a candle is completely above the upper Bollinger band , that candle will be called a signal/alert candle.
Initiate a Sell trade when that alert candles low is broken.

when a candle is completely below the lower Bollinger band , that candle will be called a signal/alert candle.
Initiate a Buy trade when that alert candles high is broken.
 
Also how can I put the alert on the below

input length = 5;

plot ema = ExpAverage(close, length);

AssignPriceColor(if low > ema then getColor(6) else if high < ema then getColor(5) else getColor(7));

when a candle is completely above the ema5 , that candle will be called a signal/alert candle.
Initiate an alert when that alert candles low is broken.

when a candle is completely below the lower ema5 , that candle will be called a signal/alert candle.
Initiate an alert when that alert candles high is broken.
 

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