Stock Market Probability in a Spread Sheet

rebel123

Active Member
Joined
Apr 18, 2017
Messages
359
Office Version
  1. 365
Platform
  1. MacOS
Would anyone know how to compile the history of the Dow Jones (either from inception or say the past 20 years)
where I could figure out probability of stocks going up two times and then down once AND ALSO three times up and then down once.

Here are the 2 questions and patterns I am looking to solve.
I am looking to solve the equations in bold.

DAY 1 DJIA goes up
DAY 2 DJIA goes up
DAY 3 DJIA goes down (what is the probability on day 3- is it 60%, 80%, etc)


DAY 1 DJIA goes up
DAY 2 DJIA goes up
DAY 3 DJIA goes up
DAY 4 DJIA goes down (what is the probability on day 3- is it 60%, 80%, etc)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Here is a file that does it but I could only get a couple of months of data. Once you figure out where to get the data (you may have to pay for it if you want to back 20 years, and inception was 1880) you can just extend the formulas.

I used helper columns to more clearly illustrate what is going on but I think this could be done with array formulas and no helpers.

 
Upvote 0
I accessed the history going back to 1992 from:
Then used a formula to walk down the columns to look for instances where the Up-Up-Down (UUD) and Up-Up-Up-Down (UUUD) criteria were met. The results are tabulated in H1:J3. Here's a snippet:
MrExcel_20220630_DJIA.xlsx
ABCDEFGHIJ
113.4%6.9%"TRUE" %
276787677Total Count
31027528TRUE's
4DateOpenHighLowClose*Adj Close**VolumeUUDUUUD
529-Jun-2231,067.4131,152.9630,894.5331,029.3131,029.31269,390,000FALSEFALSE
628-Jun-2231,549.0531,885.0930,934.3330,946.9930,946.99350,780,000FALSEFALSE
727-Jun-2231,533.6031,598.5931,351.3731,438.2631,438.26309,910,000TRUEFALSE
824-Jun-2230,846.9431,517.2930,846.9431,500.6831,500.68465,480,000FALSEFALSE
923-Jun-2230,570.3330,715.6330,293.4030,677.3630,677.36361,420,000FALSEFALSE
1022-Jun-2230,352.5730,777.9230,166.0130,483.1330,483.13343,490,000FALSEFALSE
1121-Jun-2230,074.6930,653.9830,074.6930,530.2530,530.25376,900,000FALSEFALSE
1217-Jun-2229,912.7030,167.5229,653.2929,888.7829,888.78692,830,000FALSEFALSE
1316-Jun-2230,305.7430,305.7429,740.3529,927.0729,927.07442,910,000FALSEFALSE
1415-Jun-2230,570.5031,011.9730,185.0830,668.5330,668.53392,670,000FALSEFALSE
1514-Jun-2230,592.3430,690.8030,144.2330,364.8330,364.83366,800,000FALSEFALSE
1613-Jun-2231,144.9131,144.9130,373.7230,516.7430,516.74472,290,000FALSEFALSE
1710-Jun-2232,053.5232,053.5231,387.8431,392.7931,392.79362,300,000FALSEFALSE
189-Jun-2232,828.6232,956.7332,267.7832,272.7932,272.79289,710,000FALSEFALSE
198-Jun-2233,087.0733,156.5032,824.3732,910.9032,910.90270,470,000TRUEFALSE
207-Jun-2232,783.0333,207.4532,641.8533,180.1433,180.14270,750,000FALSEFALSE
216-Jun-2233,032.0433,235.3732,819.5032,915.7832,915.78253,010,000FALSEFALSE
223-Jun-2232,986.3233,135.6132,839.2132,899.7032,899.70298,570,000FALSEFALSE
232-Jun-2232,809.0133,248.6132,509.4333,248.2833,248.28333,210,000FALSEFALSE
241-Jun-2233,156.3133,272.3432,584.7632,813.2332,813.23338,210,000FALSEFALSE
2531-May-2233,160.5933,240.2232,752.3432,990.1232,990.12533,560,000TRUETRUE
2627-May-2232,735.0933,213.6232,682.0133,212.9633,212.96328,770,000FALSEFALSE
2726-May-2232,248.1732,774.1432,248.1732,637.1932,637.19351,220,000FALSEFALSE
2825-May-2231,816.3132,254.4431,754.3332,120.2832,120.28343,460,000FALSEFALSE
2924-May-2231,717.6132,014.8631,365.5931,928.6231,928.62382,950,000FALSEFALSE
3023-May-2231,395.8931,968.4231,395.8931,880.2431,880.24402,010,000FALSEFALSE
DJIA
Cell Formulas
RangeFormula
H1:I1H1=H3/H2
H2H2=COUNTA(H5:H7682)
I2I2=COUNTA(I5:I7681)
H3:I3H3=COUNTIF(H5:H7685,"TRUE")
H5:H30H5=AND($F5<$F6,$F6>$F7,$F7>$F8)
I5:I30I5=AND($F5<$F6,$F6>$F7,$F7>$F8,$F8>$F9)

The full file is here:
 
Upvote 0
Solution
@KRice my impression was that they want the probability of how likely it is to have a down day given the occurrences of two up days, not the probability of having two up days followed by a down day.

@rebel123 needs to clarify the question.
 
