Forex Education

Trading industry knowledge. Learn forex trading, investing in stocks, commodities.

  • Home
  • Choose a broker
  • Brokers Rating
  • PAMM
  • Investment
  • Affiliate
  • Contact
  • About us
You are here: Home / Education / Forex indicators / What is ATR trailing stop? Download ATR Trailing Stop EA

What is ATR trailing stop? Download ATR Trailing Stop EA

by Fxigor

ShareTweet

To form a profitable trading strategy, it is important to know when to enter and exit the trade. While most traders use several tools to enter a trade, they often fail to comprehend when to exit. A perfect exit point helps traders do their job without added mental pressure as it relieves them from added mental pressure. While many tools and indicators can help you find the exit spot, the Average True Range Trailing Stops, or the ATR Trailing Stops, is deemed one of the best. Traders majorly use it to protect their capital. You can use it for individual trades where it can be used to lock in individual profits. When used alongside a trend filter, it can also be used to find entries.

What is ATR trailing stop?

ATR Trailing Stops or Average True Range Trailing Stop represents the process of setting trailing stops to close positions based on the average true range. Stop loss is determined based on a measure of the degree of price volatility (Average True Range)  in order to protect capital and lock in profits on individual trades.

 

How to Time Exits Using the ATR Trailing Stops

The concept of Average True Range was first introduced in 1978 by J. Welles Wilder. Stock or index volatility is measured using the ATR, and the detailed explanation could be found at the Average True Range. In the initial stages, Volatility Stops that follow trends were used with the Average True Range by Wilder. This experiment later helped in the development of Average True Range Trailing Stops.

atr trailing stop on chart

ATR Trailing Stop Loss Strategy

You can use the ATR Trailing Stop to identify exit signals for both short and long positions:

  • For a long position, the exit position will be a sell position. It would help if you exited when prices cross below the trailing line created by the ATR.
  • For a short position, the exit position will be a buy position. It would help if you exited when prices move above the trailing line created by the ATR.

Example

The given graph shows the downtrend, which is highlighted with the ATR’s help. It also has the 63-day exponential MA that has been used here as the trend filter.

atr strategy forexinrs

According to this graph:

  • When the price gets closed below the ATR, but the exponential average remains close, you must go short.
  • As soon as the price cross above the ATR trend line, you must exit.

Setting Up ATR Trailing Stops

The ATR time period can be set from 5 to 21 days. While the developer suggests setting it for 7 days for general trading, 21-days for long-term trading, and 5-days for short-term trading. For trailing stops, multiples ranging from 2.5 to 3.5 times the ATR. The lower multiples can get more susceptible to whipsaws. 

The default setting is 3X21 day ATR. The Closing Price is also set as default.

The ATR Formula

  1. Calculate the ATR trailing stop using the following method:
  2. Average True Range (ATR), a volatility indicator that compares each day’s range to measure commitment, is calculated.
  3. The result is multiplied by the chosen multiple, 3XATR, in this example.
  4. If there is an uptrend, the result from step 2 is subtracted from the Closing Price. This will be your stop for the next day.
  5. The result from step 2 is added to the closing price if the prices close below the ATR stop. This is done to track short trade.
  6. If the prices do not close below the ATR, keep subtracting 3XATR from every following day. This will continue till the price reverse below the ATR stop.

The Evolution of  the ATR Trailing Stops

The ATR stops are susceptible to whipsaws unless the trend is strong. This makes them more volatile than the rest. To avoid this volatility, you must use it with a trend filter. These stops are highly adaptive to changing market conditions than their counterparts, like the Percentage Trailing Stop. However, it yields similar results if you are applying it to stocks. Keep in mind that these need to be filtered for strong trends. 

There are two possible weaknesses of Volatility Stops and the original ATR. These are:

  • In an uptrend, the stop moves downwards when the ATR widens. A ratchet mechanism can be deployed to deal with this weakness.
  • The Reverse-and-Stop mechanism conjectures that you will be switching to a short position as soon as you stop out of a long position. The opposite is true, as well. When you are in a system that follows trends, it is widespread to exit early and get the next entry in the previous trade’s direction. You can deal with this problem by using ATR Bands.

ATR trailing stop EA

Please download ATR trailing stop EA.

This EA, please do not use for trading because trading rules are not defined. However, using this code, you can add entry rules and use ATR trailing stop for trading.

The main idea of ATR trailing EA is this code:

Copy Code Copied! Use a different Browser
                    

//–
void SendOrder(double _stop,double _take)//Order send module buy/sell
{
//—
atr = iATR(Symbol(), atrTf, atrPer, 0);
atrSL =(atr * _stop / _point);
atrTP =(atr * _take / _point);
//—
switch(Ordertype)
{
case _buy: //Buy order
_mode =OP_BUY;
pricemode = Ask;
col = Green;
_type=”BUY”;
_SL = Ask – atrSL * _point;
_TP = Ask + atrTP * _point;
break;
case _sell://Sell order
_mode = OP_SELL;
pricemode = Bid;
col = Red;
_type=”SELL”;
_SL = Bid + atrSL * _point;
_TP = Bid – atrTP * _point;
break;
}
if(CheckMoneyForTrade(Symbol(),_mode,LotSize()))
Ticket=OrderSend(Symbol(),_mode,LotSize(),pricemode,5,0,0,WindowExpertName(),MagicNumber,0,col);
if(Ticket<1)
{
Print(“Order send failed, OrderType : “,(string)_type,”, errcode : “,GetLastError());
return;
}
else
Print(“OrderType : “,(string)_type,”, executed successfully!”);
if(OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))
{
if(!OrderModify(OrderTicket(), OrderOpenPrice(), _SL, _TP, 0))
{
Print(“Failed setting TP/SL OrderType : “,(string)_type,”, errcode : “,GetLastError());
return;
}
else
Print(“Successfully setting TP/SL on OrderType : “,(string)_type);
}
}
//–
int Position()//This function prevents this adviser from interfere with other experts you may use on same account
{ // It checks and handle it’s own orders.
int dir=0;
for(int i = OrdersTotal() – 1; i >= 0; i–)
{
if(!OrderSelect(i, SELECT_BY_POS))
break;
if(OrderSymbol()!=Symbol()&&OrderMagicNumber()!= MagicNumber)
continue;
if(OrderCloseTime() == 0 && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType() == OP_SELL)
dir = -1; //Short positon
if(OrderType() == OP_BUY)
dir = 1; //Long positon
}
}
return(dir);
}
//–

Conclusion

It is important to use the right tools to spot exit signals. You will be in a better position by using the Average True Range Trailing Stops combined with a trend filter.

  • Author
  • Recent Posts
Fxigor
Fxigor
Trader since 2007. Currently work for several prop trading companies.
Fxigor
Latest posts by Fxigor (see all)
  • What Time Does the Forex Market Open on Sunday?
  • Candlestick Reversal Patterns List
  • List of Volatility Indicators

Related posts:

  1. What Does Trailing Stop Mean?
  2. How ATR Stop Loss Strategy Can Improve Your Trading?
  3. Donchian Channel Indicator in Details – Free Download
  4. What is Stop Loss Order?
  5. The High Low Moving Average – Free Download Indicator
  6. Chaikin Volatility Bands Indicator – Free Download Chaikin Volatility Indicator
  7. Download MACD Indicator with Two Lines for MT4
  8. Choppiness Index indicator – Download Free
  9. RSI Filter Indicator – Free Download
  10. How to Set Stop Loss in Forex?
  11. Free Download True Strength Index TSI Indicator

Filed Under: Forex indicators

Website categories

Main Forex Info

  • Forex Calendar 2020
  • Forex Holidays Calendar 2021 – National Public Bank Holidays List
  • Non-Farm Payroll Dates 2021
  • Key Economic Indicators
  • The Best Forex Brokers Ratings List
  • Top Forex brokers by Alexa Traffic Rank
  • Forex Brokers with Free Initial Deposit in 2020
  • Brokers That Accept PayPal Deposits
  • What is PAMM in forex? Are PAMM Accounts Safe?

Main navigation:

  • Home
  • About us
  • Forex brokers reviews
  • MT4 EA
  • Education
  • Privacy Policy
  • Risk Disclaimer
  • Contact us

Forex social network

  • RSS
  • Twitter
  • FxIgor Youtube Channel
  • Sign Up. Get newsletter.

Spanish language – Hindi Language

Spanish language website Hindi language website
Risk Warning: Trading leveraged products such as Forex and CFDs may not be suitable for all investors as they carry a high degree of risk to your capital. Trading such products is risky and you may lose all of your invested capital. Before deciding to trade, please ensure that you understand the risks involved, taking into account your investment objectives and level of experience.

Copyright Forex.in.rs 2007