Count number of close Crosses below adaptive while RSI > 55

Hello Usethink team,
I am trying for a script that can count number crosses below adaptive MA while RSI > 55 and plot accordingly if count is some number , egxample if count is 2 then arrorw yellow and count is >= 3 arrow Red,
I have tried the below but it created the arrow for every cross and it messes the chartOne

if u see the yellow arrow on every close below adaptive , thats what I want to get rid off , instead am looking to count those crosses and create a condtion if they sum up to some number

Code:
def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);
plot DnXCount2 = if DnXCount < 2 then DnXCount else double.nan;
DnXCount2.setPaintingStrategy(PaintingStrategy.BooLEAN_ARROW_DOWN);
DnXCount2.setDefaultColor(Color.Yellow);

plot DnXCount3 = if DnXCount >3 then DnXCount else double.nan;
DnXCount3.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DnXCount3.setDefaultColor(Color.RED);

1751152236900.png
 
Solution
Thank you @halcyonguy for the quick reply

the code does not mis much info, all I have used is the rsi and adaptive reference
Code:
def AdaptiveMARef = reference MovAvgAdaptive(OHLC4, 3, 34, 10);
def RSIRef = reference RSI(34, 70, 30, OHLC4);

def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);
plot DnXCount2 = if DnXCount < 2 then DnXCount else double.nan;
DnXCount2.setPaintingStrategy(PaintingStrategy.BooLEAN_ARROW_DOWN);
DnXCount2.setDefaultColor(Color.Yellow);

#plot DnXCount3 = if DnXCount >2 then DnXCount else double.nan;
#DnXCount3.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN)...
Hello Usethink team,
I am trying for a script that can count number crosses below adaptive MA while RSI > 55 and plot accordingly if count is some number , egxample if count is 2 then arrorw yellow and count is >= 3 arrow Red,
I have tried the below but it created the arrow for every cross and it messes the chartOne

if u see the yellow arrow on every close below adaptive , thats what I want to get rid off , instead am looking to count those crosses and create a condtion if they sum up to some number

Code:
def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);
plot DnXCount2 = if DnXCount < 2 then DnXCount else double.nan;
DnXCount2.setPaintingStrategy(PaintingStrategy.BooLEAN_ARROW_DOWN);
DnXCount2.setDefaultColor(Color.Yellow);

plot DnXCount3 = if DnXCount >3 then DnXCount else double.nan;
DnXCount3.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DnXCount3.setDefaultColor(Color.RED);

don't post partial code.
we have to guess and add code to make it work, and it won't match what you are seeing.

over what period of bars do you want to count crosses?
all the crosses on the chart?
all crosses in a day?
??


there will never be 2 cross belows in a row , so , DnXCount will always be 0 or 1
def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);

you need to change your counting formula

could use .AssignValueColor( ) after a plot, and put several if-thens inside it, to pick different colors.
 
don't post partial code.
we have to guess and add code to make it work, and it won't match what you are seeing.

over what period of bars do you want to count crosses?
all the crosses on the chart?
all crosses in a day?
??


there will never be 2 cross belows in a row , so , DnXCount will always be 0 or 1
def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);

you need to change your counting formula

could use .AssignValueColor( ) after a plot, and put several if-thens inside it, to pick different colors.
Thank you @halcyonguy for the quick reply

the code does not mis much info, all I have used is the rsi and adaptive reference
Code:
def AdaptiveMARef = reference MovAvgAdaptive(OHLC4, 3, 34, 10);
def RSIRef = reference RSI(34, 70, 30, OHLC4);

def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);
plot DnXCount2 = if DnXCount < 2 then DnXCount else double.nan;
DnXCount2.setPaintingStrategy(PaintingStrategy.BooLEAN_ARROW_DOWN);
DnXCount2.setDefaultColor(Color.Yellow);

#plot DnXCount3 = if DnXCount >2 then DnXCount else double.nan;
#DnXCount3.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#DnXCount3.setDefaultColor(Color.RED);


Like that

As you can see above when I do > 2 those arrows disappear and when < 2 every cross plotted
 
Thank you @halcyonguy for the quick reply

the code does not mis much info, all I have used is the rsi and adaptive reference
Code:
def AdaptiveMARef = reference MovAvgAdaptive(OHLC4, 3, 34, 10);
def RSIRef = reference RSI(34, 70, 30, OHLC4);

def AdapDnX = if RSIRef > 55 within 13 bars and close crosses below AdaptiveMARef then 1 else 0;
def DnXCount = CompoundValue(1, if AdapDnX then DnXCount[1] + 1 else 0, 0);
plot DnXCount2 = if DnXCount < 2 then DnXCount else double.nan;
DnXCount2.setPaintingStrategy(PaintingStrategy.BooLEAN_ARROW_DOWN);
DnXCount2.setDefaultColor(Color.Yellow);

#plot DnXCount3 = if DnXCount >2 then DnXCount else double.nan;
#DnXCount3.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#DnXCount3.setDefaultColor(Color.RED);


Like that

As you can see above when I do > 2 those arrows disappear and when < 2 every cross plotted
This study both plots and counts the RSI's.

The image shows the study added to both the upper and lower charts. The upper is only showing the signal, and the lower only the signal_count.


Code:
input length = 14;
input crossingType = {default below, above};
input threshold = 55;
input averageType = AverageType.WILDERS;

def sig = crosses(RSI(length=length, averageType=averageType).RSI, threshold, crossingType == CrossingType.below);

plot signal = sig;

def sig_count = if barnumber() == 1 then 0 else if sig then sig_count[1] +1 else sig_count[1];

plot signal_count = sig_count;

RSI Count.jpg
 
Solution
I am trying to count those number of crosses above /below adaptive Moving average while RSI is > 55 and create a condition based on those numbers like if the crosse happens twice then warning and if 3 the plot arrow, I hope I made it clear what am looking for, Thank you for all the support,
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
467 Online
Create Post

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