Dark Theme
Light Theme
Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
June 1st, 2014, 03:21 PM
Toronto, Canada
Experience: Advanced
Platform: Amibroker, Multicharts
Trading: Stocks
Posts: 3 since Mar 2013
Thanks Given: 0
Thanks Received: 1
A few good examples of trailing stops in Amibroker .
From the Traders Tips section of Technical Analysis of Stocks and Commodities magazine, May 2009:
Version(5.20); // requires v5.20
SetBarsRequired(sbrAll);
// get start date
Start = Cross( DateNum(), ParamDate(„Start date”, „2005-10-30” ) );
Started = Flip( Start, 0 );
StopMode = ParamToggle(„Stop Mode”, „Fixed|Chandelier” );
StopLevel = Param(„Fixed perc %”, 14, 0.1, 50, 0.1)/100;
StopATRFactor = Param(„Chandelier ATR multiple”, 4, 0.5, 10, 0.1 );
StopATRPeriod = Param(„Chandelier ATR period”, 14, 3, 50 );
// calculate support and resistance levels
if( StopMode == 0 ) // fixed percent trailing stop
{
sup = C * ( 1 - stoplevel );
res = C * ( 1 + stoplevel );
}
else // Chandelier ATR-based stop
{
sup = C - StopATRFactor * ATR( StopATRPeriod );
res = C + StopATRFactor * ATR( StopATRPeriod );
}
// calculate trailing stop line
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( Started[ i ] == 0 ) continue;
if( C[ i ] > trailstop AND C[ i - 1 ] > trailstop )
trailstop = Max( trailstop, sup[ i ] );
else
if( C[ i ] < trailstop AND C[ i - 1 ] < trailstop )
trailstop = Min( trailstop, res[ i ] );
else
trailstop = IIf( C[ i ] > trailstop, sup[ i ], res[ i ] );
trailARRAY[ i ] = trailstop;
}
// generate buy/sell signals based on crossover with trail stop line
Buy = Start OR Cross( C, trailArray );
Sell = Cross( trailArray, C );
PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray);
PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray);
Plot( Close,”Price”,colorBlack,styleBar);
Plot( trailARRAY,”trailing stop level”, colorRed );
—Tomasz Janeczko
May 2nd, 2015, 08:51 AM
wadi hof + cairo/EGYPT
Posts: 2 since Sep 2014
Thanks Given: 0
Thanks Received: 0
jlwtrading
A few good examples of trailing stops in Amibroker.
From the Traders Tips section of Technical Analysis of Stocks and Commodities magazine, May 2009:
Version(5.20); // requires v5.20
SetBarsRequired(sbrAll);
// get start date
Start = Cross( DateNum(), ParamDate(„Start date”, „2005-10-30” ) );
Started = Flip( Start, 0 );
StopMode = ParamToggle(„Stop Mode”, „Fixed|Chandelier” );
StopLevel = Param(„Fixed perc %”, 14, 0.1, 50, 0.1)/100;
StopATRFactor = Param(„Chandelier ATR multiple”, 4, 0.5, 10, 0.1 );
StopATRPeriod = Param(„Chandelier ATR period”, 14, 3, 50 );
// calculate support and resistance levels
if( StopMode == 0 ) // fixed percent trailing stop
{
sup = C * ( 1 - stoplevel );
res = C * ( 1 + stoplevel );
}
else // Chandelier ATR-based stop
{
sup = C - StopATRFactor * ATR( StopATRPeriod );
res = C + StopATRFactor * ATR( StopATRPeriod );
}
// calculate trailing stop line
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( Started[ i ] == 0 ) continue;
if( C[ i ] > trailstop AND C[ i - 1 ] > trailstop )
trailstop = Max( trailstop, sup[ i ] );
else
if( C[ i ] < trailstop AND C[ i - 1 ] < trailstop )
trailstop = Min( trailstop, res[ i ] );
else
trailstop = IIf( C[ i ] > trailstop, sup[ i ], res[ i ] );
trailARRAY[ i ] = trailstop;
}
// generate buy/sell signals based on crossover with trail stop line
Buy = Start OR Cross( C, trailArray );
Sell = Cross( trailArray, C );
PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray);
PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray);
Plot( Close,”Price”,colorBlack,styleBar);
Plot( trailARRAY,”trailing stop level”, colorRed );
—Tomasz Janeczko
please , i need to change the start date from long side to short side
thanks
Last Updated on May 2, 2015