IBD Distribution Days Study for ThinkOrSwim

Dist days have been stacking up. How exactly do we know when to restart the counter? Is there a fall threshold?
When IBD declares market in correction, the d day counts are not used by IBD until a follow-through day (i.e. 2nd confirmation day) occurs which changes market outlook to uptrend. However this script keeps counting D days until you specify a new 2nd confirmation day. When this occurs, the D day count in the script is intended to be in sync with IBD again.
BTW, IBD already shifted risk management level as it downgraded market outlook to under-pressure.
 
When IBD declares market in correction, the d day counts are not used by IBD until a follow-through day (i.e. 2nd confirmation day) occurs which changes market outlook to uptrend. However this script keeps counting D days until you specify a new 2nd confirmation day. When this occurs, the D day count in the script is intended to be in sync with IBD again.
BTW, IBD already shifted risk management level as it downgraded market outlook to under-pressure.
FYI, a cluster of breadth thrusts from the indicator I shared have fired off in the last week
 
FYI, a cluster of breadth thrusts from the indicator I shared have fired off in the last week
Nice(y) I guess I need to spend some time studying the indicators you mentioned:D
What is the trading time frame typically used for your thrust indicators?

On the distribution day count front, SPX generated a red warning on 9/10/2020 while NASDAQ generated a red warning on 9/16/2020. However, I believe there was a discrepancy on NASDAQ D day on 9/17 between this script and IBD. IBD counted a Nasdaq distribution but the script did not. This is because of the difference of the volume data provided by TOS. Overall, I believe Dist Day counts from the script and IBD are in red alarming area.
 
Nice(y) I guess I need to spend some time studying the indicators you mentioned:D
What is the trading time frame typically used for your thrust indicators?

On the distribution day count front, SPX generated a red warning on 9/10/2020 while NASDAQ generated a red warning on 9/16/2020. However, I believe there was a discrepancy on NASDAQ D day on 9/17 between this script and IBD. IBD counted a Nasdaq distribution but the script did not. This is because of the difference of the volume data provided by TOS. Overall, I believe Dist Day counts from the script and IBD are in red alarming area.
For breadth thrusts, you always want to use daily. In a nutshell, they're basically looking for weak buying pressure switching to extremely high buying pressure in a short period of time. It's used to check if a new bull market is starting. So using this with your ibd dist days, should be a damn good combo

As for the distribution days popping up, that's where things get weird. It sounds like IBD is counting the down days, but may not be counting the big jumps up in buying pressure? 2020 is just ridiculous. Nobody knows anything haha
 
For breadth thrusts, you always want to use daily. In a nutshell, they're basically looking for weak buying pressure switching to extremely high buying pressure in a short period of time. It's used to check if a new bull market is starting. So using this with your ibd dist days, should be a damn good combo

As for the distribution days popping up, that's where things get weird. It sounds like IBD is counting the down days, but may not be counting the big jumps up in buying pressure? 2020 is just ridiculous. Nobody knows anything haha
IBD uses distribution days as one of the topping indicators and the follow-through (2nd confirmation) day as the bottom to upturn indicator. Their market outlook is intended for the intermediate to long term.
 
The market had a 2nd confirmation day on 9/30 Wed. given by the rise of Dow Index of 1.2% /w higher volume. So the DistributionRstDay at the user input should be reset to 20200930 for this indicator. The new dist day count should be 1 as of today.

I found and fixed 2 bugs as a result of this new reset date which happened to be at the end of a month.

1). The vertical line representing the reset day could not be displayed if the next trading day is the start of a new month or after a holiday. The temporary fix is provided below.
# Show D-Day reset line at the next trading day after the reset date
# If D-Day is on Friday, then show it on next Monday
#AddVerticalLine(if (GetDayOfWeek(distributionRstDay) < 5) and
# (GetYYYYMMDD() == distributionRstDay + 1) then yes
# else if (GetDayOfWeek(distributionRstDay) == 5) and
# (GetYYYYMMDD() == distributionRstDay + 3) then yes
# else no,
# "2ndCnfm", Color.GREEN, Curve.MEDIUM_DASH);
# Show D-Day reset line at the reset date input by user
# It appears at the left side of the volume bar
AddVerticalLine( if (GetYYYYMMDD() == distributionRstDay ) then yes
else no,
"2ndCnfm", Color.GREEN, Curve.MEDIUM_DASH);
The above change makes the vertical line at the left side of the bar of the 2nd confirmation day.

2). The old stall-day count was included in the total new distribution day count due to a coding bug. Fix is shown below.
def totalNdDays = newDistDays+newStallDays;
 
The market had a 2nd confirmation day on 9/30 Wed. given by the rise of Dow Index of 1.2% /w higher volume. So the DistributionRstDay at the user input should be reset to 20200930 for this indicator. The new dist day count should be 1 as of today.

