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

Jim Berg Stop Loss for Amibroker (AFL)

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

In “The Truth About Volatility,” Jim Berg presents how to use several well-known volatility measures such as average True range (ATR) to calculate entry, trailing stop, AND profit-taking levels. Implementing techniques presented in the article is very simple using the AmiBroker Formula Language (Afl), AND takes just a few lines of code.

Listing 1 shows the formula that the plots color-coded price chart, trailing stop, AND profit-taking lines, as well as a colored ribbon showing volatility-based entry AND exit signals. The relative strength index (RSI) used by Berg is a built-in indicator in AmiBroker, so no additional code is necessary. See Figure 3 for an example.

Screenshots

Similar Indicators / Formulas

NRTR WATR
Submitted by allexiss about 8 years ago
DODA BAND BUY SELL
Submitted by saas over 6 years ago
JMA Stoploss
Submitted by kuzukapama over 8 years ago
TSL & HL & New
Submitted by morgen over 7 years ago
Stop Loss Indicator
Submitted by nabcha over 9 years ago
ABKP Benchmark Bar
Submitted by amitabh over 9 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Jim Berg Volatility Stop Loss");
P = ParamField("Price field",-1);
Periods = Param("Periods", 170, 2, 200, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 

TwoAtr =  2 * ATR( 10 );
EntrySignal = C > ( LLV( L, 20 ) + TwoAtr); 
ExitSignal = C < ( HHV( H, 20 ) - TwoAtr);
TrailingStop = HHV( C - TwoAtr, 15 ); 
ProfitTarget = EMA( H, 13 ) + TwoAtr; 

Plot( TrailingStop, "Trailing Stop Loss", colorBrown, styleThick | styleLine ); 
Plot( ProfitTarget, "Profit Target", colorLime, styleThick ); 
Plot( C, "Price", IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorRed, colorGrey50 )), styleBar | styleThick ); 

Buy = EntrySignal;
Sell = ExitSignal or Cross(TrailingStop, C) OR Cross(C, ProfitTarget);

_SECTION_END();

2 comments

1. kv_maligi

Very good.

Please add aslo Buy sell signals if possible

thanks
viswanath

2. jeanmuller

Can you add Buy and Sell signal’s please?

Thanks!!

Leave Comment

Please login here to leave a comment.

Back