Need help counting positive trends in strings of data

Chris Hoek

New Member
Joined
May 28, 2015
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I'm playing around with a spreadsheet with historical gold and silver pricing. The spreadsheet is arranged horizontally so that dates are all in a row, respective gold and silver pricing are below the dates also in rows. I'm going back several (about 5) years, so I have a lot of columns (around 1300).

I want to be able to count how many times gold/silver has gone on 2 day positive streaks, the count for 2 day positive streaks should not include streaks that were greater than 2 days
I want to be able to count how many times gold/silver has gone on 3 day positive streaks, the count for 3 day positive streaks should not include streaks that were greater than 3 days
I want to be able to count how many times gold/silver has gone on 4 day positive streaks, the count for 4 day positive streaks should not include streaks that were greater than 4 days
I want to be able to count how many times gold/silver has gone on 5 day positive streaks, the count for 5 day positive streaks should not include streaks that were greater than 5 days
I want to be able to count how many times gold/silver has gone on 6 day positive streaks, the count for 6 day positive streaks should not include streaks that were greater than 6 days, etc.

I want to be able to identify longest positive streaks in gold/silver data (how many days positive)

I will have some more trends I want to calculate, but I'm hoping I can figure those out myself once I have the above figured out.

I'm ok with inserting helper rows as needed.

Thank you in advance for any assistance you may be able to offer!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Please update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using, as the best solution often varies by version. Don’t forget to scroll down to save your changes.

Also, please provide some sample data and expected results. It seems like your data would be better if formatted in columns with dates being in a column and Gold and Silver in a row.

MrExcel has a tool called “XL2BB” that lets you post samples of your data, allowing us to copy/paste it to our Excel spreadsheets to work with the same data you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that this board also has a "Test Here” forum. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Thanks,

Doug
 
Upvote 0
Thank you Doug. Profile updated. Sample data below. Let me know if more info, details, data are needed.

Date10/2/201810/3/201810/4/2018 10/5/201810/8/201810/9/2018 10/10/2018 10/11/201810/11/2018
Gold$1,197.93$1,200.03 $1,199.58$1,200.13$1,192.53$1,186.88 $1,189.98 $1,210.63 $1,219.33
Silver$14.55$14.66$14.51 $14.57 $14.24$14.33 $14.26 $14.40$14.56
Gold vs day before$2.10-$0.45$0.55-$7.60-$5.65$3.10$20.65$8.70
Silver vs day before$0.11-$0.15$0.06-$0.33$0.09-$0.07$0.14$0.17
 
Upvote 0
There are ways to make this cleaner, but this should demonstrate a way to get the information you are seeking.
Book_2023-10-17.xlsx
LMNOPQRSTUV
1DateGoldGold vs day beforeRisingCountStreak endsSilverSilver vs day beforeRisingCountStreak ends
210/2/2018$1,197.93$14.55
310/3/2018$1,200.03$2.10TRUE1 $14.66$0.11TRUE1 
410/4/2018$1,199.58($0.45)FALSE1 $14.51($0.15)FALSE1 
510/5/2018$1,200.13$0.55TRUE1 $14.57$0.06TRUE1 
610/8/2018$1,192.53($7.60)FALSE1 $14.24($0.33)FALSE1 
710/9/2018$1,186.88($5.65)FALSE2end$14.33$0.09TRUE1 
810/10/2018$1,189.98$3.10TRUE1 $14.26($0.07)FALSE1 
910/11/2018$1,210.63$20.65TRUE2 $14.40$0.14TRUE1 
1010/12/2018$1,219.33$8.70TRUE3 $14.56$0.16TRUE2 
1110/13/2018$1,220.00$0.67TRUE4 $14.60$0.04TRUE3 
1210/14/2018$1,221.00$1.00TRUE5 $14.70$0.10TRUE4end
1310/15/2018$1,222.00$1.00TRUE6end$14.50($0.20)FALSE1 
1410/16/2018$1,210.00($12.00)FALSE1 $14.45($0.05)FALSE2 
1510/17/2018$1,205.00($5.00)FALSE2end$14.40($0.05)FALSE3 
1610/18/2018$1,210.00$5.00TRUE1 $14.35($0.05)FALSE4 
1710/19/2018$1,215.00$5.00TRUE2 $14.30($0.05)FALSE5 
1810/20/2018$1,220.00$5.00TRUE3 $14.25($0.05)FALSE6 
1910/21/2018$1,230.00$10.00TRUE4end$14.20($0.05)FALSE7end
20
21
22Gold StreakCountSilver StreakCount
232220
243030
254141
265050
276160
287071
298080
309090
31100100
Sheet6
Cell Formulas
RangeFormula
N3:N19,S3:S19N3=M3-M2
O3:O19,T3:T19O3=M3>M2
Q3:Q19,V3:V19Q3=IF(P4<P3,"end","")
P4:P19,U4:U19P4=IF(O4=O3,P3+1,1)
N23:N31N23=COUNTIFS($P$3:$P$19,M23,$Q$3:$Q$19,"end")
S23:S31S23=COUNTIFS($U$3:$U$19,R23,$V$3:$V$19,"end")

I copied and paste/transposed your data to columns and also added in some additional "fake" data just to have more...

I hope this helps,

Doug
 
Upvote 0
Solution
Doug, this should work just fine. I know why you flipped the data vertically. I will transpose it back horizontally and move on to the next problem. Thank you Sir!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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