Improving A Trading Strategy
I: Introduction – Improving the TD Sequential Long Strategy from Base Working Scripts Example
TD Sequential is a technical indicator for stock trading developed by Thomas R. DeMark in the 1990s. It uses bar plot of stocks to generate trading signals. The recognition of a buy signal involves three steps. Step one is the identification of a bear flip, where a bar whose close is higher than that of four bars earlier appears, followed by a bar whose close is lower than the close four bars prior. Step two involves counting 9 consecutive bars, each close lower than the close four bars prior. The third step, called countdown stage, is optional, which requires the trader to count 13 close prices lower than the low price two minutes earlier before entering a long position.
Several elements could be modified in this strategy. Whether to include the countdown stage, the choice of the number of bars in the setup stage and countdown stage, the parameters that help to decide when to exit and the size of the trade will affect strategy performance. In addition, we could use information other than price to decide whether the signal should be traded.
Part II is a comparison of the strategy performance by adjusting the aforementioned elements. Part III discusses the effect of adding Bloomberg’s social sentiment data to support trade decisions. For simplicity and control of variable purposes, all tests used AAPL one-minute bar data, and the time range of backtests was the first half of the year 2016.
II: The effect of modifying strategy parameters
1. Base strategy
The base strategy does not execute the countdown stage, which means a long position will be traded as soon as the setup stage is complete. Constant values are set for stop limit and stop loss (15 cents above and 30 cents below the entry price). Positions will be closed out before market close regardless of price levels. Trade size is set to be constant at 100.
Below is a brief summary of the performance of the base strategy in the first six months of the year 2016. All calculations include commission fees.
The plots above show that for the given parameters, the daily returns of the base strategy were pretty volatile and negatively skewed. PnL plummeted in the first week, and then oscillated at the level of -400. The Sharpe ratio of the base strategy was negative, and the trade win percentage was a little more than a half.
|Sharpe Ratio||-0.81||Maximum Drawdown||-5.24%|
|Total Return||-2.68%||Avg Trade Duration||27 min 55 sec|
|Total Profit||111.01||Total Edge/Share||0.13 cents|
|Total Net Profit||-300.13||Net Edge/Share||-0.35 cents|
|Trade Win Percentage||57.65%||Daily Win Percentage||52.00%|
|Return Skewness||-0.43||Return Kurtosis||3.82|
|Number of Trades||425||Total Trading Days||125|
|Max Daily Gain||1.34 %||Max Daily Loss||-1.43%|
Changing exit rules
Choice of stop profit and stop loss levels would determine when to exit a position, affecting the duration and number of trades and strategy PnL.
The following backtest used the same parameters as the base strategy, except that the levels of stop profit and stop loss were set to 35 cents above and 50 cents below the entry price, respectively. The change was able to improve PnL and other performance indicators.
|Sharpe Ratio||1.00||Maximum Drawdown||-6.43%|
|Total Return||4.83%||Avg Trade Duration||1 hr 9 min|
|Total Profit||834.00||Total Edge/Share||1.38 cents|
|Total Net Profit||541.65||Net Edge/Share||0.90 cents|
|Trade Win Percentage||54.64%||Daily Win Percentage||53.60%|
|Return Skewness||-0.42||Return Kurtosis||3.18|
|Number of Trades||302||Total Trading Days||125|
|Max Daily Gain||1.18 %||Max Daily Loss||-1.89%|
Instead of using constant values, we could also set stop profit/loss levels to be dependent on the TD Setup trend range. The TD setup trend (TDST) is the price extremes during the setup stage of the TD signal. The magnitude of this range reflects the volatility of stock prices in the time period of the signal recognition process.
In the backtest below, the rule is to exit the market once the low price exceeds the entry price by two times the TDST range, or falls below the entry price by one TDST range.
Compared with the base strategy, modifying the exit rule improved strategy PnL in the backtest period. Performance in February and March improved significantly. The daily return was less volatile in the following three months compared with the strategy using constant-level exit rules although the overall trend was slightly declining. However, the PnL drop at the start of the year still existed, and the strategy still had large drawdowns.
|Sharpe Ratio||0.87||Maximum Drawdown||-8.50%|
|Total Return||5.32%||Avg Trade Duration||2 hr 8 min|
|Total Profit||814.00||Total Edge/Share||1.80 cents|
|Total Net Profit||595.30||Net Edge/Share||1.32 cents|
|Trade Win Percentage||44.25%||Daily Win Percentage||51.20%|
|Return Skewness||-0.11||Return Kurtosis||3.47|
|Number of Trades||226||Total Trading Days||125|
|Max Daily Gain||1.86%||Max Daily Loss||-2.06%|
As could be seen from the chart above, the number of trades dropped by around a half after the exit rule is changed and the average trade duration increased greatly. Consequently, total commission paid was lower, and the magnitude of maximum daily gains and losses were higher.
Using high, low and close of minute bar
In the base strategy, close prices are used to recognize buy signals, and minute low prices are used for the calculation of whether stop profit/loss levels have been reached. If close prices are used to determine when to exit instead of low prices, it will be easier to hit stop profit and harder to hit stop loss. A comparison of the backtest result, holding other parameters unchanged, is as follows:
|Sharpe Ratio||0.85||Maximum Drawdown||-6.85%|
|Total Return||4.88%||Avg Trade Duration||1 hr 49 min|
|Total Profit||786.00||Total Edge/Share||1.59 cents|
|Total Net Profit||546.89||Net Edge/Share||1.11 cents|
|Trade Win Percentage||45.75%||Daily Win Percentage||50.40%|
|Return Skewness||-0.11||Return Kurtosis||3.45|
|Number of Trades||247||Total Trading Days||125|
|Max Daily Gain||1.79%||Max Daily Loss||-2.16%|
In this case, the number of trades increased from 226 to 247, but the Sharpe Ratio dropped from 0.87 to 0.85. Greater PnL was achieved in the first quarter, but there was also a greater loss in the second quarter.
Changing trade positions
We could also change positions traded in the strategy instead of using constant values. For example, we could adjust positions so that a fixed percentage of capital is invested for each trade. Below is the backtest result where the percentage of traded capital was set to 20%.
Adding TD countdown stage and more rules to the signal
Some details in the rules of the TD sequential strategy, including whether to execute the countdown stage for the determination of the trading signal, or to wait for a bear flip before entering a position, affects the length of the minute bars required for signal recognition and thus will have an impact on the strategy PnL.
The following strategy requires a new low to be reached in the last two bars of the setup stage before entering a long position, and uses TDST range to calculate stop prfit/loss levels. Result of the backtest shows that this additional rule doesn’t seem to increase the trade win probability, and the change in the number of trades and strategy PnL is minor.
|Sharpe Ratio||0.70||Maximum Drawdown||-5.95%|
|Total Return||3.89%||Avg Trade Duration||2 hr|
|Total Profit||641.99||Total Edge/Share||1.51 cents|
|Total Net Profit||435.88||Net Edge/Share||1.02 cents|
|Trade Win Percentage||47.42%||Daily Win Percentage||49.59%|
|Return Skewness||-0.17||Return Kurtosis||3.48|
|Number of Trades||213||Total Trading Days||125|
|Max Daily Gain||1.79%||Max Daily Loss||-2.10%|
Adding countdown stage to the strategy greatly increases the length of bars required for buy signal recognition. Based on the result of the backtests, this step doesn’t help to increase the probability of recognizing a successful trade, nor does it improve backtest PnL.
III: Using Social Sentiment Data to modify TD Sequential Strategy
Bloomberg Event-Driven Feed Social Analytics is a dataset that measures collective social sentiment. It uses score and confidence to measure investors’ sentiment in holding stocks after reading financially-relevant tweets. Sentiment data could be interpreted as a prediction on short-term stock market movement, and may be helpful in determining whether it is a good time to enter the market.
In this part, the TD sequential strategy is modified so that the stock is traded based on the TD buy signal as well as social sentiment data. When the pattern of stock minute bars is recognized as a TD sequential buy signal, sentiment up to that time is evaluated, so as to avoid buying stock when the social sentiment is generally negative. At any given time, available same-day sentiment time series is converted to a single value and be compared to a predefined threshold. Earlier information is assigned lower weight in the calculation of the current sentiment. The weight decays exponentially as the sentiment information becomes older.
In the backtest below, exit rule same as the one mentioned in part II was used (with the use of TDST range). The threshold for the weighted sentiment score was 2.0.
Using sentiment data reduced the number of trades and lowered the volatility of strategy PnL. The volatility of returns in the backtest period dropped from 11.50% to 8.87% compared with the performance without sentiment data, improving the Sharpe ratio. The maximum drawdown also decreased from 8.5% to 2.7%. As could be seen from the distribution plots above, strategy with sentiment data had fewer large negative returns.
|Sharpe Ratio||1.28||Maximum Drawdown||-2.66%|
|Total Return||3.03%||Avg Trade Duration||1 hr 37 min|
|Total Profit||814.00||Total Edge/Share||2.25 cents|
|Total Net Profit||432.01||Net Edge/Share||1.76 cents|
|Trade Win Percentage||43.75%||Daily Win Percentage||44.62%|
|Return Skewness||0.73||Return Kurtosis||3.98|
|Number of Trades||96||Total Trading Days||123|
|Max Daily Gain||1.92%||Max Daily Loss||-1.28%|
Trade Win Percentage under different Sentiment Threshold
|Sentiment threshold||No sentiment||0||1||2||3|
|Trade win percentage||45.3%||43.9%||44.7%||47.3%||40.4%|
Number of Trades with Lowest 10% PnL under different Sentiment Threshold
|Sentiment threshold||No sentiment||0||1||2||3|
|Number of trades||27||11||11||10||8|
Including the sentiment data didn’t help to improve the probability of getting positive PnL from a trade, but it did decrease the number of trades with big losses.
The plot below demonstrated performance of the strategy same as above but traded six liquid tech stocks: AAPL, MSFT, FB, CSCO, TWTR and INTC.
|Sharpe Ratio||0.70||Maximum Drawdown||-1.15%|
|Total Return||1.17 %||Avg Trade Duration||1 hr 34 min|
|Total Profit||632.00||Total Edge/Share||1.11 cents|
|Total Net Profit||367.86||Net Edge/Share||0.65 cents|
|Trade Win Percentage||39.30%||Daily Win Percentage||43.64%|
|Return Skewness||0.62||Return Kurtosis||4.81|
|Number of Trades||285||Total Trading Days||126|
|Max Daily Gain||0.87%||Max Daily Loss||-0.73%|
 Perl, J., & DeMark, T. R. (2008). TD Sequential: Defining the Trend and Identifying Exhaustion Points. DeMark Indicators, 1-27.