Bollinger Band with RSI for Bullish and Bearish Signals


Category:
0
0

Hi Pete

I am trying to put together an indicator to signal bullish/Bearish Bullinger Band with RSI signal. The code is below:

 Editors Note: Here are the specifications the author of this post was trying to achieve:

“I want the scan to find stocks where the close of the candle crosses back above the lower Bollinger Band. I also need to have the RSI in oversold condition.”

“Oh yeah, one last thing. I would like to include the ForceIndex. I want to find where the ForceIndex is above the zero line, but the current bar’s ForceIndex is greater than it’s previous value times a multiplier of 1.5”

input length = 20;
input num_devs_dn = 2.0;
input bollinger_price = close;
input lower_band_price = close;def value = Average(bollinger_price, length) - num_devs_dn * StDev(bollinger_price, length);input RSIlength = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = yes;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
plot condition = Lower_band_price[1] crosses above value[1] and RSI[1] <= highest(OverSold[1],2) ;

It’s however seems not working properly. Appreciate if you could have a look and help me with it.

Many Thanks in Advance.

Regards

Ali

Marked as spam
Posted by (Questions: 6, Answers: 10)
Asked on April 30, 2018 8:29 pm
314 views
0
Private answer

Until you explain exactly what you expect the code to be doing we really can’t help you with your code. Bollinger Band and RSI. That does not tell us anything about how each of these are intended to form the signals your code is supposed to identify.

Having said that, the combination of Bollinger Bands and RSI is EXTREMELY common. This topic was covered in detail in our video: Thinkorswim AutoTrade Almost

Be sure to check out that video. You are likely to find the code you are trying to write has already been done and published.

Marked as spam
Posted by (Questions: 37, Answers: 4090)
Answered on April 30, 2018 8:42 pm
0
Hi Pete I have further worked it and the code looks like below (for Bullish): input length = 20; input num_devs_dn = 2.0; input bollinger_price = close; input lower_band_price = close; def value = Average(bollinger_price, length) – num_devs_dn * StDev(bollinger_price, length); input RSIlength = 5; input over_Bought = 50; input over_Sold = 50; input price = close; input averageType = AverageType.WILDERS; input showBreakoutSignals = yes; def NetChgAvg = MovingAverage(averageType, price – price[1], length); def TotChgAvg = MovingAverage(averageType, AbsValue(price – price[1]), length); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSI = 50 * (ChgRatio + 1); def OverSold = over_Sold; def OverBought = over_Bought; plot condition =lower_band_price[1] crosses above value[1] and high[1] > value[1] and RSI[1]<=Oversold[1]; It is to capture a reversal signal from lower band with oversold RSI signal. I have watched the AutoTrade Almost video and learnt a lot but still appreciate your thoughts on the above script. It seems I getting there! Many thanks. Regards Ali
( at April 30, 2018 10:25 pm)
0

Again, I am not going to try to interpret your intentions from reading your code. That is a sure-fire way to get things wrong. I need you to state in clear and precise terms the exact pattern of each indicator you are trying to code. When presenting your original question, a screenshot marked up showing these signals would have lead to an immediate solution.

So in summary, I have yet to see you express the exact specifications for the signal you are trying to code. Until I have the exact specifications, I have no grounds from which to examine your code and make corrections.

This:
“It is to capture a reversal signal from lower band with oversold RSI signal.”

Is lacking many details. And could be easily constructed using the condition wizard. No coding knowledge required.

( at May 1, 2018 8:12 am)
0

Hi Pete
I finally manged to get the script working, and respond to the signal I was looking for. As I mantioned I am in the learning curve with this and trying few things even simple.
anyway, Thanks for your time.
Regards
Ali

( at May 1, 2018 11:50 pm)
0

What a shame. Without a clear description of what you were trying to achieve, and without the final code that did the job….. how is this post going to benefit other viewers? I will have to delete this question because this post provides no useful benefit to our viewing audience.

( at May 2, 2018 7:49 am)
0

Hi Pete
It wasn’t my intention to give any impression whatsoever that I am not willing to share. I just wanted to stop disturbing…
I have continued playing with the script (still novice in scripting!) and now trying to add FI Force Index to scan price and volume by 50% up from previous day in positive territory. with the new feature it is not there yet, so appreciate if you have a look and let me know if you can help the code to work:

input length = 20;
input num_devs_dn = 2.0;
input bollinger_price = close;
input lower_band_price = close;

def value = Average(bollinger_price, length) – num_devs_dn * StDev(bollinger_price, length);

input RSIlength = 5;
input over_Bought = 50;
input over_Sold = 50;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = yes;

def NetChgAvg = MovingAverage(averageType, price – price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price – price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;

input FIlength = 13;
Input FIMultiplier = 1.5;

def FI = ExpAverage(data = (close – close[1]) * volume, length);

def ZeroLine = 0;

def FI_Uptrend = (FI > (FI[1]*FIMultiplier))>zeroline;

Plot scan = lower_band_price[1] crosses above value[1] and high[1]> Value[1] and FI_Uptrend and (RSI

( at May 3, 2018 7:14 am)
0

The error is here: def FI_Uptrend = (FI > (FI[1]*FIMultiplier))>zeroline;

The correction is here: def FI_Uptrend = FI > FI[1] * FIMultiplier and FI > zeroline;

( at May 3, 2018 7:40 am)
0

The issue is not about whether you were willing the share the final result. My issue is how does this benefit our viewing audience. When they read your original question they do not have a clue what goal you are trying to achieve with this code. After asking numerous times for you to clearly state the goals you intend for this code I have still not seen you state them. That is my issue.

Pretend you are searching for a solution that involves Bollinger band and RSI. Your search leads you to this very post. The only description given is this:

“I am trying to put together an indicator to signal bullish/Bearish Bullinger Band with RSI signal”

What does the visitor to this post expect to find, specifically? What is bullish/bearish Bollinger Band? (do you suppose there is only one way of defining that?). What is “RSI Signal”? That is completely meaningless. That is my issue.

To salvage this post, I will edit your original question by clearly stating the goals achieved by your final piece of code.

( at May 3, 2018 7:51 am)
0

Please do so as you wish, and hope others will benefit from it and give me their advice/help to make it better. In mean time I realised you have put the very first version of the code which don’t have the FI in it. In order to tally with your edited statement you must put the latest code that I have posted.

Thanks

Ali

( at May 3, 2018 4:27 pm)