Improved Chandeleir Exit
Instantaneous Trendline & Sinewave Indicator as described by John Ehlers
Instantaneous Trendline and Sinewave Indicator
INSYNC Index
Investor Preference Index

 

Improved Chandeleir Exit

A few weeks ago when the Chandelier Exit was posted to on our board board, I
asked if there was a faster version of it. On my (slowpoke) 200 Mhz PC at
home, it took about 1 to 2 minutes to calculate the formula on a single
stock.

Anyway, I did not hear of any feasible solutions. Last night, upon reading
about the 25X25 system on this site , it struck me that the original
Chandelier Exit (see below) had a whole bunch of PREV statements in it. I'm
sure everyone knows where I'm going with this by now.

Anyway, here is how the code (at least this iteration) should be modified to
speed up the calculation by a factor of 5. Basically, we move PREV into a
variable vPREV prior to using it (so that it is only calculate once) in the
long and short exits. Here is the code for the long exit. I tested it with
the sample Entry Rule and receive the same results in 1/5th the time. Just
modify the SHORT exit in the same way. Hope this helps everyone using it.

{DEFINE ENTRY PRICE, WITH EXIT BEING -- ENTRY PRICE AND NO TRADE BEING 0}
{Move PREV into a variable to speed things up - DB 2/17/00}
vPREV:=PREV;
EntryPrice:= If(vPREV <= 0,
{Trade entered today?}
If(LongEntry, CLOSE, 0),
{Trade entered before today. Stopped today?}
If(LOW <= vPREV - MoneyMgmtStop, -vPREV,
If(LOW <= HighestSince(1,vPREV=0, HIGH) - 3 * ATR(10), -vPREV,
If(LOW <= HighestSince(1,vPREV=0, CLOSE) - 2.5 * ATR(10), -vPREV,
vPREV))));

(Go Top)

Instantaneous Trendline & Sinewave Indicator as described by John Ehlers

Here are a few formula's that I picked up from a
mailing from George Angell


LSS 5 day Osc
X:=HHV(H,5)-Ref(O,-5);
Y:=C-LLV(L,5);
LSS:=100*(X+Y)/(HHV(H,5)-LLV(L,5))*2;
LSS;

LLS 5 DAY Osc Diff from 3 day osc
X:=HHV(H,5)-Ref(O,-5);
Y:=C-LLV(L,5);
LSS:=100*(X+Y)/(HHV(H,5)-LLV(L,5))*2;
Diff:=LSS-Ref(LSS,-3);
Diff;

LLS Strength Index(1 day)
100*(Ref(C,-1)-Ref(L,-1))/(Ref(H,-1)-Ref(L,-1))

LLS Pivot Breakout Buy Number
X:=(H+L+C)/3;
BBN:=2*X-L;
BSN:=2*X-H;
BBN;
BSN;

(Go Top)

Instantaneous Trendline and Sinewave Indicator
by John Ehlers

Here is the MetaStock 6.52 or higher formula code for the Instantaneous Trendline and Sinewave Indicator as described by John Ehlers in his article “At Last! A Trend-Friendly Oscillator”. To implement them the following formulas must be created in MetaStock’s Indicator Builder. Each formula must be created separately and must be named exactly as it appears below. Only the last two formulas are plotted, so you may wish to prevent the others from being displayed in the Indicator QuickList by unchecking the “Display In QuickList” option when creating the formula.

To download and install the formulas use the following steps

Download the MS65FORM.DTA file into a temp folder

To Download the file for this formula click MS65FORM.DTA

Use the following instructions to Import the MS65FORM.DTA file from the temp file it was downloaded to.

1. Run MetaStock.

2. Choose Indicator Builder from the Tools menu.

3. Click the Organize button to launch the Formula Organizer Wizard.

4. Follow the on-screen instructions.


Name: H cycle count 1a

value:= Fml("Hilbert cycle period - 1a");

