Combine William% and RSI

GpInvest

New member
Hi everyone
I am trying to write a basic indicator code that implement William% and RSI to find deep and top of the market this is the code that I was able to write, but it does not work so It is clearly wrong.
can anyone be so nice to check it and help me out?
thanks

Code:
# buy the deep
input length = 14;
input oversold = 30;
input overbought = 70;
input WprPeriod = 24;

# WPR Indicator
def HH = highest(high, WprPeriod);
def LL = lowest(low, WprPeriod);
def WPR = (HH - close) / (HH - LL) * -100;

# RSI Indicator
def NetChgAvg = WildersAverage(close - close[1], length);
def TotChgAvg = WildersAverage(AbsValue(close - close[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);

# Buy/Sell Signals
def buySignal = if RSI crosses above oversold and WPR > -20 then 1 else 0;
def sellSignal = if RSI crosses below overbought and WPR < -80 then 1 else 0;

# Plot Signals
plot buy = if buySignal then low - 2.5 else Double.NaN;
Buy.setdefaultColor(color.dark_GREEN);
Buy.hidetitle();
plot sell = if sellSignal then high + 2.5 else Double.NaN;
sell.setDefaultColor(color.red);
Sell.hidetitle();
buy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
@GpInvest
Not sure where you expect it to signal because the conditions, as written, never happen.
I rewrote it as a lower study to help you visualize.
59dg2kk.png

I think you may have gotten your levels swapped, but depending on which one produces different results.
 

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

@GpInvest
Not sure where you expect it to signal because the conditions, as written, never happen.
I rewrote it as a lower study to help you visualize.
59dg2kk.png

I think you may have gotten your levels swapped, but depending on which one produces different results.
what's the script for the re-wrote lower study? could you share?
 
@cswu1211
Ruby:
declare lower;
# buy the deep
input length = 14;
input oversold = 30;
input overbought = 70;
input WprPeriod = 24;

plot OS = oversold;
plot OB = overbought;

# WPR Indicator
def HH = highest(high, WprPeriod);
def LL = lowest(low, WprPeriod);
plot WPR = (HH - close) / (HH - LL) * -100;
plot WPRU = -20;
plot WPRL = -80;

# RSI Indicator
def NetChgAvg = WildersAverage(close - close[1], length);
def TotChgAvg = WildersAverage(AbsValue(close - close[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);

# Buy/Sell Signals
def buySignal = if RSI crosses above oversold and WPR > -20 then 1 else 0;
def sellSignal = if RSI crosses below overbought and WPR < -80 then 1 else 0;

# Plot Signals
plot buy = if buySignal then low - 2.5 else Double.NaN;
Buy.setdefaultColor(color.dark_GREEN);
Buy.hidetitle();
plot sell = if sellSignal then high + 2.5 else Double.NaN;
sell.setDefaultColor(color.red);
Sell.hidetitle();
buy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
@cswu1211
Ruby:
declare lower;
# buy the deep
input length = 14;
input oversold = 30;
input overbought = 70;
input WprPeriod = 24;

plot OS = oversold;
plot OB = overbought;

# WPR Indicator
def HH = highest(high, WprPeriod);
def LL = lowest(low, WprPeriod);
plot WPR = (HH - close) / (HH - LL) * -100;
plot WPRU = -20;
plot WPRL = -80;

# RSI Indicator
def NetChgAvg = WildersAverage(close - close[1], length);
def TotChgAvg = WildersAverage(AbsValue(close - close[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);

# Buy/Sell Signals
def buySignal = if RSI crosses above oversold and WPR > -20 then 1 else 0;
def sellSignal = if RSI crosses below overbought and WPR < -80 then 1 else 0;

# Plot Signals
plot buy = if buySignal then low - 2.5 else Double.NaN;
Buy.setdefaultColor(color.dark_GREEN);
Buy.hidetitle();
plot sell = if sellSignal then high + 2.5 else Double.NaN;
sell.setDefaultColor(color.red);
Sell.hidetitle();
buy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Tks a lot. It seems that the Signals doesn't come out with results. Maybe a scan will help.
 
@cswu1211
As I stated in my previous post, the OPs conditions for buy and sell signals as written never happen and suggest they had gotten one of the sets of levels swapped. OP has never responded with where they expected the study to signal. If we knew that, it could be fixed.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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