Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trading Stocks/Forex with % trailing stop indicator

FYI: This is not implemented in Python platform, but the idea is eyes-open, and can be easily done in Python. Image cannot be added in the post, so i post the links to image.

This is one of my most important breakthrough discoveries over past few years, as I had been studied quant strategies using Excel VBA long before Quantopian comes out, and I regularly published them on my blog : blog.sina.com.cn/caoy1980. I see no similar publication at all on the web space. I think every investor shall know this, to understand how price moves. So let me share it with the English community.

Besides the traditional technical analysis, such as Moving average, Bollinger band, there is a thing called Chandelier Trailing Stop, or in short, trailing stop. Unfortunately, nobody digs it further, until me. I plot the Percentage trailing stop line along the price line, find it very useful to track the price trend. The buy/sell rule is : long when price line (blue) above trailing stop line (red) , and short when price below it. Be aware of double top, and using with moving average, MA(10,20,40,55).

The following charts are self explanatory : SPY daily chart over past 60 trading days (ending 2016Aug19), with MA(10,20), and 1% trailing stop (red line).This is done in Excel.

[IMG]http://oi65.tinypic.com/26455w4.jpg[/IMG]

below is 0.5% trailing stop.
[IMG]http://oi65.tinypic.com/15whzkl.jpg[/IMG]

below is 1 hour chart of Facebook (FB) on MetaTrader4 platform which has build-in mesh-grid, and with 0.5% trailing stop and MA(20).
[IMG]http://oi65.tinypic.com/jr63vr.jpg[/IMG]

For other US stocks, such as AAPL, 1% trailing stop works well. For China stocks, using 3% trailing stop, and 1%/2%(for daily) and 2%/3% (for intraday) trailing stop for China index.

For intraday, 0.3% and 0.5% trailing stop work well for US index ETF such as SPY, and for big stocks like AAPL, 0.5% and 1% trailing stop work well. E.g. the following is ES (mini SPX future) chart on Metatrader4 platform (Asia/Euro hours impact US hours' movement, e.g. double top), 30min time frame, 0.3%/0.5% trailing and MA(20,40). Longer term investor shall look at 4 hour chart, with 0.5% and 1% Trailing stop. You can also code the trailing stop line on the powerful www.tradingview.com platform.

The parameters of trailing stop line, e.g. TSP(1.0%), such as 0.3%, 0.5%, 1%, 2%, 3% are not magic numbers. They are simply the integer numbers, and 0.5% being half of 1%, and 0.3 being half of 0.5%. Thus the methodology is very robust and free of calibration or pre-assumption. Specifically, we select the number such that 1) the price line and trailing stop line have less cross (this favors higher % number), and 2) once the trend reverse e.g. prince line falls below TSP line, the profit is preserved as much as possible (this favors lower %). So there is a trade-off.

The trailing stop line has some very good mathematical features: 1) it is monotone, 2) it is a measurement, i.e. the max distance between price and trailing stop is bounded by the % number, 3) it is a trend-following technique, also can identify non-trending period by flagging out the double top/bottom ( the premise is: a strong trendy price line shall be of low volatility, and the trend is about to reverse when volatility is high, because buyers and sellers are disagreeing).

It also applies to Forex, Bond, Commodity, etc. You can backtest it on your quantopian platforms.