I found and fixed 2 bugs as a result of this new reset date which happened to be at the end of a month.

1). The vertical line representing the reset day could not be displayed if the next trading day is the start of a new month or after a holiday. The temporary fix is provided below.
# Show D-Day reset line at the next trading day after the reset date
# If D-Day is on Friday, then show it on next Monday
#AddVerticalLine(if (GetDayOfWeek(distributionRstDay) < 5) and
# (GetYYYYMMDD() == distributionRstDay + 1) then yes
# else if (GetDayOfWeek(distributionRstDay) == 5) and
# (GetYYYYMMDD() == distributionRstDay + 3) then yes
# else no,
# "2ndCnfm", Color.GREEN, Curve.MEDIUM_DASH);
# Show D-Day reset line at the reset date input by user
# It appears at the left side of the volume bar
AddVerticalLine( if (GetYYYYMMDD() == distributionRstDay ) then yes
else no,
"2ndCnfm", Color.GREEN, Curve.MEDIUM_DASH);
The above change makes the vertical line at the left side of the bar of the 2nd confirmation day.

2). The old stall-day count was included in the total new distribution day count due to a coding bug. Fix is shown below.
def totalNdDays = newDistDays+newStallDays;
My mannnn! Thanks so much for the update
 
My mannnn! Thanks so much for the update
Did you do a comparison by chance of using the Nasdaq vs the NYSE for observing dist days? I'm curious if that may be better considering how heavy the QQQ lead has been this year.
 
Did you do a comparison by chance of using the Nasdaq vs the NYSE for observing dist days? I'm curious if that may be better considering how heavy the QQQ lead has been this year.
I haven't done that although IBD does use Nasdaq as the main index. I think they give Nasdaq a little more weight in their market outlook. I don't know how to quantify the weight and apply in a script.

On the other hand, I did some tests comparing Nasdaq vs SPX, mostly for the last 10 years, considering nasdaq is more aggressive (risk on) index. I added a Nasdaq bullish turning signal in my SPX chart, based on the following observation:

When SPX is in a downtrend and makes a new low while COMP performs better in last 4 days comparatively, the SPX is likely to turn up in a day or two.
 
According to IBD:

One Red Flag That A Follow-Through May Fail

Follow-through signals are more likely to fail if distribution days occur in the first few days of a new uptrend. This is one key red flag.

We had a couple of D-days as of today, so I'd like to make my distribution warning color to be red. But the following code has some bugs and I could not display anything at my SPX volume pane.

It's probably something obvious for an skilled eye. Any comments about the issue in the code below are appreciated.

Code:
#-------------------------------------------------------------------------------------
# Follow-through signals (FTD) are more likely to fail if distribution days
# occur in the first few days of a new uptrend. This is one key red flag.
# Quantification in script is implemented with a concept of critical score (critScore):
#   critScore = 3 for the 1st 5 days after FTD
#   critScore = 2 on the 6th, critScore = 1 on 7th day, critScore = 0 after 7th day
#   Total Distribution days = critScore + regular D-day count
#   critScore is used only if there is at least one D-day in the 1st 5th day after FTD        
#-------------------------------------------------------------------------------------

def daysAfterFTD = CountTradingDays(distributionRstDay, GetYYYYMMDD());
def critScore = if daysAfterFTD <= 5 then 3 else
                         if daysAfterFTD <= 6 then 2 else
                         if daysAfterFTD <= 7 then 1 else 0;

def totalNdDaysC = totalNdDays + if totalNdDays > 0 then critScore else 0;

# Actual distribution day count is shown but color depends on totalNdDaysC
addLabel(yes, "NewDdays =" + concat("",totalNdDays ),
         if totalNdDaysC <=2 then Color.Green
         else if totalNdDaysC <= 4 then Color.ORANGE
         else Color.RED);
 
According to IBD:

One Red Flag That A Follow-Through May Fail

Follow-through signals are more likely to fail if distribution days occur in the first few days of a new uptrend. This is one key red flag.

We had a couple of D-days as of today, so I'd like to make my distribution warning color to be red. But the following code has some bugs and I could not display anything at my SPX volume pane.

It's probably something obvious for an skilled eye. Any comments about the issue in the code below are appreciated.

Code:
#-------------------------------------------------------------------------------------
# Follow-through signals (FTD) are more likely to fail if distribution days
# occur in the first few days of a new uptrend. This is one key red flag.
# Quantification in script is implemented with a concept of critical score (critScore):
#   critScore = 3 for the 1st 5 days after FTD
#   critScore = 2 on the 6th, critScore = 1 on 7th day, critScore = 0 after 7th day
#   Total Distribution days = critScore + regular D-day count
#   critScore is used only if there is at least one D-day in the 1st 5th day after FTD      
#-------------------------------------------------------------------------------------