If(Sum(value,6)>=360 AND Sum(value,5)<360 ,6,0) +

If(Sum(value,7)>=360 AND Sum(value,6)<360 ,7,0) +

If(Sum(value,8)>=360 AND Sum(value,7)<360 ,8,0) +

If(Sum(value,9)>=360 AND Sum(value,8)<360 ,9,0) +

If(Sum(value,10)>=360 AND Sum(value,9)<360 ,10,0) +

If(Sum(value,11)>=360 AND Sum(value,10)<360 ,11,0) +

If(Sum(value,12)>=360 AND Sum(value,11)<360 ,12,0) +

If(Sum(value,13)>=360 AND Sum(value,12)<360 ,13,0) +

If(Sum(value,14)>=360 AND Sum(value,13)<360 ,14,0) +

If(Sum(value,15)>=360 AND Sum(value,14)<360 ,15,0)



Name: H cycle count 2a

value:= Fml("Hilbert cycle period - 1a");

If(Sum(value,16)>=360 AND Sum(value,15)<360 ,16,0) +

If(Sum(value,17)>=360 AND Sum(value,16)<360 ,17,0) +

If(Sum(value,18)>=360 AND Sum(value,17)<360 ,18,0) +

If(Sum(value,19)>=360 AND Sum(value,18)<360 ,19,0) +

If(Sum(value,20)>=360 AND Sum(value,19)<360 ,20,0) +

If(Sum(value,21)>=360 AND Sum(value,20)<360 ,21,0) +

If(Sum(value,22)>=360 AND Sum(value,21)<360 ,22,0) +

If(Sum(value,23)>=360 AND Sum(value,22)<360 ,23,0) +

If(Sum(value,24)>=360 AND Sum(value,23)<360 ,24,0) +

If(Sum(value,25)>=360 AND Sum(value,24)<360 ,25,0)



Name: H cycle count 3a

value:= Fml("Hilbert cycle period - 1a");

If(Sum(value,26)>=360 AND Sum(value,25)<360 ,26,0) +

If(Sum(value,27)>=360 AND Sum(value,26)<360 ,27,0) +

If(Sum(value,28)>=360 AND Sum(value,27)<360 ,28,0) +

If(Sum(value,29)>=360 AND Sum(value,28)<360 ,29,0) +

If(Sum(value,30)>=360 AND Sum(value,29)<360 ,30,0) +

If(Sum(value,31)>=360 AND Sum(value,30)<360 ,31,0) +

If(Sum(value,32)>=360 AND Sum(value,31)<360 ,32,0) +

If(Sum(value,33)>=360 AND Sum(value,32)<360 ,33,0) +

If(Sum(value,34)>=360 AND Sum(value,33)<360 ,34,0) +

If(Sum(value,35)>=360 AND Sum(value,34)<360 ,35,0)



Name: H ip sum 1

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

(Cos(0)*pr)+

(Cos(360*(1/pd))*Ref(pr,-1))+

(Cos(360*(2/pd))*Ref(pr,-2))+

(Cos(360*(3/pd))*Ref(pr,-3))+

(Cos(360*(4/pd))*Ref(pr,-4))+

(Cos(360*(5/pd))*Ref(pr,-5))+

If(pd>6, Cos(360*(6/pd))*Ref(pr,-6), 0)+

If(pd>7, Cos(360*(7/pd))*Ref(pr,-7), 0)+

If(pd>8, Cos(360*(8/pd))*Ref(pr,-8), 0)+

If(pd>9, Cos(360*(9/pd))*Ref(pr,-9), 0)+

If(pd>10, Cos(360*(10/pd))*Ref(pr,-10), 0)+

If(pd>11, Cos(360*(11/pd))*Ref(pr,-11), 0)+

If(pd>12, Cos(360*(12/pd))*Ref(pr,-12), 0)+

If(pd>13, Cos(360*(13/pd))*Ref(pr,-13), 0)+

