Scan for RSI above 70 more than 0 count today

hi please help with a code :
i'm looking to scan stock on 1 minute time scale has RSI more than 70 more than 0 time within today.


Code:
#

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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 scan = overbought >= 1 ;
 
hi please help with a code :
i'm looking to scan stock on 1 minute time scale has RSI more than 70 more than 0 time within today.


Code:
#

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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 scan = overbought >= 1 ;


i have no idea what this is supposed to mean. please elaborate.

....more than 0 time within today.....


your Plot statement is comparing a constant to a constant so it's always going to be true..
70 > 1

you would want something like this,
plot z = rsi > over_Bought;

then figure out another condition and add it to that formula with AND.
 

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

I'm looking for scanner to count the number of RSI cross from below 70 to above 70 on 1minute chart.

the red count is RSI count with no delay count , counting each time RSI cross above 70 as 1 count.

the yellow count is RSI count with a delay count. counting each RSI cross above 70 after 30 bars delays. (i think this is more difficult to code than red count)

yellow count is more realistic in trading but red is also good.

ticker : MNST, 2023 March 16, 1 minute chart
image.png
 
I haven't run this as a scan, but the following script will count the number of times RSI crosses above 70 within the current day and display the count in a label. Obviously, in the chart you posted above, it would count all eight. You will have to work on filtering the minor crosses out. I compare this to a technique known as 'debouncing' in terms of automation. You could do so with bar counting, time delays, combining with other parameters, or defining a minimum drop in RSI in order to again count a 70 level cross (looks like you understand that with your 30 bar delay).

Code:
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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;

def Active = GetDay() == GetLastDay(); #Today
def var = RSI crosses above 70;
def cumulative = if Active and !Active[1] then var else if Active then cumulative[1] + var else cumulative[1];
plot scan  = cumulative;

AddLabel (yes, "COUNT " +  (scan), color.dark_green  );
 
Last edited by a moderator:
I haven't run this as a scan, but the following script will count the number of times RSI crosses above 70 within the current day and display the count in a label. Obviously, in the chart you posted above, it would count all eight. You will have to work on filtering the minor crosses out. I compare this to a technique known as 'debouncing' in terms of automation. You could do so with bar counting, time delays, combining with other parameters, or defining a minimum drop in RSI in order to again count a 70 level cross (looks like you understand that with your 30 bar delay).

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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;

def Active = GetDay() == GetLastDay(); #Today
def var = RSI crosses above 70;
def cumulative = if Active and !Active[1] then var else if Active then cumulative[1] + var else cumulative[1];
plot scan = cumulative;

AddLabel (yes, "COUNT " + (scan), color.dark_green );

thank u . looking good.
i do up a RSI cross down version also.
how do i combine the 2 into 1 singular code to save space?

Code:
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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;

def Active = GetDay() == GetLastDay(); #Today
def var = RSI crosses below 30;
def cumulative = if Active and !Active[1] then var else if Active then cumulative[1] + var else cumulative[1];
plot scan = cumulative;

AddLabel (yes, "COUNT " + (scan), color.dark_red );
 
You will only be able to run a scan for one plot (up or down) at a time, but if you want it on your chart just add this to the end of your code.

def varLow = RSI crosses below 30;
def cumulativeLow = if Active and !Active[1] then varLow else if Active then cumulativeLow[1] + varLow else cumulativeLow[1];
plot scanLow = cumulativeLow;

AddLabel (yes, "COUNT " + (scanLow), color.dark_red );
 
I'm looking for scanner to count the number of RSI cross from below 70 to above 70 on 1minute chart.

the red count is RSI count with no delay count , counting each time RSI cross above 70 as 1 count.

the yellow count is RSI count with a delay count. counting each RSI cross above 70 after 30 bars delays. (i think this is more difficult to code than red count)

yellow count is more realistic in trading but red is also good.

ticker : MNST, 2023 March 16, 1 minute chart
image.png


i'm going to guess that this will end up being too complex for a scan.

you made 2 posts, and still didn't explain what needs to happen.

scans look for a condition.
counting occurances of something is a number, so half of a condition, half of what is needed for a scan.
what number do you wish to compare the count to, to provide a true output from a scan? 3, 6, 11, 25,....?

'delay count' is vague and doesn't describe what is desired.

The location of the numbers on your image aren't precise enough to tell us WHEN you want to assign a number.

if there are 3 crossings within 30 bars, do you want to find,
the first crossing?
or the last crossing?

what defines the Range of bars to look at, to find crossings?
from the current bar, 30 bars before it and 30 bars after it?
15 bars before current bar and 15 bars after it?
or something else?


"yellow count is more realistic in trading but red is also good."
red is what actually happened, so red is realistic, whatever that means. this sentence has no meaning.


look at the chart, and describe what has to happen, in short statements, using only words that describe actions or items on the chart.
bar, barnumber, open, high, low, close, crossing,
(ex. there is no delay on a chart , so don't use that word).
 
You will only be able to run a scan for one plot (up or down) at a time, but if you want it on your chart just add this to the end of your code.

def varLow = RSI crosses below 30;
def cumulativeLow = if Active and !Active[1] then varLow else if Active then cumulativeLow[1] + varLow else cumulativeLow[1];
plot scanLow = cumulativeLow;

AddLabel (yes, "COUNT " + (scanLow), color.dark_red );
hi how do i change the code to count on 9.30am to 4pm only? exclude extended hours works.
 
Last edited:
i'm going to guess that this will end up being too complex for a scan.

you made 2 posts, and still didn't explain what needs to happen.

scans look for a condition.
counting occurances of something is a number, so half of a condition, half of what is needed for a scan.
what number do you wish to compare the count to, to provide a true output from a scan? 3, 6, 11, 25,....?

'delay count' is vague and doesn't describe what is desired.

The location of the numbers on your image aren't precise enough to tell us WHEN you want to assign a number.

if there are 3 crossings within 30 bars, do you want to find,
the first crossing?
or the last crossing?

what defines the Range of bars to look at, to find crossings?
from the current bar, 30 bars before it and 30 bars after it?
15 bars before current bar and 15 bars after it?
or something else?


"yellow count is more realistic in trading but red is also good."
red is what actually happened, so red is realistic, whatever that means. this sentence has no meaning.


look at the chart, and describe what has to happen, in short statements, using only words that describe actions or items on the chart.
bar, barnumber, open, high, low, close, crossing,
(ex. there is no delay on a chart , so don't use that word).
sorry , i dont know how to quantify the exact thing i wanted.
but the code is working well from me.

thanks for your time :)
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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