def daysAfterFTD = CountTradingDays(distributionRstDay, GetYYYYMMDD());
def critScore = if daysAfterFTD <= 5 then 3 else
                         if daysAfterFTD <= 6 then 2 else
                         if daysAfterFTD <= 7 then 1 else 0;

def totalNdDaysC = totalNdDays + if totalNdDays > 0 then critScore else 0;

# Actual distribution day count is shown but color depends on totalNdDaysC
addLabel(yes, "NewDdays =" + concat("",totalNdDays ),
         if totalNdDaysC <=2 then Color.Green
         else if totalNdDaysC <= 4 then Color.ORANGE
         else Color.RED);
I think I found an issue in counttradingdays() and have a resolutions now.

The following code worked in my script. But change "101" to "103" corrupts the routine.

def yearstart = GetYear() * 10000 + 101;
AddLabel(yes, CountTradingDays(yearstart, GetYYYYMMDD()) +
" trading days since year start" + " y=" + yearstart);

So I used barnumber() to achieve the same purpose.

Code:
#-------------------------------------------------------------------------------------
# Follow-through signals (FTD) are more likely to fail if distribution days
# occur in the first few days of a new uptrend. This is one key red flag.
# Quantification in script is implemented with a concept of critical score (critScore):
#   critScore = 3 for the 1st 5 days after FTD
#   critScore = 2 on the 6th, critScore = 1 on 7th day, critScore = 0 after 7th day
#   Total Distribution days = critScore + regular D-day count
#   critScore is used only if there is at least one D-day in the 1st 5th day after FTD         
#-------------------------------------------------------------------------------------

def ftdBar = if GetYYYYMMDD() == distributionRstDay then barnumber() else 0;
def lastFtdBar = highestall(ftdBar);
def daysAfterFTD = lastBar - lastFtdBar;

def critScore = if daysAfterFTD <= 0 then 0 else
                if daysAfterFTD <= 5 then 3 else
                if daysAfterFTD <= 6 then 2 else
                if daysAfterFTD <= 7 then 1 else 0;

def totalNdDaysC = totalNdDays + if totalNdDays > 0 then critScore else 0;
#addLabel(yes, "critScore =" + concat("", critScore) + concat("DayC", totalNdDaysC), Color.GRAY);

# Actual distribution day count is shown but color depends on totalNdDaysC
addLabel(yes, "NewDdays =" + concat("",totalNdDays ),
         if totalNdDaysC <=2 then Color.Green
         else if totalNdDaysC <= 4 then Color.ORANGE
         else Color.RED);

So today is 5th day after FTD, I have a red warning because of 2 distribution days. Tomorrow, it should become yellow and then normal (green) if there are no more distributions in the next 2 days.
 
Has anyone done any scripting around IBD Follow Through Day?
If you find any FTD script, please let us know.

To help identify FTD, I added some codes to the end of my existing script. Hope it will be useful.

The new code is designed to show the 1st day of rally during a market correction, including the pink rally day which may be hard to recognize sometimes as in case on 2020-10-30 for SPX. The 1st rally day is used to starting counting for valid FTD.

Currently, the following code shows two 1st rally days (9-24 and 10-30) for the last 6 months as green chart bubbles on top of the volume bars for SPX. It may require additional tests to be bug-free. You'll probably need to adjust the definitions from 8% drop to other percentages to be more in line with IBD market outlook or create other codes to determine the market correction.

Code:
# Add an indication of 1st rally day to start FTD count
# in a market correction period
# pink rally day is a day satisfying the following conditions:
# 1). Close above ½ of daily TRUE range and below prior day close
# 2). Low is the lowest during the market correction,
#     including future lows if available

# resolution of each 1st rally day is set to about 2 weeks
def rDayInterval = round(25/2, 0);

def futureLow = if isNaN(prLo[-rDayInterval]) then futureLow[1]
                else prLo[-rDayInterval];
def futureCls = if isNaN(cls[-rDayInterval]) then futureCls[1]
                else cls[-rDayInterval];

# market correction is currently defined as down 8% from top
def mktCr    = prLo <= highest(high, 25) * .92;
def prRng    = TrueRange(prHi, cls, prLo); #prHi - prLo;
def pinkRday = cls > (prLo + (prHi - prLo)/2) and cls < cls[1] and
               prLo <= lowest(prLo[1],rDayInterval) and
               prLo <= lowest(futureLow, rDayInterval);
def realRday = cls > cls[1] and
               cls <= lowest(futureCls, rDayInterval) and
               cls[1] <= lowest(cls[1], rDayInterval) and
               !pinkRday[1];              
def RallyDay1 = (mktCr or mktCr[1]) and (pinkRday or realRday);

AddChartBubble(RallyDay1, vol, "R1", color.LIGHT_GREEN);
 
Hi All can someone help me understand this. I started looking at IBD and ended up here. Wondering if one you can explain me how to use it?
Thanks in advance.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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