# Ehlers Instantaneous Trend Ribbon - Help Pls!

##### Active Member

Can anyone please create a Multi-TF ribbon of this Ehler's Trend ?

All i know is that one can use "inhourly" / "indaily" /
in15mins" etc to code. But how to do it !!??

Please find the code below.. will be grateful if any expert can modify the code to show several ribbons of different timeframes..

thanks!

SetBarsRequired(200, 0);

// Ehlers ITrend
// from Ehlers, John F. Cybernetic Analysis for Stocks and Futures. Wiley. 2004.

// Chapter 3, p. 21. Code on p. 24.

function ITrend(array, alpha)
{
// initialize early array values and declare as array
it = array;
//it = (array[2] - 2*array[1] + array[0])/4; This initialization takes a longtime to converge.
for(i = 2; i < BarCount; i++)
{
it = (alpha - alpha*alpha/4)*array +
.5*alpha*alpha*array[i-1] -
(alpha - .75*alpha*alpha)*array[i-2] +
2*(1 - alpha)*it[i-1] -
(1 - alpha)*(1 - alpha)*it[i-2];
}
return it;
}

function ITrendTrigger(array)
{
trigger = 2*array - Ref(array, -2);
return trigger;
}

Med = (H+L)/2;

// Instantaneous Trend
Plot(Med, "", colorBlack, styleNoDraw);
trend = ITrend(Med, .07);
Plot(trend, "ITrend", colorRed, styleThick);
Plot(ITrendTrigger(trend), "", colorTurquoise, styleThick);

#### giuditta

##### Member
Hi,
try to add simply this strings at the end of the formula. (here a string related to weekly data). check also with intraday chart with inhourly or in15mins instead of "inweekly" parameter.

Plot(TimeFrameExpand(Med,inWeekly),"", colorBlack, styleNoDraw);
Plot(TimeFrameExpand(trend,inWeekly), "ITrend weekly", colorOrange, styleThick);
Plot(TimeFrameExpand(ITrendTrigger(trend),inWeekly), "", colorGreen, styleThick);

##### Active Member
It might be working. Checking it thoroughly this time.
My apologies.

---Ignore Text Bellow---
It displays only the current TF lines correctly..

I am getting 2 parallel horizontal lines after adding your code. May be because of Ehlers functions.

Not successfuly.. But many thanks..

can you check it yourself in AB ?

#### johntashix

##### New Member
please use this script to be able to extend multi timeframe capability.

//Source
src = (High + Low)/2;
itrend = 0;

start = NullCount(Close);

for(i = 2; i < BarCount; i++)
{
if(i < start)
{
itrend = src;
lag = itrend;
}
else
{
if(i < start + 4)
{
itrend = ((src +
2*src[i-1]+src[i-2])/4);
}
else
{
itrend = (Alpha - Alpha *Alpha/4)*src +
0.5*Alpha*Alpha*src[i-1] -
(Alpha-0.75*Alpha*Alpha)*src[i-2] +
2*(1-Alpha )*itrend[i-1] -
(1-Alpha )*(1-Alpha )*itrend[i-2];
}

lag = 2*itrend - itrend[i-2];

}
}