--- In [email protected], "Mike" <sfclimb...@...> wrote: > > John, > > If in fact Peak is supposed to retain the value of the previous Peak when not > a new Peak (as opposed to zero shown in my previous post) and similarly for > Valley, then my earlier post would need to be modified to the following (also > corrected to no longer use the AmiBroker keyword Peak as a variable name) > > BP1 = Ref( BP, -1 ); > BP2 = Ref( BP, -2 ); > > NewPeak = ( BP1 > BP AND BP1 > BP2 ); > Peaks = IIF( NewPeak, BP1, ValueWhen( NewPeak, BP1 ) ); > NewValley = ( BP1 < BP AND BP1 < BP2 ); > Valleys = IIF( NewValley, BP1, ValueWhen( NewValley, BP1 ) ); > > AvgPeak = MA( Peaks, 50 ); > FracAvgPeak = Fraction * AvgPeak; > AvgValley = MA( Valleys, 50 ); > FracAvgValley = Fraction * AvgValley; > > Mike
Thanks Mike, that too was very helpful. (You might want to see my prior post about constant confusion[sic].) Best, John
