Find number of red candles after the market opened

rengagopal

Member
VIP
Hello,

I need a code to find out number of red candles [open > close] and total number of candles after the market has opened.

Thank you!!
 
Solution
Hello,

I need a code to find out number of red candles [open > close] and total number of candles after the market has opened.

Thank you!!

This might help with bubbles to track the accumlation of red candles during the day and a label option.

Screenshot-2023-02-26-160259.png
Code:
#Exampl_Red_Candle_Count_RTH

input showbubbles = yes;
input showlabel   = yes;
def red = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600) > 0)
          then 0
          else if SecondsFromTime(0930) >= 0 and
                  SecondsTillTime(1600) > 0 and open > close
          then red[1] + 1
          else red[1];

def all = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600)>0)
          then 0
          else if...
Hello,

I need a code to find out number of red candles [open > close] and total number of candles after the market has opened.

Thank you!!

This might help with bubbles to track the accumlation of red candles during the day and a label option.

Screenshot-2023-02-26-160259.png
Code:
#Exampl_Red_Candle_Count_RTH

input showbubbles = yes;
input showlabel   = yes;
def red = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600) > 0)
          then 0
          else if SecondsFromTime(0930) >= 0 and
                  SecondsTillTime(1600) > 0 and open > close
          then red[1] + 1
          else red[1];

def all = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600)>0)
          then 0
          else if SecondsFromTime(0930) >= 0 and
                  SecondsTillTime(1600) > 0
          then  all[1] + 1 
          else all[1];


AddChartBubble(showbubbles and SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0,
high * 1.0025,
"Red: " + red +
"\nRTH: " + all +
"\n%Red: \n" + AsPercent(red/all),
if open > close then Color.RED else color.gray, yes);


def redtoday = highestall(if GetDay() == GetLastDay() then red else Double.NaN);
def alltoday = if secondsfromTime(1600)<0 then all else highestall(all);

AddLabel(showlabel and GetDay() == GetLastDay(),
"Today: " + asprice(getyyyYMMDD()) +
" | Red: " + redtoday +
" | RTH: " + alltoday+
" | %Red: " + AsPercent(redtoday/alltoday),
if secondsfromTime(1600)<0 and open < close then color.gray else Color.RED);
 
Solution

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

This might help with bubbles to track the accumlation of red candles during the day and a label option.
This code works. But, If I use it on 5D 2Min chart, the 5th day is good, but all other days shows the accumulation of prior days. Example; 3rd day begining has 5th and 4th day's count also. Could you please help? How to use this in watchlist also.

Thank you!!
 
The following code is not producing any valid results. Please help!! Thank you!!

Code:
# This logic is to find out the TOTAL number of RED candles and
# the RED candles DOWN ratio at 0.25, 0.5 and Greater than 0.5% / Candle during market is OPEN.

DECLARE LOWER;

DEF RP1 = 0;
DEF RP2 = 0;
DEF RP3 = 0;

DEF OC_RATIO = ROUND(((OPEN / CLOSE)-1)*100,2);

def red = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600) > 0)
          then 0 ELSE (
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= 0.0 AND OC_RATIO < -0.25
                    THEN RED[1] + 1 AND RP1[1] + 1  AND RP3[1] AND RP2[1] ELSE
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= -0.25 AND OC_RATIO < -0.5
                    THEN RED[1] + 1 AND RP2[1] + 1  AND RP3[1] AND RP1[1] ELSE
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= -0.5
                    THEN RED[1] + 1 AND RP3[1] + 1  AND RP2[1] AND RP1[1] ELSE RED[1] AND RP3[1] AND RP2[1] AND RP1[1]);

ADDLABEL (YES, "TOTAL --> " + RED + "    RED01 --> " + RP1 + "    RED02 --> " + RP2 + "    RED03 --> " + RP3, COLOR.WHITE);
 
Last edited by a moderator:
The following code is not producing any valid results. Please help!! Thank you!!

Code:
# This logic is to find out the TOTAL number of RED candles and
# the RED candles DOWN ratio at 0.25, 0.5 and Greater than 0.5% / Candle during market is OPEN.

DECLARE LOWER;

DEF RP1 = 0;
DEF RP2 = 0;
DEF RP3 = 0;

DEF OC_RATIO = ROUND(((OPEN / CLOSE)-1)*100,2);

def red = if !(SecondsFromTime(0930) >= 0 and
               SecondsTillTime(1600) > 0)
          then 0 ELSE (
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= 0.0 AND OC_RATIO < -0.25
                    THEN RED[1] + 1 AND RP1[1] + 1  AND RP3[1] AND RP2[1] ELSE
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= -0.25 AND OC_RATIO < -0.5
                    THEN RED[1] + 1 AND RP2[1] + 1  AND RP3[1] AND RP1[1] ELSE
                IF SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 and OPEN <= CLOSE AND OC_RATIO <= -0.5
                    THEN RED[1] + 1 AND RP3[1] + 1  AND RP2[1] AND RP1[1] ELSE RED[1] AND RP3[1] AND RP2[1] AND RP1[1]);

ADDLABEL (YES, "TOTAL --> " + RED + "    RED01 --> " + RP1 + "    RED02 --> " + RP2 + "    RED03 --> " + RP3, COLOR.WHITE);


Thank you all!! I kind of fixed his with some compromise. Thank you again!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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