Upper Dots RVI Alerts

Chuck

Well-known member
This is a great study, works great on tick charts, but has graphic errors on regular time frames. Maybe one of you guys can easily fix this. Any help would be appreciated.

Code:
declare upper;

input ArrowLimit = 124;

input length = 14;
input ob  = 80;
input ob2 = 0;
input os = 20;
input os2 = 0;

def highPrice = StDev(high, 10);
def lowPrice = StDev(low, 10);

def highAvgUp = ExpAverage(if high > high[1] then highPrice else 0, length);
def highAvgDown = ExpAverage(if high < high[1] then highPrice else 0, length);

def lowAvgUp = ExpAverage(if low > low[1] then lowPrice else 0, length);
def lowAvgDown = ExpAverage(if low < low[1] then lowPrice else 0, length);

def highRVI = 100 - 100 / (1 + highAvgUp / highAvgDown);
def lowRVI = 100 - 100 / (1 + lowAvgUp / lowAvgDown);

plot RVI = (highRVI + lowRVI) / 2;
plot OverBought = ob;
plot OverBoughtmore = ob2;
plot OverSold = os;
plot OverSoldmore = os2;

RVI.DefineColor("OverBought", GetColor(5));
RVI.DefineColor("Normal", GetColor(7));
RVI.DefineColor("OverSold", GetColor(1));
RVI.AssignValueColor(if RVI > OverBought then RVI.Color("OverBought") else if RVI < OverSold then RVI.Color("OverSold") else RVI.Color("Normal"));

OverBought.SetDefaultColor(CreateColor(175, 5, 25));
OverSold.SetDefaultColor(CreateColor(5, 175, 25));

input over_bought = 80.0;
input over_sold = 20.0;
input percentDLength = 3;
input percentKLength = 14;
input AudibleAlert = yes;



def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;
def avgrel = Average(Average(rel_diff, percentDLength), percentDLength);
def avgdiff = Average(Average(diff, percentDLength), percentDLength);
def SMIData = (avgrel / (avgdiff / 2) + 1) * 50;

def isLow = If (SMIData < SMIData[-1] and SMIData < SMIData[1], 1, 0);
def isHigh =   If (SMIData > SMIData[-1] and SMIData > SMIData[1], 1, 0);

rec prevLowSMI = CompoundValue(1, If(isLow[1], SMIData[1], prevLowSMI[1]), 0);
rec prevHighSMI = CompoundValue(1, If(isHigh[1], SMIData[1], prevHighSMI[1]), 0);

rec prevLow =  CompoundValue(1, If(isLow[1], low, prevLow[1]), low);
rec prevHigh =  CompoundValue(1, If(isHigh[1], high, prevHigh[1]), high);

def barlimit = If(IsNaN(open[-ArrowLimit]) && !IsNaN(open), yes, no);

def positiveDivergenceReg = If (SMIData > prevLowSMI and low < prevLow, 1, 0);
def positiveDivergenceHid = If (SMIData < prevLowSMI and low > prevLow, 1, 0);

plot posDiv = If(barlimit and isLow and (positiveDivergenceReg or positiveDivergenceHid), low, Double.NaN);
posDiv.AssignValueColor(if positiveDivergenceReg then Color.GREEN else Color.GREEN);
posDiv.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
posDiv.SetLineWeight(2);


def negativeDivergenceReg =  If (SMIData < prevHighSMI and high > prevHigh, 1, 0);
def negativeDivergenceHid = If (SMIData > prevHighSMI and high < prevHigh, 1, 0);

plot negDiv = If(barlimit and isHigh and ( negativeDivergenceReg or negativeDivergenceHid), high, Double.NaN);
negDiv.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
negDiv.AssignValueColor(if negativeDivergenceReg then Color.RED else Color.LIGHT_RED);
negDiv.SetLineWeight(2);



plot AvgSMI = Average(SMIData, percentDLength);
AvgSMI.SetDefaultColor(Color.GRAY);


plot SMI = SMIData;
SMI.AssignValueColor(if SMI > SMI[1] then Color.BLUE else Color.RED);
SMI.SetLineWeight(2);


plot highdots = if RVI >= over_bought then high else Double.NaN;
plot lowdots = if RVI <= over_sold then low else Double.NaN;
highdots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
highdots.SetDefaultColor(Color.RED);
highdots.SetLineWeight(1);
lowdots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
lowdots.SetDefaultColor(Color.GREEN);
lowdots.SetLineWeight(1);

# Sound alerts

Alert(AudibleAlert and posDiv[1], "Pressure Bullish", Alert.BAR, Sound.Chimes);
Alert(AudibleAlert and negDiv[1], "Pressure Bearish", Alert.BAR, Sound.Bell);
 

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

@Chuck What's the issue with regular time frame?
Lines go all over the screen on my system. Verticals ...slightly angled lines everywhere. When I use it on a 512 tick chart it works great. 2 min day chart or 5,10 etc.... lines everywhere. It may be some stupid error on my part... I can’t figure it out.
 
Lines go all over the screen on my system. Verticals ...slightly angled lines everywhere. When I use it on a 512 tick chart it works great. 2 min day chart or 5,10 etc.... lines everywhere. It may be some stupid error on my part... I can’t figure it out.
Check that you have "Fit studies" selected on the vertical (price) axis. You can set it to the Left Axis as well, if crossovers with price are unimportant.

happy trading
-mashume
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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