A few days ago I solicited a solution to a problem I have by posting:
I have a spreadsheet that represents stock daily data and associated trades in rows. As with all trading, some trades are winners and some losers and on some days, there are no trades, as represented by "0". Winners are identified in a column by a "1" and losers by a "-1". I need a formula that will sum the largest number of consecutive winners and losers.
A very helpful individual replied to my question and provided me with the following message:
You can use an Array
Code:
Longest Winning Streak:
=MAX(FREQUENCY(IF(A2:A200=1,ROW(A2:A200)),IF(A2:A200<>1,ROW(A2:A200))))
confirmed with CTRL + SHIFT + ENTER (enter alone will not suffice)
Modify ranges as nec. but try to keep as lean as possible
above assumes 0's (like -1's) stop the winning streak ... for losing streak change references to 1 to -1
Unfortunately, this response didn’t solve my problem because the column values look something like “1,0,0,1,0,0,1,1”. Since "0" stops the streak the supplied solution will not work. Help please.
Bookmarks