Tuesday, April 12, 2011

Current Trendline and Sinewave Indicator

Current Trendline and Sinewave Indicator as described by John Ehlers
Here is the MetaStock 6,52 or higher formula code for immediate and Trendline Sinewave Indicator as described by John Ehlers in his article "at last! A Friendly Trend Oscillator. To implement 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 in the last two formulas are plotted, so you may want to prevent others to be displayed in the Indicator QuickList by marking the "Display In QuickList" option when creating the formula.
To download and install the formulas use the following steps
Download the file in the Temp folder MS65FORM.DTA
To download the file for this formula click MS65FORM.DTA
Use the following instructions to import the file MS65FORM.DTA the temp file was downloaded.
1st Run MetaStock.
2nd Select Indicator Builder from the menu Tools.
3rd Click the Organize button to launch the Formula Organizer Wizard.
4th Follow the instructions on screen.

Name: H cycle count 1A
value: = Fml ("Hilbert cycle period - 1a");
If (Sum (value, 6)> = 360 and the amount (value, 5) <360, 6,0) +
If (Sum (value, 7)> = 360 and the amount (value, 6) <360, 7.0) +
If (Sum (value, 8)> = 360 and the amount (value, 7) <360, 8.0) +
If (Sum (value, 9)> = 360 and the amount (value, 8) <360, 9.0) +
If (Sum (value, 10)> = 360 and the amount (value, 9) <360, 10.0) +
If (Sum (value, 11)> = 360 and the amount (value, 10) <360, 11.0) +
If (Sum (value, 12)> = 360 and the amount (value, 11) <360, 12.0) +
If (Sum (value, 13)> = 360 and the amount (value, 12) <360, 13.0) +
If (Sum (value, 14)> = 360 and the amount (value, 13) <360, 14.0) +
If (Sum (value, 15)> = 360 and the amount (value, 14) <360, 15.0)

Name: H cycle count 2a
value: = Fml ("Hilbert cycle period - 1a");
If (Sum (value, 16)> = 360 and the amount (value, 15) <360, 16.0) +
If (Sum (value, 17)> = 360 and the amount (value, 16) <360, 17.0) +
If (Sum (value, 18)> = 360 and the amount (value, 17) <360, 18.0) +
If (Sum (value, 19)> = 360 and the amount (value, 18) <360, 19.0) +
If (Sum (value, 20)> = 360 and the amount (value, 19) <360, 20.0) +
If (Sum (value, 21)> = 360 and the amount (value, 20) <360, 21.0) +
If (Sum (value, 22)> = 360 and the amount (value, 21) <360, 22.0) +
If (Sum (value, 23)> = 360 and the amount (value, 22) <360, 23.0) +
If (Sum (value, 24)> = 360 and the amount (value, 23) <360, 24.0) +
If (Sum (value, 25)> = 360 and the amount (value, 24) <360, 25.0)

Name: H cycle count 3a
value: = Fml ("Hilbert cycle period - 1a");
If (Sum (value, 26)> = 360 and the amount (value, 25) <360, 26.0) +
If (Sum (value, 27)> = 360 and the amount (value, 26) <360, 27.0) +
If (Sum (value, 28)> = 360 and the amount (value, 27) <360, 28.0) +
If (Sum (value, 29)> = 360 and the amount (value, 28) <360, 29.0) +
If (Sum (value, 30)> = 360 and the amount (value, 29) <360, 30.0) +
If (Sum (value, 31)> = 360 and the amount (value, 30) <360, 31.0) +
If (Sum (value, 32)> = 360 and the amount (value, 31) <360, 32.0) +
If (Sum (value, 33)> = 360 and the amount (value, 32) <360, 33.0) +
If (Sum (value, 34)> = 360 and the amount (value, 33) <360, 34.0) +
If (Sum (value, 35)> = 360 and the amount (value, 34) <360, 35.0)