If(pd>14, Cos(360*(14/pd))*Ref(pr,-14), 0)



Name: H ip sum 2

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

If(pd>15, Cos(360*(15/pd))*Ref(pr,-15), 0)+

If(pd>16, Cos(360*(16/pd))*Ref(pr,-16), 0)+

If(pd>17, Cos(360*(17/pd))*Ref(pr,-17), 0)+

If(pd>18, Cos(360*(18/pd))*Ref(pr,-18), 0)+

If(pd>19, Cos(360*(19/pd))*Ref(pr,-19), 0)+

If(pd>20, Cos(360*(20/pd))*Ref(pr,-20), 0)+

If(pd>21, Cos(360*(21/pd))*Ref(pr,-21), 0)+

If(pd>22, Cos(360*(22/pd))*Ref(pr,-22), 0)+

If(pd>23, Cos(360*(23/pd))*Ref(pr,-23), 0)+

If(pd>24, Cos(360*(24/pd))*Ref(pr,-24), 0)



Name: H ip sum 3

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

If(pd>25, Cos(360*(25/pd))*Ref(pr,-25), 0)+

If(pd>26, Cos(360*(26/pd))*Ref(pr,-26), 0)+

If(pd>27, Cos(360*(27/pd))*Ref(pr,-27), 0)+

If(pd>28, Cos(360*(28/pd))*Ref(pr,-28), 0)+

If(pd>29, Cos(360*(29/pd))*Ref(pr,-29), 0)+

If(pd>30, Cos(360*(30/pd))*Ref(pr,-30), 0)+

If(pd>31, Cos(360*(31/pd))*Ref(pr,-31), 0)+

If(pd>32, Cos(360*(32/pd))*Ref(pr,-32), 0)+

If(pd>33, Cos(360*(33/pd))*Ref(pr,-33), 0)+

If(pd>34, Cos(360*(34/pd))*Ref(pr,-34), 0)



Name: H rp sum 1

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

(Sin(0)*pr)+

(Sin(360*(1/pd))*Ref(pr,-1))+

(Sin(360*(2/pd))*Ref(pr,-2))+

(Sin(360*(3/pd))*Ref(pr,-3))+

(Sin(360*(4/pd))*Ref(pr,-4))+

(Sin(360*(5/pd))*Ref(pr,-5))+

If(pd>6, Sin(360*(6/pd))*Ref(pr,-6), 0)+

If(pd>7, Sin(360*(7/pd))*Ref(pr,-7), 0)+

If(pd>8, Sin(360*(8/pd))*Ref(pr,-8), 0)+

If(pd>9, Sin(360*(9/pd))*Ref(pr,-9), 0)+

If(pd>10, Sin(360*(10/pd))*Ref(pr,-10), 0)+

If(pd>11, Sin(360*(11/pd))*Ref(pr,-11), 0)+

If(pd>12, Sin(360*(12/pd))*Ref(pr,-12), 0)+

If(pd>13, Sin(360*(13/pd))*Ref(pr,-13), 0)+

If(pd>14, Sin(360*(14/pd))*Ref(pr,-14), 0)



Name: H rp sum 2

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

If(pd>15, Sin(360*(15/pd))*Ref(pr,-15), 0)+

If(pd>16, Sin(360*(16/pd))*Ref(pr,-16), 0)+

If(pd>17, Sin(360*(17/pd))*Ref(pr,-17), 0)+

If(pd>18, Sin(360*(18/pd))*Ref(pr,-18), 0)+

If(pd>19, Sin(360*(19/pd))*Ref(pr,-19), 0)+

If(pd>20, Sin(360*(20/pd))*Ref(pr,-20), 0)+

If(pd>21, Sin(360*(21/pd))*Ref(pr,-21), 0)+

If(pd>22, Sin(360*(22/pd))*Ref(pr,-22), 0)+