Upvote 0
Interesting Jeff...I think we have some ambiguity regarding direction...I've taken "Day 3" or "Day 4" to be the most recent date...so the most recent would be "down" and it was preceded by two or three consecutive "up" days. If Day 1 is intended to be the most recent date, then all of my signs in the AND formulas are flipped...an easy fix, but clarification would be good. Thanks for calling attention to this. I've updated the file to include it both ways, but I'm not sure which is desired:
MrExcel_20220630_DJIA.xlsx
FGHIJKL
113.4%6.9%11.7%5.2%"TRUE" %
27678767776777677Total Count
31027528896399TRUE's
4Adj Close**VolumeUUDUUUDDDUDDDU
531,029.31269,390,000FALSEFALSETRUEFALSE
630,946.99350,780,000FALSEFALSEFALSEFALSE
DJIA
Cell Formulas
RangeFormula
H1:K1H1=H3/H2
H2H2=COUNTA(H5:H7682)
I2:K2I2=COUNTA(I5:I7681)
H3:K3H3=COUNTIF(H5:H7685,"TRUE")
H5:H6H5=AND($F5<$F6,$F6>$F7,$F7>$F8)
I5:I6I5=AND($F5<$F6,$F6>$F7,$F7>$F8,$F8>$F9)
J5:J6J5=AND($F5>$F6,$F6<$F7,$F7<$F8)
K5:K6K5=AND($F5>$F6,$F6<$F7,$F7<$F8,$F8<$F9)


 
Upvote 0
Interesting Jeff...I think we have some ambiguity regarding direction
Here is what I mean. I think you found all occurrences of UUD and determined that count as a percentage of all days. I think what is desired is all cases of UU and determine what percentage of those are followed by a D.

Same for UUUD.
 
Upvote 0
I see...may very well be...a conditional probability rather than the expected likelihood of a particular sequence of 3 or 4 events. Thanks for clarifying this. I'm curious what the OP has to say.
 
Upvote 0
Stephen, thank you...that is very helpful. Did you recall weighing in on this a year and a half ago?
The objective then strongly suggests that Jeff's interpretation for the current request is correct. It appears the OP is indeed looking for a conditional probability. The initial wording...
where I could figure out probability of stocks going up two times and then down once
probably means there is a desire to estimate the expected probability that the Dow Jones closing price will go down given that the index closed up the previous two days. The approach I took for this was to utilize helper columns. To examine the Up-Up-Down scenario (an Up closing followed by another Up closing followed by a Down closing), one column uses a simple formula that performs a walking comparison moving down the column day by day, looking back 3 days to determine whether there is a string of 2 "up" closings (from day 1 to 2 and from 2 to 3). I've referred to this column as UUX since it looks for Up closings during the previous two day-to-day intervals and does not evaluate the closing between "yesterday" and "today" (that comes next). Another column mimics this approach except the formula also checks for the change Down from day 3 ("yesterday") to day 4 (the current day corresponding to the row the formula is on). The first column gives the count of UUX instances and the second column gives the count of UUD instances, so the estimated conditional probability sought would be (count of True UUD)/(count of True UUX).

The same approach was used for the UUUX and UUUD scenario using another two helper columns.

Jeff was right about my first post...I assumed the objective was to estimate the likelihood for a UUD string and a UUUD string. I've left those in the file in columns H and I, respectively (in fact, they are needed for the probability calculation). The opposing trends of DDU and DDDU are also shown (columns J:K).

The L:M helper columns perform the UUX and UUUX checks described above. Both conditional probabilities for a Down that occurs when the previous two or three closings were Up appear to be about 49 %...if I didn't make any errors.

Here is a mini-sheet showing the setup and the computations of interest. The most recent version of my file is available at the link in the previous post if there is any interest in revising or extending the approach.
MrExcel_20220630_DJIA.xlsx
ABCDEFGHIJKLMNOPQR
113.4%6.9%11.7%5.2%27.5%14.1%<-- "TRUE" %Conditional Probabilities
2767876777678767776787677<-- Total CountP(D|UU)UUD/UUX48.6%
3102752889639921141083<-- Count of TRUE'sP(D|UUU)UUUD/UUUX48.8%
4DateOpenHighLowClose*Adj Close**VolumeUUDUUUDDDUDDDUUUXUUUX
529-Jun-2231,067.4131,152.9630,894.5331,029.3131,029.31269,390,000FALSEFALSETRUEFALSEFALSEFALSE
628-Jun-2231,549.0531,885.0930,934.3330,946.9930,946.99350,780,000FALSEFALSEFALSEFALSEFALSEFALSE
727-Jun-2231,533.6031,598.5931,351.3731,438.2631,438.26309,910,000TRUEFALSEFALSEFALSETRUEFALSE
824-Jun-2230,846.9431,517.2930,846.9431,500.6831,500.68465,480,000FALSEFALSEFALSEFALSEFALSEFALSE
DJIA
Cell Formulas
RangeFormula
H1:M1H1=H3/H2
H2,J2,L2H2=COUNTA(H5:H7682)
I2,K2,M2I2=COUNTA(I5:I7681)
H3:M3H3=COUNTIF(H5:H7685,"TRUE")
R2R2=H3/L3
R3R3=I3/M3
H5:H8H5=AND($F5<$F6,$F6>$F7,$F7>$F8)
I5:I8I5=AND($F5<$F6,$F6>$F7,$F7>$F8,$F8>$F9)
J5:J8J5=AND($F5>$F6,$F6<$F7,$F7<$F8)
K5:K8K5=AND($F5>$F6,$F6<$F7,$F7<$F8,$F8<$F9)
L5:L8L5=AND($F6>$F7,$F7>$F8)
M5:M8M5=AND($F6>$F7,$F7>$F8,$F8>$F9)
 
Upvote 0

Forum statistics

Threads
1,224,746
Messages
6,180,705
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top