Hello Wabbit
Your formulas and comments are excellent - thanks.
I was wondering if you could take a quick peek at the following code I wrote. My goal is to display:
1. total number of bars since last high (looking back to first displayed data) was achieved, excluding current bar
2. peak-to-trough % change [defined as (high-low)/high], being high as per above and low=lowest value since high
I have looked around in the Forum but couldn't quite find what I wanted.
plot:=Input("1=Bars Since Last Hi,2=% Peak to Tr Since Prev Hi",1,2,1);{is current bar highest value?}test1:=P>Ref(Highest(P),-1);{bars since last high}test2:=HighestSinceBars(1,test1=1,P);{lowest since prev high}test3:=If(test1=1,P,LowestSince(1,test2=1,P));{highest since prev high}test4:=HighestSince(1,test2=0,P);{% peak to trough}ptt:=(test4-test3)/test4*100;{plot}If(plot=1,test2,ptt)
I think my code achieves this but would like a reality check from a pro.
Many thanks.
ZigZag
Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
Wabbit
Many thanks for your prompt and valuable reply. Your code achieves intended goals with more efficiency.
Also, your PS is well taken.
Best