0% found this document useful (0 votes)
121 views2 pages

SVE Trend Trails

The document describes a function called trends_func that calculates trend lines. It initializes trends and support variables, then loops through the bar count. It checks the low prices of the current and previous bars to determine the support level. It also checks the high prices to determine if trends should be set to the previous trends level, support level, or resistance level. The function returns the calculated trends. The rest of the document defines variables to calculate resistance, and calls the trends_func to plot short and long trend lines on the chart.

Uploaded by

maddy_i5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views2 pages

SVE Trend Trails

The document describes a function called trends_func that calculates trend lines. It initializes trends and support variables, then loops through the bar count. It checks the low prices of the current and previous bars to determine the support level. It also checks the high prices to determine if trends should be set to the previous trends level, support level, or resistance level. The function returns the calculated trends. The rest of the document defines variables to calculate resistance, and calls the trends_func to plot short and long trend lines on the chart.

Uploaded by

maddy_i5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

function trends_func(resistance)

{
trends = (H+L)/2; // initialize
support = (H+L)/2; // initialize

for( i = 4; i < BarCount; i++ )


{
// support
prev = support[ i - 1 ];

if (L[ i ] >= L[ i - 2 ]
AND L[ i - 1 ] >= L[ i - 2 ]
AND L[ i - 3 ] >= L[ i - 2 ]
AND L[ i - 4 ] >= L[ i - 2 ])
{
support[ i ] = L[ i - 2 ];
}
else if (L[ i ] > H[ i - 1]*1.0013)
{
support[ i ] = H[ i - 1 ]*0.9945;
}
else if (L[ i ] > prev*1.1)
{
support[ i ] = prev*1.05;
}
else
{
support[ i ] = prev;
}
// trends
prev = trends[ i - 1 ];

if (H[ i ] > prev AND H[ i - 1 ] > prev)


{
trends[ i ] = Max(prev,support[ i ]);
}
else if (H[ i ] < prev AND H[ i - 1 ] < prev)
{
trends[ i ] = Min(prev,resistance[ i ]);
}
else if (H[ i ] > prev)
{
trends[ i ] = support[ i ];
}
else
{
trends[ i ] = resistance[ i ];
}
}
return trends;
}

// AFL code by E.M.Pottasch, 12/28/2010,


// idea from: http://stocata.org/metastock/stop_trail_trends.html
atrfact = Param("atrfact",2, 1, 10, 0.1);
period = Param("period",10, 1, 100, 1);
HiLo = IIf(H-L<1.5*MA(H-L,period),H-L,1.5*MA(H-L,period));
Href = IIf(L<=Ref(H,-1),H-Ref(C,-1),(H-Ref(C,-1))-(L-Ref(H,-1))/2);
Lref = IIf(H>=Ref(L,-1),Ref(C,-1)-L,(Ref(C,-1)-L)-(Ref(L,-1)-H)/2);
diff1 = Max(HiLo,Href);
diff2 = Max(diff1,Lref);
ATRmod = Wilders(diff2,period);
loss = atrfact*ATRmod;
resistance = C + loss;
// calculate trends
trends = trends_func(resistance);

SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );


GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(IIf(trends >
C,trends,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),style
Staircase);
Plot(IIf(trends <
C,trends,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleSt
aircase);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy