Does anybody have Vortex and Supertrend user defined function? I need use these functions basically call then in other program.

Hi All,
Request to help with Vortex and Supertrend user defined function , which can be called in other AFl.

Regards
gpsnitie

Thanks.
I do get the AFL , but how do I convert it to function?

I know the concept, need introduce variables and return the value but still.

The entire AFL function is at the bottom of the page, you don't need to "convert" anything. Here it is again:

function SuperTrend(lenATR, width)
{
	nATR = ATR(lenATR);
	pAvg = (H+L) / 2;
	
	upperBand = pAvg + width * nATR;
	lowerBand = pAvg - width * nATR;
	isUpTrend = True;
	dn = DateNum();
	
	for (i=lenATR; i<BarCount; ++i)
	{
		if (C[i] > upperBand[i-1])
			isUpTrend[i] = True;
		else if (C[i] < lowerBand[i-1])
			isUpTrend[i] = False;
		else
			isUpTrend[i] = isUpTrend[i-1];
			
		if (isUpTrend[i])
			lowerBand[i] = Max(lowerBand[i], lowerBand[i-1]);
		else
			upperBand[i] = Min(upperBand[i], upperBand[i-1]);
			
		//_TRACE(NumToStr(dn[i], 8.0, False)+": Close="+C[i]+" isUpTrend="+isUpTrend[i]+" upperBand="+upperBand[i]+" lowerBand="+lowerBand[i]);
	}
	
	super = IIf(isUpTrend, lowerBand, upperBand); 	
	return super;
}
3 Likes

@gpsnitie the Vortex indicator from January 2010 Technical Analysis of Stocks & Commodities,

http://www.amibroker.com/members/traders/01-2010.html

2 Likes