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

trailing sl for Amibroker (AFL)

Rating:
3 / 5 (Votes 3)
Tags:
trading system, amibroker, stop loss

trailing sl formula

Screenshots

Similar Indicators / Formulas

Visual ATR Stop Loss System
Submitted by siivaramm over 8 years ago
Buy Sell & Trailing SL & TGL
Submitted by morgen almost 7 years ago
ATR Stop Loss System
Submitted by esnataraj over 8 years ago
KPL System
Submitted by na1982 almost 9 years ago
Chandelier Exit v2 by Geoff Mulhall
Submitted by akxsat almost 9 years ago
Ensign Volatility Stop
Submitted by kaiji almost 9 years ago

Indicator / Formula

Copy & Paste Friendly
StopLevel = 1 - Param("trailing stop %", 3, 0.1, 10, 0.1)/100;

Buy = Cross( MACD(), Signal() );
Sell = 0;
trailARRAY = Null;
trailstop = 0;

for( i = 1; i < BarCount; i++ )
{

   if( trailstop == 0 AND Buy[ i ] ) 
   { 
      trailstop = High[ i ] * stoplevel;
   }
   else Buy[ i ] = 0; // remove excess buy signals

   if( trailstop > 0 AND Low[ i ] < trailstop )
   {
      Sell[ i ] = 1;
      SellPrice[ i ] = trailstop;
      trailstop = 0;
   }

   if( trailstop > 0 )
   {   
      trailstop = Max( High[ i ] * stoplevel, trailstop );
      trailARRAY[ i ] = trailstop;
   }

}

PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);

Plot( Close,"Price",colorBlack,styleBar);
Plot( trailARRAY,"trailing stop level", colorRed );

2 comments

1. sikandar

Hi its only for Longs,Can you code for shorts

2. morgen

This is very good for a percent stop level, also for buy with MACD with other indicators to add in the formula.
Thank you

Leave Comment

Please login here to leave a comment.

Back