April 25, 2020

ATR Trailing Stoploss AFL

This is a very simple AFL which plots the SL for a long or short position 3 ATR stops away from close of the currently selected bar.

While the AFL does not define entry, you can consider SL hit as trend reversal and initiate reverse trade.

NOTE:
- ATR stands for Average True Range.... google for more info
- ATR is displayed for currently selected bar (i.e. it is not trailing)
- for a long position, the SL should only move up only when a new high is made and vice versa
- you can use this to define position sizing
- ATR is based on close and default 14 days (or bars).
- ATR stop is set at 3... using 2 will give faster exit at cost of more whipsaws
- you can use this on 5 min, 15 min or daily, weekly charts etc
- this AFL is for Amibroker... ignore it if you don't have/ know Amiboker

AFL Code:



_SECTION_BEGIN("KPL ATR SL");
Plot(SelectedValue(C+ATR(14)*3),"",colorOrange);
Plot(SelectedValue(C-ATR(14)*3),"",colorTeal);
_SECTION_END();



Example chart (NIFTY): 
- green vertical line is currently selected bar (marked with arrow)
- ATR SL is green for long position and red for short position

























No comments:

Post a Comment