If(pd>23, Sin(360*(23/pd))*Ref(pr,-23), 0)+

If(pd>24, Sin(360*(24/pd))*Ref(pr,-24), 0)



Name: H rp sum 3

pd:=Int(Fml("Hilbert cycle period - final-a"));

pr:=(H+L)/2;

If(pd>25, Sin(360*(25/pd))*Ref(pr,-25), 0)+

If(pd>26, Sin(360*(26/pd))*Ref(pr,-26), 0)+

If(pd>27, Sin(360*(27/pd))*Ref(pr,-27), 0)+

If(pd>28, Sin(360*(28/pd))*Ref(pr,-28), 0)+

If(pd>29, Sin(360*(29/pd))*Ref(pr,-29), 0)+

If(pd>30, Sin(360*(30/pd))*Ref(pr,-30), 0)+

If(pd>31, Sin(360*(31/pd))*Ref(pr,-31), 0)+

If(pd>32, Sin(360*(32/pd))*Ref(pr,-32), 0)+

If(pd>33, Sin(360*(33/pd))*Ref(pr,-33), 0)+

If(pd>34, Sin(360*(34/pd))*Ref(pr,-34), 0)



Name: H TL sum 1

value:=Int(Fml("Hilbert cycle period - final-a"));

If(value=6, Mov((H+L)/2,8,S),0) +

If(value=7, Mov((H+L)/2,9,S),0) +

If(value=8, Mov((H+L)/2,10,S),0) +

If(value=9, Mov((H+L)/2,11,S),0) +

If(value=10, Mov((H+L)/2,12,S),0) +

If(value=11, Mov((H+L)/2,13,S),0) +

If(value=12, Mov((H+L)/2,14,S),0) +

If(value=13, Mov((H+L)/2,15,S),0) +

If(value=14, Mov((H+L)/2,16,S),0) +

If(value=15, Mov((H+L)/2,17,S),0)



Name: H TL sum 2

value:=Int(Fml("Hilbert cycle period - final-a"));

If(value=16, Mov((H+L)/2,18,S),0) +

If(value=17, Mov((H+L)/2,19,S),0) +

If(value=18, Mov((H+L)/2,20,S),0) +

If(value=19, Mov((H+L)/2,21,S),0) +

If(value=20, Mov((H+L)/2,22,S),0) +

If(value=21, Mov((H+L)/2,23,S),0) +

If(value=22, Mov((H+L)/2,24,S),0) +

If(value=23, Mov((H+L)/2,25,S),0) +

If(value=24, Mov((H+L)/2,26,S),0) +

If(value=25, Mov((H+L)/2,27,S),0)



Name: H TL sum 3

value:=Int(Fml("Hilbert cycle period - final-a"));

If(value=26, Mov((H+L)/2,28,S),0) +

If(value=27, Mov((H+L)/2,29,S),0) +

If(value=28, Mov((H+L)/2,30,S),0) +

If(value=29, Mov((H+L)/2,31,S),0) +

If(value=30, Mov((H+L)/2,32,S),0) +

If(value=31, Mov((H+L)/2,33,S),0) +

If(value=32, Mov((H+L)/2,34,S),0) +

If(value=33, Mov((H+L)/2,35,S),0) +

If(value=34, Mov((H+L)/2,36,S),0) +

If(value=35, Mov((H+L)/2,37,S),0)



Name: Hilbert cycle period - 1a

value1:=((H+L)/2) - Ref(((H+L)/2),-6);

value2:= Ref(value1,-3);

value3:=0.75*(value1-Ref(value1,-6)) + 0.25*(Ref(value1,-2)-Ref(value1,-4));


inphase:= 0.33 * value2 + (0.67 * PREV);

quad:= 0.2 * value3 + ( 0.8 * PREV);


p1:=Atan(Abs(quad+Ref(quad,-1)),Abs(inphase+Ref(inphase,-1)));


