Amibroker: How to Code the ATR Trailing Stop (Chandelier) using ApplyStop

Line1

Beginners Course  |  Intermediate Course  |  Amibroker Course Home

The ATR Stop, used mostly as a trailing stop loss and also known as a chandelier stop, is one of the most popular methods of trailing stop loss used by traders and investors.

ATR stands for Average True Range, in other words it is the Average range (from high to low) of the last “x” amount of bars.

Why is this useful?  Well, if we are using the average range of the last “x” amount of bars, and that average changes as the market moves on, then the ATR will change as well.  In other words – it is adjusting for volatility.  If we have large, wide daily ranges, we get a larger ATR value.  If we have small, neat daily ranges, we get a smaller ATR value.

Using this as our trailing stop helps our stop loss adjust, too.

Check out the video below,I hope you enjoy, and please leave a comment!

The main part of our code is this:

  • stopLength = ( 3 * ATR(10) );

This sets up the ATR stop length we want to use, and then:

  • Sell = 0;
  • ApplyStop(stopTypeTrailing, stopModePoint, stopLength, 2, True, 1 );

You may need to actually type it in, to avoid formatting errors of cut and paste 🙂

You can see all the details and examples of ApplyStop at the Amibroker Knowledge base article.

I hope this helps, happy trending and enjoy!

– Dave McLachlan

Beginners Course  |  Intermediate Course  |  Amibroker Course Home

Videos in the FREE Amibroker Course:

  1. Amibroker: How To Import A Watchlist With A CSV File
  2. Amibroker: How To Backtest A Single Stock Or Index
  3. Amibroker: How To Backtest a Portfolio or Group of Stocks
  4. Amibroker: How To Optimize A Trading System
  5. Amibroker: How To Scan The Market For Buy And Sell Signals
  6. Amibroker: How To Use Explore To Find And Filter Stocks
  7. Amibroker: How To Add Position Sizing Using AFL
  8. Amibroker: How to Add An Index Filter To Your Trading System Using AFL
  9. Amibroker: How To Plot Your Trading System On A Chart (incl. Buy/Sell Arrows)
  10. Amibroker: How to Use the If, Then Else Function (IIF)
  11. Amibroker: How to Code the ATR Trailing Stop (Chandelier) using ApplyStop
  12. Amibroker: How to Plot ApplyStop on a Chart
  13. Amibroker: How to Code Van Tharp Position Sizing (Fixed Fractional)
  14. Amibroker: How to “Scale In” to Positions (1) – Buying Once a Month
  15. Amibroker: How to “Scale In” to Positions (2) – Pyramiding Three Times
  16. Amibroker: How to Use “Cross”, When One Thing Crosses Another
  17. Amibroker Advanced: How to Compare Equity Curves

FREE Trading System Video Lessons:

  1. 7 Free Trading Systems and Their Returns From The Last 13 Years
  2. Seven Full Trading Systems Revisited, With Completely New Data
  3. Trading System: How to Create A Buy and Hold Trading System
  4. Trading System: How to Code “Sell In May And Go Away”
  5. Trading System: How to Code a Moving Average Channel That Made 23% p.a
  6. Trading System: How to Code Highest Highs As Used In 52 Week Highs Or Turtle Trading System
  7. Trading System: How to Code a Bollinger Band Breakout Trading System
  8. Trading System: How to Code a Moving Average Crossover That Returned 28% per annum
  9. Trading System: How to Refer to Previous Signals For MAup Trading System
  10. Trading System: How to Code the Leap Of Faith (Gaps) Trading System That Returned 24% p.a.
  11. Trading System: How to Code a Short Selling System (Plus Results)
  12. Trading System: Meb Faber Trading System Using Different Timeframes
  13. Trading System: How to Code the Three Billion Dollar Trading System

FREE Amibroker Q & A Videos:

  1. Amibroker Q & A: How To Do A Monte Carlo Test? (on ALL versions)
  2. Amibroker Q & A: Visualising Monte Carlo Data with Histograms and Scatter Plots
  3. Amibroker Q & A: How to Create the 52 Week High/Low Index with AddToComposite
  4. Amibroker Q & A: How to Code Trend Pilot: Five Consecutive Days Above or Below a Moving Average
  5. Amibroker Q & A: Three “Hacks” To Improve Your Coding Skills
  6. Amibroker Q & A: How to Remove Excess Signals

Read Related Articles:




  And, subscribe for free to stay in touch and receive the latest updates:

Enter Your Email Address:

.
(Check Your Junk Mail, Just In Case)

January 3, 2016  Tags: , , , , , , ,   Posted in: Amibroker Course

One Response

  1. Craig Bugden - May 10, 2017

    This Course is very good, I would like to get more info from this site.

Leave a Reply