Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Volatility Stop Indicator (VSTOP) for Amibroker (AFL)
kaiji
about 14 years ago
Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
amibroker, stop loss, volatility

Below code how to call the volatility stop procedure. The procedure returns trailing stop loss. This array can be used to define entries or exits.

For an example on how to use this formula click here

Thanks to E.M.Pottasch for this formula and its improvements

Screenshots

Similar Indicators / Formulas

Volatility system
Submitted by adelnet about 14 years ago
ATR-based trailing stop
Submitted by amifan almost 14 years ago
TSL & HL & New
Submitted by morgen almost 12 years ago
Stop Loss Indicator
Submitted by nabcha about 14 years ago
ABKP Benchmark Bar
Submitted by amitabh about 14 years ago
Profit Trailing Stoploss
Submitted by drpragnesh40 almost 11 years ago

Indicator / Formula

Copy & Paste Friendly
// E.M.Pottasch, Jul 2010
// from Metastock formula, link: http://stocata.org/metastock/stop_trail_atr.html
// added separate parameters for upward and downward market environment

function vstop_func(trBull,trBear)
{
	trailArray[ 0 ] = C[ 0 ]; // initialize
	for( i = 1; i < BarCount; i++ )
	{
		prev = trailArray[ i - 1 ];
 
		if (C[ i ] > prev AND C[ i - 1 ] > prev)
		{
			trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
		}
		else if (C[ i ] < prev AND C[ i - 1 ] < prev)
		{
			trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
		}
		else if (C[ i ] > prev)
		{
			trailArray[ i ] = C[ i ] - trBull[ i ];
		}
		else
		{
			trailArray[ i ] = C[ i ] + trBear[ i ];	
		}
	}
	return trailArray;
}

per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);

trBull = multBull * ATR(per);
trBear = multBear * ATR(per);

trailArray = vstop_func(trBull,trBear);

SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(IIf(trailArray > C,trailArray,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),styleStaircase);
Plot(IIf(trailArray < C,trailArray,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleStaircase);
Plot( C, "\nCandle",colorWhite, styleCandle );

7 comments

1. empottasch

I updated this formula, see also Amibroker library (VSTOP 3).

2. administrator

Thanks I have updated the formula.

3. morgen

The best formula for both Buystop and Sellstop!
Thank You E.M.Pottasch

4. kv_maligi

Very Good.

Thanks
Viswanath

5. kv_maligi

Dear Sir,

I admire your tech capabilities & knowledge in this field of trading.

I read your comments that you are developing/working on new system/indicator.

If it is done, kinldy update and paste in the wisestocktrader.com

Once again thanks & regards,

Viswanath MK

6. Say-HI

good

7. parfumeur

Any location to find the vstop_proc.afl file ?? Needed in the Pastie #7 = Volatility Stop Usage Example.afl

Leave Comment

Please login here to leave a comment.

Back