# Instantaneous Trend Line by John Ehlers

#### Grey1

##### Senior member
EL code to Ehler's instantaneous Trend line

#### Attachments

• trend line.doc
35.5 KB · Views: 254
Grey1,

I tried to copy this into Tradestation 7.1 and recieved and error message when verifiying "Invalid Input Name", referring to the syntax "Inputs:    Price((H+L)/2);".

Can you tell me what I need to change this, as I like the idea of this indicator.

Thanks

This is TS2000i code and works when I copied it and verified into TS2000. There are some significant differences in the code needed for TS7 compared to TS2000 as I have found out on the Tradestation Easylanguage board.

If all else fails you could post a question on their board as they are quite good at answering.

Paul

Can you tell me how to use this Instantaneous Trend? I tried reading Ehlers site, its beyond my grasp....

Thanks,
Ed

I have the code for the recent version of TradeStation. If anyone would like it, send me a PM. It will not let me post it here. I guess eld files aren't allowed??

Inputs: Price((H+L)/2);

Vars:
InPhase(0),
Phase(0),
DeltaPhase(0),
count(0),
InstPeriod(0),
Period(0),
Trendline(0);

If CurrentBar > 5 then begin

Value1 = Price - Price[6];
Value2 =Value1[3];
Value3 =.75*(Value1 - Value1[6]) + .25*(Value1[2] - Value1[4]);
InPhase = .33*Value2 + .67*InPhase[1];

{Use ArcTangent to compute the current phase}
If AbsValue(InPhase +InPhase[1]) > 0 then Phase =

{Resolve the ArcTangent ambiguity}
If InPhase < 0 and Quadrature > 0 then Phase = 180 - Phase;
If InPhase < 0 and Quadrature < 0 then Phase = 180 + Phase;
If InPhase > 0 and Quadrature < 0 then Phase = 360- Phase;

{Compute a differential phase, resolve phase wraparound, and limit delta phase errors}
DeltaPhase = Phase[1] - Phase;
If Phase[1] < 90 and Phase > 270 then DeltaPhase = 360 + Phase[1] - Phase;
If DeltaPhase < 1 then DeltaPhase = 1;
If DeltaPhase > 60 then Deltaphase = 60;

{Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period.}
InstPeriod = 0;
Value4 = 0;
For count = 0 to 40 begin
Value4 = Value4 + DeltaPhase[count];
If Value4 > 360 and InstPeriod = 0 then begin
InstPeriod = count;
end;
end;

{Resolve Instantaneous Period errors and smooth}
If InstPeriod = 0 then InstPeriod = InstPeriod[1];
Value5 = .25*(InstPeriod) + .75*Value5[1];

{Compute Trendline as simple average over the measured dominant cycle period}
Period = IntPortion(Value5); Trendline = 0;
For count = 0 to Period + 1 begin
Trendline = Trendline + Price[count];
end;
If Period > 0 then Trendline = Trendline / (Period + 2);

Value11 = .33*(Price + .5*(Price - Price[3])) + .67*Value11[1];

if CurrentBar < 26 then begin
Trendline = Price;
Value11 = Price;
end;
Plot1(Trendline, "TR");
Plot2(Value11, "ZL");
end;

Nobody has actually said this indicator is any good ?? But I guess it is if its worth posting the code etc. I like the name too !! I suppose you wouldn't have the code for Metastock ??

I don't see that there is anything instantaneous about it.
It is just an adaptive moving average and will lag the way all moving averages do.

jmreeve said:
I don't see that there is anything instantaneous about it.
It is just an adaptive moving average and will lag the way all moving averages do.

Hence the reason Ehlers published the code and it is being posted on this board. I found a couple of Ehlers other indicators to be more helpful than this one, but all in all I don't think any of them are that great. Just good for education.

I have never used this, I just found it in my library when i read this thread.
Good luck.

Replies
4
Views
646
Replies
0
Views
2K
Replies
18
Views
13K
Replies
2
Views
3K
Replies
2
Views
1K