I guess you could use some of the ideas of a cup and handle formula,combine it with wecoyote13's request from earlier and do something like :
{for peak}
Adjust:=Input("Enter Adjustment periods",1,100,6);
AdjustConstant:=(adjust/2);
Ind1:=Stoch(14,3);
Ind2:=C;
T1:=Peak(1,Ind1,15);
CD:=T1<>Ref(T1,-1);
I1:=ValueWhen(1,Cross(BarsSince(Cd),AdjustConstant),HHV(Ind1,Adjust));
I2:=ValueWhen(2,Cross(BarsSince(Cd),AdjustConstant),HHV(Ind1,Adjust));
C1:=ValueWhen(1,Cross(BarsSince(Cd),AdjustConstant),Cum(1));
C2:=ValueWhen(2,Cross(BarsSince(Cd),AdjustConstant),Cum(1));
P1:=ValueWhen(1,Cum(1)=C1,Ind2);
P2:=ValueWhen(2,Cum(1)=C2,Ind2);
I1>I2 and P1<P2
Adjust is for us to check the highest value or lowest value of X at the time of the peak or the trough for "Adjust" amont of bars.
We divide it by 2 to evenly extent the Adjust values on both sides.
Then we count the number of bars till the inidcator value we picked adn matched this number of bars to retrieve our price value or second indicator value ...
A little confusing :D
I might have made a mistake but that should be a decent start
Patrick
My Site