PDA

View Full Version : Formula for CAPP


franca
16th October 2003, 04:57 AM
Does anyone know the metastock formula for CAPP, Close above Previous Peak. A trigger for some medium term systems.
A Peak is defined as the highest point between a
Short Term Uptrend and Short Term Downtrend.
I'll be most grateful if someone has something that works.
Ta :lol:

Jose
18th October 2003, 02:33 AM
Franca, there are many ways to determine trend, and Linear Regression Slope seems to be one of the better ones - its minimal lag gets you in & out of trends a tad earlier.

Try the indicator below.
Plot a copy of it on the price chart (Peak/Trough levels option), and another below in its own window (breakout signals option).

jose '-)


======================
Peak & Trough trend breakouts
======================

---8<---------------------------------

{©Copyright 2003 Jose Silva}
{josesilva22@yahoo.com}

pds:=Input("Linear Regression Slope trend periods",2,252,5);
plot:=Input("plot: Peak/Trough breakouts=1, chart values=2",1,2,1);

LRS:=LinRegSlope(C,pds);
Pk:=Ref(LRS,-1)>LRS AND Ref(LRS,-1)>Ref(LRS,-2)
AND Ref(C,-1)>C AND Ref(C,-1)>Ref(C,-2);
PkVal:=ValueWhen(1,Pk,Ref(C,-1));
PkBreak:=C>PkVal;

Tr:=Ref(LRS,-1)<LRS AND Ref(LRS,-1)<Ref(LRS,-2)
AND Ref(C,-1)<C AND Ref(C,-1)<Ref(C,-2);
TrVal:=ValueWhen(1,Tr,Ref(C,-1));
TrBreak:=C<TrVal;

If(plot=1,-TrBreak,TrVal);
If(plot=1,PkBreak,PkVal)

---8<---------------------------------

Darlene
1st June 2004, 04:23 AM
Hi Jose,

Can you please let me know how you would enter this into a TradeSim analysis where the trigger would be the breakout?

Cheers
Darlene

Jose
3rd June 2004, 04:39 AM
=========================
TradeSim (Peaks & Troughs breakouts)
=========================
{All trades delayed by one day
(entry/exit Long on Open next trade day).
Adjust TradeDelay variable to 0 for no delay.
Adjust default system variables within code in
indicator "Peaks & Troughs trend breakouts".}

---8<------------------------------------

TradeDelay:=1;

LongEntryTrigger:=Ref(Fml("Peaks & Troughs trend breakouts")=1,-TradeDelay);
LongEntryPrice:=OPEN;

LongExitTrigger:=Ref(Fml("Peaks & Troughs trend breakouts")=-1,-TradeDelay);
LongExitPrice:=OPEN;
LongInitialStop:=0;

ExtFml("TradeSim.Initialize");
ExtFml("TradeSim.SetStartRecordDate",1,1,1998);
ExtFml("TradeSim.SetStopRecordDate",1,1,2010);

ExtFml("TradeSim.RecordTrades",
"Peaks & Troughs breakouts",
LONG,
LongEntryTrigger,
LongEntryPrice,
LongInitialStop,
LongExitTrigger,
LongExitPrice,
START)

---8<------------------------------------

jose '-)

Darlene
8th June 2004, 04:18 AM
Thanks Jose - thats greatly appreciated.

Cheers
Darlene