Peaks and Troughs

Status
Not open for further replies.

andrewmurray86

New Member
Joined
Jun 18, 2020
Messages
29
Office Version
  1. 2016
Platform
  1. Windows
Hello Everyone I'm hoping you might help me with a formula to identify peaks and troughs

I've got a formula that finds that maximum drawdown from the initial balance, But I need to find the value to get the maximum drawdown overall (At this time it is the maximum from the initial balance.
And I need to find the draw down between a new high then the low before a new high.

The graph should help

This graph is generated from the data I will use to get the formula. The information will sit off the side for easy reference, I have also included the data with peak and trough labeled on it, but I'm just after the values as described above, not every peak and trough, you can see there are many but essentially just the ones labelled in the graph

Thanks so much everyone!

Annotation 2020-06-26 064953.png


Cell Formulas
RangeFormula
S2:S92S2=IF(AND((R2>R1),(R2>R3)),"peak","")
R2R2=X1+N2
R3:R93R3=R2+N3
T2:T93T2=IF(AND((R2<R1),(R2<R3)),"trough","")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A94:T200,O2:S92,A93:S93Cellcontains a blank value textNO
A94:T200,O2:S92,A93:S93Cellcontains a blank value textNO
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Like this?

Book3.xlsm
ABC
1IDEquityPT
23995.97
33991.93 
43988.28 
53984.64 
63980.39 
73976.13 
83936.21 
93896.3 
103896.14 
113895.98 
123867.21 
133838.39 
143798 
153757.61 
163716.97 
173676.33 
183675.41 
193675.09Trough
203681.66 
213688.27 
223764.01 
233788.03 
243812.48 
253812.78Peak
263812.3Trough
273906.41 
283931.76 
293949.48 
304010.59Peak
314007.91Trough
324008.19 
334030.97 
344031.25 
354053.77Peak
364053.31 
374053.07 
384052.7 
394052.45 
404017.59 
413982.72 
423982.09Trough
433999.01 
444015.93 
454032.77 
464049.6Peak
474048.68 
484048.31 
493948.31 
503928.31 
513928.14Trough
523950.34 
533951.16 
543952.04 
553976.97Peak
563960.06 
573943.26Trough
583966.08 
593977.22 
603977.82 
614000.62 
624024.03 
634040.33Peak
644039.76Trough
654060.98 
664061.35Peak
674059.7 
684059.12 
694058.87 
704058.61 
714016.17 
723973.76 
733973.47 
743940.03 
753906.59Trough
763932.69Peak
773932.2 
783864.2 
793861.67Trough
803887.37Peak
813885.99 
823884.94 
833883.92 
843882.93 
853881.94Trough
863882.93Peak
873879.87 
883879.08 
893878.04 
903877.05 
913876.22 
923873.17 
933873.17 
Sheet4
Cell Formulas
RangeFormula
C3:C93C3=IF(AND(B3<B2,B3<B4),"Trough",IF(AND(B3>B2,B3>B4),"Peak",""))


1593124158021.png
1593124158021.png
 
Upvote 0
Thanks everyone that's really great. I am wondering if there is a way we can tweak the formula to only give the extremes like in the graph I posted? Or even using the data from
Irobbo314's formula
Cell Formulas
RangeFormula
C3:C93C3=IF(AND(B3<B2,B3<B4),"Trough",IF(AND(B3>B2,B3>B4),"Peak",""))

to give the "gap" between the lowest and highest after a peak, if we treat the start balance of 4000 as a peak, then the lowest point from there is 8.12% lower

I'm thinking if, for example" if C3= peak then find next trough and calculate the the difference, the give the max difference between the peak and trough". The idea is to eliminate the smaller peak-trough fluctuations so after the peak to trough of c3 to c19, the next one would be peak at c35 and trough at c51, then peak at c66 and trough at c92

Is such a thing possible?
 
Last edited:
Upvote 0
This seems better.

Book3.xlsm
ABCDE
1IDEquityComboValleysPeaks
23995.97 
33991.93   
43988.28   
53984.64   
63980.39   
73976.13   
83936.21   
93896.3   
103896.14   
113895.98   
123867.21   
133838.39   
143798   
153757.61   
163716.97   
173676.33   
183675.41   
193675.09ValleyValley 
203681.66   
213688.27   
223764.01   
233788.03   
243812.48   
253812.78   
263812.3ValleyValley 
273906.41   
283931.76   
293949.48   
304010.59Peak Peak
314007.91   
324008.19   
334030.97   
344031.25   
354053.77Peak Peak
364053.31   
374053.07   
384052.7   
394052.45   
404017.59   
413982.72   
423982.09   
433999.01   
444015.93   
454032.77   
464049.6Peak Peak
474048.68   
484048.31   
493948.31   
503928.31   
513928.14ValleyValley 
523950.34   
533951.16   
543952.04   
553976.97Peak Peak
563960.06   
573943.26   
583966.08   
593977.22   
603977.82   
614000.62   
624024.03   
634040.33Peak Peak
644039.76   
654060.98   
664061.35Peak Peak
Sheet4
Cell Formulas
RangeFormula
C2:C66C2=IF(D2<>"",D2,IF(E2<>"",E2,""))
D3:D66D3=IF(AND(B2>B3,B4>B3),IF(B3<AVERAGE($B$2:$B$93),"Valley",""),"")
E3:E66E3=IF(AND(B2<B3,B4<B3),IF(B3>AVERAGE($B$2:$B$93),"Peak",""),"")


1593130697606.png
 
Upvote 0
And if that works for you then the 3 columns of formulas can be condensed to just 1 formula.

Rich (BB code):
=IF(AND(B2>B3,B4>B3),IF(B3<AVERAGE($B$2:$B$93),"Valley",""),IF(AND(B2<B3,B4<B3),IF(B3>AVERAGE($B$2:$B$93),"Peak",""),""))
 
Upvote 0
I'm not sure how to replicate the results you said exactly, but playing with these percentages gets closer. I'm calling it quits for today, so here's another version of the formula that you can tinker with to tune it to your liking.

Rich (BB code):
=IF(AND(B2>B3,B4>B3),IF(B3<MIN($B$2:$B$93)/0.93,"Valley",""),IF(AND(B2<B3,B4<B3),IF(B3>MAX($B$2:$B$93)*0.995,"Peak",""),""))

1593132415452.png
 
Upvote 0
Hi guys, I've got it down to a nice point. I'm just wondering if there is a way to get the values highlighted?

I'm using this formula, on another sheet, =IF(Splash!S3:S252="Valley", MIN(Splash!R3:R252),"")

But I am getting a blank cell :(
 
Upvote 0
And if that works for you then the 3 columns of formulas can be condensed to just 1 formula.

Rich (BB code):
=IF(AND(B2>B3,B4>B3),IF(B3<AVERAGE($B$2:$B$93),"Valley",""),IF(AND(B2<B3,B4<B3),IF(B3>AVERAGE($B$2:$B$93),"Peak",""),""))
Hi i am facing similar issue of identifying peaks and troughs, but if there are continous peak or trough values then the
Formula is not identifying, any pointers on
This can be helpful.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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