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)
almost 10 years ago
Amibroker (AFL)

3 / 5 (Votes 8)
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.


Similar Indicators / Formulas

Submitted by allexiss almost 9 years ago
Submitted by saas almost 7 years ago
JMA Stoploss
Submitted by kuzukapama almost 9 years ago
TSL & HL & New
Submitted by morgen about 8 years ago
Stop Loss Indicator
Submitted by nabcha about 10 years ago
ABKP Benchmark Bar
Submitted by amitabh about 10 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);



1. kv_maligi

Very good.

Please add aslo Buy sell signals if possible


2. jeanmuller

Can you add Buy and Sell signal’s please?


Leave Comment

Please login here to leave a comment.