Help!
by VoroneTZ. 10/14/25 05:04
|
|
|
|
|
|
|
|
|
2 registered members (VoroneTZ, TipmyPip),
9,297
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Sine Trend system code by John Ehlers
#442410
06/21/14 04:12
06/21/14 04:12
|
Joined: Feb 2014
Posts: 183
RTG
OP
Member
|
OP
Member
Joined: Feb 2014
Posts: 183
|
[size:17pt]Hello. I am recoding the Sine Trend system published in Ehlers book, "Rocket Science for Traders". Now I think there is an obvious error in the code.
This is the orginal EasyLanguage code. I have made the error as I see it in bold and large type.
The variable "Period" doesn't have a value when it is called upon resulting in the undeclared indentifier error.
Am I seeing this right?
{***************************************
Written by: Ehlers - Rocket science for traders typed by Henry Amand
Description: SineTrend system, page 120
****************************************}
Inputs: Price((H+L)/2);
Vars: Smooth (0), Detrender (O) , I1 (0), Q1 (O), jI (O), JQ (0), I2 (0), Q2 (0), Re (0), Im (0), Period (0), SmoothPeriod (O), SmoothPrice (O), DCPeriod (O), RealPart (0), Imagpart (O), count (0), DCPhase (O), DCSine (O), LeadSine (O), Itrend (O), Trendline (O), Trend (0), DaysinTrend (O);
If CurrentBar > 5 then begin
Smooth = (4*Price + 3*Price[1] + 2*Price[2] + Price[3]) / 10; Detrender = (.0962 * Smooth + .5769 * Smooth[2] - .5769 * Smooth[4] - .0962*Smooth[6]) * (.075 * Period[1] + .54);
{Compute InPhase and Quadrature components.}
Q1 = (.0962 * Detrender + .5769 * Detrender[2] - .5769 * Detrender[4] - .0962 * Detrender[6]) * (.075 * Period[1] + .54); I1 = Detrender[3];
[/size]
Last edited by RTG; 06/21/14 04:14.
|
|
|
Re: Sine Trend system code by John Ehlers
[Re: jcl]
#442589
06/25/14 23:52
06/25/14 23:52
|
Joined: Feb 2014
Posts: 183
RTG
OP
Member
|
OP
Member
Joined: Feb 2014
Posts: 183
|
OK.
I've managed to get a bit further along with this project. Although I am getting a script crash error in the section in bold type. Any ideas?
#include <profile.c> #include <indicators.c> #include <default.c>
function run() { vars Price = series(price()); vars Period = series(); vars Smooth = series((Price[0]*4 + Price[1]* 3 + Price[2]*2 + Price[3])/10); vars Detrender = series((.0962 * Smooth[0] + .5769 * Smooth[2] - .5769 * Smooth[4] - .0962*Smooth[6]) * (.075 * Period[1] + .54));
// {Compute InPhase and Quadrature components.} vars Q1 = series((.0962 * Detrender[0] + .5769 * Detrender[2] - .5769 * Detrender[4] - .0962 * Detrender[6]) * (.075 * Period[1] + .54)); vars I1 = series(Detrender[3]); // {Advance the phase of I1 and Q1 by 90 degrees} vars jI = series((.0962 * I1[0] + .5769 * I1[2] - .5769 * I1[4] - .0962 * I1[6]) * (.075 * Period[1] + .54)); vars JQ = series((.0962 * Q1[0] + .5769 * Q1[2] - .5769 * Q1[4] - .0962 * Q1[6]) * (.075 * Period[1] + .54));
// {Phasor addition for 3 bar averaging)} vars I2 = series(I1[0] - JQ[0]); vars Q2 = series(Q1[0] + jI[0]);
// {Smooth the I and Q components before applying the discriminator} vars I2 = series(.2 * I2[0] + .8 * I2[1]); vars Q2 = series(.2 * Q2[0] + .8 * Q2[1]);
plot("Smooth", Smooth[0], MAIN,BLUE); plot("Detrender",Detrender[0], NEW,RED); plot("I1", I1[0],0, BLUE); plot("jI",jI[0], 0,ORANGE); plot("Q1", Q1[0], 0, ORANGE); plot("JQ",JQ[0], 0, GREEN); plot("I2", I2[0], 0, PURPLE); plot("Q2", Q2[0], 0, YELLOW); // {Homodyne Discriminator} vars Re = series(I2[0] * I2[1] + Q2[0] * Q2[1]); vars Im = series(I2[0] * Q2[1] - Q2[0] * I2[1]); vars Re = series(.2 * Re[0] + .8 * Re[1]); vars Im = series(.2 * Im[0] + .8 * Im[1]); plot("Smooth", Smooth[0], MAIN,BLUE); plot("Detrender",Detrender[0], NEW,RED); plot("I1", I1[0],0, BLUE); plot("jI",jI[0], 0,ORANGE); plot("Q1", Q1[0], 0, ORANGE); plot("JQ",JQ[0], 0, GREEN); plot("I2", I2[0], 0, PURPLE); plot("Q2", Q2[0], 0, YELLOW); plot("Re", Re[0], NEW, BLACK); plot("Im", Im[0], 0, OLIVE); vars SmoothPeriod = series(); if(Im != 0 and Re != 0) vars Period = series((2*PI) / atan2(Im[0],Re[0])); // This line and below line are causing the script to crash when both are active if(Period[0] > 1.5 * Period[1]) vars Period = series(1.5 * Period[1]); if(Period[0] < .67 * Period[1]) vars Period = series(.67 * Period[1]); if(Period[0] < 6) Period = 6; if(Period[0] > 50) Period = 50; vars Period = series((.2 * Period[0] + .8 * Period[1])); // This line and above vars SmoothPeriod = series(.33 * Period[0] + .67 * SmoothPeriod[1]); }
|
|
|
|