View Full Version : CAPP
rajster
7th January 2006, 03:17 AM
Hi Everyone
I am trying to find an indicator for CAPP. (Close above Previous Peak) and vice versa. CBPT. (Close below previous trough. Is anyone aware of these indicators avaliable anywhere on the net? Your help would be greatly appreciated.
Thanks
Rajster
Jose
7th January 2006, 04:24 AM
First define Peak & Trough, and then we'll see what we can do.
jose '-)
rajster
8th January 2006, 05:08 AM
I guess my definition of a peak is when the closing price has been consistently rising. (ie not fallen below its previous closing price in the past 3 days then then falls by at least 3% before rising again to close above the previous highest closing point.
How does that sound? :)
Raj
Jose
8th January 2006, 11:38 AM
It sounds like you won't get many peaks using that definition.
jose '-)
rajster
9th January 2006, 07:56 AM
Ok
well any suggestions? 8)
Jose
9th January 2006, 04:42 PM
Start with this basic code:
{ Basic Peak }
pk:=Ref(H,-1)>H AND Ref(H,-1)>Ref(H,-2);
{ Peak High }
pkHi:=ValueWhen(1,pk,Ref(H,-1));
{ Basic Trough }
tr:=Ref(L,-1)<L AND Ref(L,-1)<Ref(L,-2);
{ Trough Low }
trLo:=ValueWhen(1,tr,Ref(L,-1));
{ Plot on price chart }
pkHi;trLo
jose '-)
davidjc01
1st August 2006, 11:05 AM
The HomeTrader definition of a Short Term Up Trend (STUT) is 2 consecutive (MUST be consecutive) candles with higher highs. Similarly a Short Term Down Trend (STDT) is 2 consecutive candles with lower lows.
A Peak then, is the Highest High between the start of a STUT and the start of a STDT. A Trough is the Lowest Low between the start of a STDT and the start of a STUT.
A CAPP is a Close above the "most recent" Peak. Curiously a CAPP could occur during a STDT and a CBPT could occur during a STUT!!
Sometime ago 2 proposals for CAPP were posted.
The first was:
STUT := H > Ref(H, -1) AND Ref(H, -1) > Ref(H, -2);
STDT := L < Ref(L, -1) AND Ref(L, -1) < Ref(L, -2);
PPeak := If(STDT = 1, HighestSince(1, STUT, H), PREV);
CAPP := Cross( C, PPeak)
It works the great majority of the time but there are exceptions (eg RIC 13/08/2003 is not flagged.)
The second was:
STUT := H > Ref(H, -1) AND Ref(H, -1) > Ref(H, -2); {Short term uptrend}
STDT := L < Ref(L, -1) AND Ref(L, -1) < Ref(L, -2); {Short term downtrend}
Init:=Cum(STUT+STDT>-1)=1; {Only used to establish an initial trend since records begin}
INSTUT:= (BarsSince(Init OR STUT));
ESTUT := (Ref(INSTUT,-1)=0 AND INSTUT); {First entered uptrend}
ESTDT := (Ref(INSTUT,-1)=1 AND INSTUT=0); {First entered downtrend}
PPeak := If(ESTDT = 1, HighestSince(1, ESTUT, H), PREV); {Previous Peak, highest high since uptrend began and trend reversed}
CAPP := If(Cross( C, PPeak)=1,1,0) {First close above previous peak} ;
CAPP
Which, besides being more difficult to understand, does not seem to work.
Do any ex Hometrader's out there have any experience with either of these codes?
Jose, have you tried them?
Regards,
Jose
2nd August 2006, 10:52 PM
Sorry Dave, you've lost my complete interest immediately after reading this line:
"The HomeTrader definition..." ;)
jose '-)
davidjc01
4th August 2006, 03:49 AM
OK, Jose. I plead "No contest!" :wink:
Can I change tack a bit but still on the question of CAPP?
How can I look-back and find the value of a funtion in a specific period? It seems all the BarsSince, HighestSince, HighestSinceBarsAgo type functions look backwards from the present bar to the bar when a certain condition is true.
But how do I look back and find the value of a function between the times a certain condition first becomes true, and then later becomes false.
As a simple example if I look back 52 weeks, how would I measure the value of the Highest High in week 52 whilst ignoring weeks 1 to 51?
David :D
Jose
5th August 2006, 03:51 AM
David, I would first define the date (or condition) period, and then get the values for that period.
Example:
=======================
High/Low of date period
=======================
---8<------------------------------------
{Plots High/Low of user-input date period.
©Copyright 2004~2006 Jose Silva
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.
http://www.metastocktools.com }
{ Date inputs }
StDay:=Input("start Day",1,31,1);
StMnth:=Input("start Month",1,12,1);
StYear:=Input("start Year",1800,2200,2006);
EnDay:=Input("end Day",1,31,1);
EnMnth:=Input("end Month",1,12,7);
EnYear:=Input("end Year",1800,2200,2006);
{ Restrict to selected period }
start:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth AND DayOfMonth()>=StDay));
end:=Year()<EnYear
OR (Year()=EnYear AND (Month()<EnMnth
OR Month()=EnMnth AND DayOfMonth()<=EnDay));
{ High/Low for selected period }
period:=start AND end;
Hi:=Highest(ValueWhen(1,period,H));
Lo:=Lowest(ValueWhen(1,period,L));
{ Enable below to restrict plot to period }
{plot:=LastValue(BarsSince(end));
Hi:=Ref(Ref(Hi,-plot),plot);
Lo:=Ref(Ref(Lo,-plot),plot);}
{ Plot on price chart }
Hi;Lo
---8<------------------------------------
jose '-)
davidjc01
5th September 2006, 01:05 PM
Jose,
Thanks so much. That was very helpful. Much appreciated.
David
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.