phase:=If(inphase<0 AND quad>0, 180-p1,

If(inphase<0 AND quad<0, 180+p1,

If(inphase>0 AND quad<0, 360-p1,p1)));


dp:=If(Ref(phase,-1)<90 AND phase>270, 360+Ref(phase,-1)-phase,Ref(phase,-1)-phase);

dp2:=If(dp < 1, 1,

If(dp > 60, 60, dp));


dp2



Name: Hilbert cycle period - final-a

c1:= Fml( "H cycle count 1a") + Fml( "H cycle count 2a") + Fml( "H cycle count 3a") ;

c2:=If(c1=0,PREV,c1);


(0.25*c2) + (0.75*PREV)



Name: Instantaneous Trend Line

pr:=(H+L)/2;


(Fml("H TL sum 1") + Fml("H TL sum 2") + Fml("H TL sum 3"));

0.33*(pr + (0.5*(pr-Ref(pr,-3)))) + (0.67*PREV)



Name: Sinewave Indicator

pd:=Int(Fml("Hilbert cycle period - final-a"));

cp:=Fml("Hilbert cycle period - final-a");

ip:=Fml( "H ip sum 1") + Fml( "H ip sum 2") +

Fml( "H ip sum 3");

rp:=Fml( "H rp sum 1") + Fml( "H rp sum 2") +

Fml( "H rp sum 3");


dc1:=If(Abs(ip)>0.001, Atan(rp/ip,1), 90*If(rp>=0,1,-1));

dc2:=If(pd<30 AND cp>0,dc1+((6.818/cp - 0.227)*360),dc1);

dc3:=If(ip<0, dc2+270, dc2+90);

dcp:=If(dc3>315, dc3-360, dc3);


Sin(dcp);

Sin(dcp+45)

(Go Top)

INSYNC Index

The formula from Equis: Insync Index (rev. 01/06/97)

The interpretation for the following formulas came from the article "The Insync Index", by Norm North, in Technical Analysis of Stocks & Commodities Jan 1995.

All of these formulas are necessary for the last one, Insync Index to run properly. They are listed in the order in which they should be copied and pasted into the MetaStock Formula Builder


BOLInSLB
Mov( C ,20 ,S ) - 2 * ( Std( C ,20 ) )

BOLInSUB
Mov( C ,20 ,S ) + 2 * ( Std( C ,20 ) )

BOLInS2
( C - Fml( "BOLInSLB" ) ) / ( Fml( "BOLInSUB" ) - Fml( "BOLInSLB" ) )

BOLInSLL
If( Fml( "BOLInS2" ) ,< , .05 ,-5 ,If( Fml( "BOLInS2" ) ,> ,.95 ,5 ,0 ) )

CCIInS
If( CCI(14 ) ,> ,100 ,5 ,If ( CCI(14 ) ,< ,-100 ,-5 ,0 ) )

EMVInS2
EMV(10 ,S ) - Mov( EMV(10 ,S) ,10 ,S )

EMVInSB
If( Fml( "EMVInS2" ) ,< ,0 ,If( Mov( EMV(10 ,S ) ,10 ,S ) ,< ,0 ,-5 ,0 ) ,0 )

EMVInSS
If( Fml( "EMVInS2" ) ,> ,0 ,If( Mov( EMV(10 ,S ) ,10 ,S ) ,> ,0 ,5 ,0 ) ,0 )

MACDInS2
MACD( ) - Mov( MACD( ) ,10 ,S )

MACDinSB
If( Fml( "MACDInS2" ) ,< ,0 ,If( Mov( MACD( ) ,10 ,S ) ,< ,0 ,-5 ,0 ) ,0 )

MACDInSS
If( Fml( "MACDInS2" ) ,> ,0 ,If( Mov( MACD( ) ,10 ,S) ,> ,0 ,5 ,0 ) ,0 )

