Williams Accumulation/Distribution (Williams AD) Strategy

Author: ChaoZhang, Date: 2023-11-02 17:25:51
Tags:

img

Overview

The Williams Accumulation/Distribution Indicator (Williams AD) is a technical analysis indicator that monitors price changes and trading volumes to determine market sentiment. This indicator is based on Williams’ assumption that volume tends to increase in a falling market. It reflects whether the current market trend is controlled by buyers or sellers.

This strategy analyzes the changes in the values of the Williams Accumulation/Distribution indicator to determine whether the current trend is in an accumulation phase or a distribution phase, thereby generating buy and sell signals.

Strategy Logic

The core indicator of this strategy is the Williams Accumulation/Distribution (Williams AD). The calculation formula is as follows:

If Close > Previous Close
   Williams AD = Previous Williams AD + (Close - Low)  
If Close < Previous Close
   Williams AD = Previous Williams AD + (Close - High)
If Close == Previous Close
   Williams AD = Previous Williams AD

Where if today’s close is higher than yesterday’s, today’s AD value is equal to yesterday’s AD value plus the difference between “today’s close - today’s low”. If today’s close is lower than yesterday’s, today’s AD value is equal to yesterday’s AD value plus the difference between “today’s close - today’s high”.

This indicator reflects the power relationship in trading. The main judgment rules are as follows:

  • Rising AD indicates increasing buying power, which is an accumulation trend.
  • Falling AD indicates increasing selling power, which is a distribution trend.

When the security price hits a new high and the AD indicator does not hit a new high, it is considered a distribution signal to go short. When the security price hits a new low and the AD indicator does not hit a new low, it is considered an accumulation signal to go long.

According to these rules, the specific trading signal generation rules for this strategy are:

  • AD > 0, generate long signal
  • AD < 0, generate short signal

The long and short direction can be reversed through the input parameter “reverse”.

Advantage Analysis

The advantages of this strategy include:

  1. Using Williams AD to judge market sentiment can improve win rate.

  2. The indicator calculation is simple and easy to implement.

  3. The reverse parameter allows flexible adaptation to different market conditions.

  4. Divergence between indicator and price can generate relatively accurate trading signals.

  5. Market sentiment can be clearly visualized through candlestick colors.

Risk Analysis

This strategy also has the following risks:

  1. Williams AD has lagging issues which may generate wrong signals.

  2. Relying solely on one indicator can be affected by false breakouts and generate too frequent signals.

  3. Improper parameter settings may lead to over-trading.

  4. Other factors need to be considered to determine entry and exit timing.

  5. Indicator judgements may be problematic around trend reversals.

Risks can be reduced through optimizing parameters, combining multiple indicators for confirmation, filtering trade frequency, etc.

Optimization Directions

This strategy can be optimized in the following aspects:

  1. Add more parameters for optimization, such as trading range, frequency, etc.

  2. Combine with other indicators for signal filtering, such as volume-price indicators, moving averages, etc.

  3. Add stop loss strategies to control single trade loss.

  4. Conduct parameter training to find optimal parameter combinations.

  5. Incorporate machine learning algorithms for dynamic parameter optimization.

  6. Test robustness across different products, timeframes, market environments.

  7. Build backtesting system to evaluate strategy’s risk-reward profile.

Conclusion

The Williams AD strategy judges market sentiment based on indicator direction changes. It has the advantages of simple signal generation and flexible parameter tuning. But as a single indicator strategy, it has inherent limitations and needs multi-dimensional optimizations and additional techniques for verification before stable profitability in live trading. It provides reference for judging market sentiment but still requires prudent trading.


/*backtest
start: 2023-10-02 00:00:00
end: 2023-11-01 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 18/01/2018
// Accumulation is a term used to describe a market controlled by buyers;
// whereas distribution is defined by a market controlled by sellers.
// Williams recommends trading this indicator based on divergences:
//
//  Distribution of the security is indicated when the security is making 
//  a new high and the A/D indicator is failing to make a new high. Sell.
//
//  Accumulation of the security is indicated when the security is making 
//  a new low and the A/D indicator is failing to make a new low. Buy.
//
//You can change long to short in the Input Settings
//WARNING:
//- For purpose educate only
//- This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Williams Accumulation/Distribution (Williams AD)", shorttitle="Williams AD")
reverse = input(false, title="Trade reverse")
hline(0, color=blue, linestyle=line)
xPrice = close
xWAD = iff(close > nz(close[1], 0), nz(xWAD[1],0) + close - low[1], 
         iff(close < nz(close[1],0), nz(xWAD[1],0) + close - high[1],0))
pos = iff(xWAD > 0, 1,
       iff(xWAD < 0, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )        
plot(xWAD, color=green, title="Williams AD")

More