Name: H IP a sum
pd: = Int (Fml ("Hilbert cycle period - final-a"));
PR: = (H + L) / 2;
(Cos (0) * program) +
(Cos (360 * (1/pd)) * Ref (eg, -1)) +
(Cos (360 * (2/pd)) * Ref (eg, -2)) +
(Cos (360 * (3/pd)) * Ref (eg, -3)) +
(Cos (360 * (4/pd)) * Ref (eg, -4)) +
(Cos (360 * (5/pd)) * Ref (eg, -5)) +
If (PD> 6, cos (360 * (6/pd)) * Ref (eg, -6), 0) +
If (PD> 7, cos (360 * (7/pd)) * Ref (eg, -7), 0) +
If (PD> 8, cos (360 * (8/pd)) * Ref (eg, -8), 0) +
If (PD> 9, cos (360 * (9/pd)) * Ref (eg, -9), 0) +
If (PD> 10, cos (360 * (10/pd)) * Ref (eg, -10), 0) +
If (PD> 11, cos (360 * (11/pd)) * Ref (eg, -11), 0) +
If (PD> 12, cos (360 * (12/pd)) * Ref (eg, -12), 0) +
If (PD> 13, cos (360 * (13/pd)) * Ref (eg, -13), 0) +
If (PD> 14, cos (360 * (14/pd)) * Ref (eg, -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 (eg, -15), 0) +
If (PD 16>, cos (360 * (16/pd)) * Ref (eg, -16), 0) +
If (PD> 17, cos (360 * (17/pd)) * Ref (eg, -17), 0) +
If (PD> 18, cos (360 * (18/pd)) * Ref (eg, -18), 0) +
If (PD> 19, cos (360 * (19/pd)) * Ref (eg, -19), 0) +
If (PD> 20, cos (360 * (20/pd)) * Ref (eg, -20), 0) +
If (PD> 21, cos (360 * (21/pd)) * Ref (eg, -21), 0) +
If (PD> 22, cos (360 * (22/pd)) * Ref (eg, -22), 0) +
If (PD 23>, cos (360 * (23/pd)) * Ref (eg, -23), 0) +
If (PD> 24, cos (360 * (24/pd)) * Ref (eg, -24), 0)

Name: H IP 3 sum
pd: = Int (Fml ("Hilbert cycle period - final-a"));
PR: = (H + L) / 2;
If (PD> 25, cos (360 * (25/pd)) * Ref (eg, -25), 0) +
If (PD> 26, cos (360 * (26/pd)) * Ref (eg, -26), 0) +
If (PD> 27, cos (360 * (27/pd)) * Ref (eg, -27), 0) +
If (PD> 28, cos (360 * (28/pd)) * Ref (eg, -28), 0) +
If (PD> 29, cos (360 * (29/pd)) * Ref (eg, -29), 0) +
If (PD> 30, cos (360 * (30/pd)) * Ref (eg, -30), 0) +
If (PD> 31, cos (360 * (31/pd)) * Ref (eg, -31), 0) +
If (PD> 32, cos (360 * (32/pd)) * Ref (eg, -32), 0) +
If (PD> 33, cos (360 * (33/pd)) * Ref (eg, -33), 0) +
If (PD> 34, cos (360 * (34/pd)) * Ref (eg, -34), 0)

Name: H Rp sum 1
pd: = Int (Fml ("Hilbert cycle period - final-a"));
PR: = (H + L) / 2;
(Sin (0) * program) +
(Sin (360 * (1/pd)) * Ref (eg, -1)) +
(Sin (360 * (2/pd)) * Ref (eg, -2)) +
(Sin (360 * (3/pd)) * Ref (eg, -3)) +
(Sin (360 * (4/pd)) * Ref (eg, -4)) +
(Sin (360 * (5/pd)) * Ref (eg, -5)) +
If (PD> 6, Sin (360 * (6/pd)) * Ref (eg, -6), 0) +
If (PD> 7, Sin (360 * (7/pd)) * Ref (eg, -7), 0) +
If (PD> 8, Sin (360 * (8/pd)) * Ref (eg, -8), 0) +
If (PD> 9, Sin (360 * (9/pd)) * Ref (eg, -9), 0) +
If (PD> 10, Sin (360 * (10/pd)) * Ref (eg, -10), 0) +
If (PD> 11, Sin (360 * (11/pd)) * Ref (eg, -11), 0) +
If (PD> 12, Sin (360 * (12/pd)) * Ref (eg, -12), 0) +
If (PD> 13, Sin (360 * (13/pd)) * Ref (eg, -13), 0) +
If (PD> 14, Sin (360 * (14/pd)) * Ref (eg, -14), 0)

Name: H Rp 2 sum
pd: = Int (Fml ("Hilbert cycle period - final-a"));
PR: = (H + L) / 2;
If (PD> 15, Sin (360 * (15/pd)) * Ref (eg, -15), 0) +
If (PD> 16, Sin (360 * (16/pd)) * Ref (eg, -16), 0) +
If (PD> 17, Sin (360 * (17/pd)) * Ref (eg, -17), 0) +
If (PD> 18, Sin (360 * (18/pd)) * Ref (eg, -18), 0) +
If (PD> 19, Sin (360 * (19/pd)) * Ref (eg, -19), 0) +
If (PD> 20, Sin (360 * (20/pd)) * Ref (eg, -20), 0) +
If (PD> 21, Sin (360 * (21/pd)) * Ref (eg, -21), 0) +
If (PD> 22, Sin (360 * (22/pd)) * Ref (eg, -22), 0) +
If (PD> 23, Sin (360 * (23/pd)) * Ref (eg, -23), 0) +
If (PD> 24, Sin (360 * (24/pd)) * Ref (eg, -24), 0)

Name: H Rp 3 sum
pd: = Int (Fml ("Hilbert cycle period - final-a"));
PR: = (H + L) / 2;
If (PD> 25, Sin (360 * (25/pd)) * Ref (eg, -25), 0) +
If (PD> 26, Sin (360 * (26/pd)) * Ref (eg, -26), 0) +
If (PD> 27, Sin (360 * (27/pd)) * Ref (eg, -27), 0) +
If (PD> 28, Sin (360 * (28/pd)) * Ref (eg, -28), 0) +
If (PD> 29, Sin (360 * (29/pd)) * Ref (eg, -29), 0) +
If (PD> 30, Sin (360 * (30/pd)) * Ref (eg, -30), 0) +
If (PD> 31, Sin (360 * (31/pd)) * Ref (eg, -31), 0) +
If (PD> 32, Sin (360 * (32/pd)) * Ref (eg, -32), 0) +
If (PD> 33, Sin (360 * (33/pd)) * Ref (eg, -33), 0) +
If (PD> 34, Sin (360 * (34/pd)) * Ref (eg, -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 * last);
quad: = 0,2 * value3 + (0.8 * last);
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 ("cycle count Tues 1a") + Fml ("Tues cycle count 2a") + Fml ("Tues cycle count 3a");
C2: If = (C1 = 0, previous, C1);
(0,25 * c2) + (0.75 * last)

Name: Instantaneous trend line
PR: = (H + L) / 2;
(Fml ("a sum Tues TL") + Fml ("TL Tues sum 2") + Fml ("TL Tues sum 3"));
0,33 * (PR + (0.5 * (PR-Ref (eg, -3)))) + (0.67 * last)

Name: Sinewave Indicator
pd: = Int (Fml ("Hilbert cycle period - final-a"));
cp: = Fml ("Hilbert cycle period - final-a");
IP: = Fml ("IP Tues sum 1") + Fml ("IP Tues sum 2) +
Fml ("IP Tues sum 3");
Rp: = Fml ("Tues sum of Rp 1") + Fml ("Tues amount Rp 2") +
Fml ("Tues amount Rp 3");

DC1: If = (abs (ip)> 0,001, atan (RP / IP, 1), 90 * If (RP> = 0,1, -1));
dc2: If = (IP <0, DC1 270, DC1 90);
DCP: If = (dc2> 315, dc2-360, dc2);

Sin (DCP);
Sin (DCP 45)

No comments:

Post a Comment

Powered by Blogger.