MFIInS
If( MFI( 20 ) ,> ,80 ,5 , If( MFI( 20 ) ,< ,20 ,-5 ,0 ) )

PDOInS2
DPO( 18 ) - Mov( DPO( 18 ) ,10 ,S )

PDOInSB
If( Fml( "PDOInS2" ) ,< ,0 ,If( Mov( DPO( 18 ) ,10 , S) ,< ,0 ,-5 ,0 ) ,0 )

PDOInSS
If( Fml( "PDOInS2" ) ,> ,0 ,If( Mov( DPO ( 18 ) ,10 ,S) ,> ,0 ,5 ,0 ) ,0 )

ROCInS2
ROC( C ,10 ,$ ) - Mov( ROC( C ,10 ,$ ) ,10 ,S )

ROCInSB
If( Fml( "ROCInS2" ) ,< ,0 ,If( Mov( ROC( C ,10 ,$ ) ,10 ,S ) ,< ,0 ,-5 ,0 ) ,0 )

ROCInSS Index
If( Fml( "ROCInS2" ) ,> ,0 ,If( Mov( ROC( C ,10 ,$ ) ,10 ,S ) ,> ,0 ,5 ,0 ) ,0 )

RSIInS
If( RSI(14 ) ,> ,70 ,5 ,If( RSI(14 ), < ,30 ,-5 ,0 ) )

STO%dInS
If( Stoch(14 ,3 ) ,> ,80 ,5 ,If( Stoch(14 ,3 ) ,< ,20 ,-5 ,0 ) )

STO%kInS
If( Stoch(14 ,1) ,> ,80 ,5 ,If( Stoch(14 ,1 ) ,< ,20 ,-5 ,0 ) )

InSync Index
50 + Fml( "CCIInS" ) + Fml( "BOLInSLL" ) + Fml( "RSIInS" ) + Fml( "STO%kInS " ) + Fml( "STO%dInS" ) + Fml( "MFIInS" ) + Fml( "EMVInSB" ) + Fml( "EMVInSS" ) + Fml( "ROCInSS" ) + Fml( "ROCInSB" ) + Ref (Fml( "PDOInSS" ) ,-10 ) + Ref (Fml( "PDOInSB" ) ,-10 ) + Fml( "MACDInS S" ) + Fml( "MACDInSB" )

These formulas were provided by Barry Millman. All questions should be addressed to him at 73374.1364@Compuserve.com.

Mr. Millman wrote these formulas using many Custom Formula slots for clarity and ease of understanding. Please note that the final formula `InSync Index' requires all of the previous formulas to be correct.

(Go Top)

Investor Preference Index

This indicator was discussed in the December 1997 Technical Analysis of Stocks & Commodities magazine, page 19. The article was written by Cyril V. Smith Jr.

"This indicator, a long - term stock market investment tool, compares the performance of the S&P 500 to the New York Stock Exchange index to measure sentiment. The theory is that investors have a preference for certain types of investments, blue chips versus mid-cap, during phases of a bull market."

To plot this in MetaStock for Windows, follow these instructions. When complete, if you save this as a chart, you will simply need to load the chart and it will recalculate using the newest data.

  • Open a chart of the S&P 500.
  • Open a chart of the New York Stock Exchange index.
  • Drag the S&P 500 price plot into the NYSE chart.
  • Drop the indicator listed below on the plot of the S&P 500. The plot will turn a different color when you are pointing at it.
  • The resultant plot is the Investor Preference Index.

Formula: Investor Preference Index:

(Sum(Mov(ROC(Log(C),24,%)-ROC(Log(P),24,%),15,S)-Mov(ROC(Log(C),24,%)-ROC(Log(P),24,%),38,S),54)+1)*100

System test:

Enter Long

C=HHV(C,26)

Close Long

Fml("Investor Preference Index")<97.6 AND ROC(Fml("Investor Preference Index"),2,$)<=(-.04)

(Go Top)