// Downloaded From https://www.WiseStockTrader.com _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();