Williams 9 Days Breakout Strategy
This strategy is based on the 9-day breakout concept of Larry Williams, by monitoring the direction of 9-day moving average to determine the trend, and taking positions at breakout points to follow the trend.

Overview
This strategy is based on the 9-day breakout concept of Larry Williams, by monitoring the direction of 9-day moving average to determine the trend, and taking positions at breakout points to follow the trend.
Strategy Logic
- Use 9-day EMA as an indicator to judge the trend
- When price breaks out above EMA from below, it is judged as bullish and long position is taken
- When price breaks out below EMA from above, it is judged as bearish and short position is taken
- Buy signal: Opening price is lower than 9-day EMA, closing price is higher than 9-day EMA
- Sell signal: Opening price is higher than 9-day EMA, closing price is lower than 9-day EMA
Specifically:
- Calculate the 9-day EMA
- Check if the candle of the day satisfies the buy condition, i.e. opening price is lower than 9-day EMA, closing price is higher than 9-day EMA
- If satisfied, take long position at closing price, with stop loss set at previous high
- Check if the candle of the day satisfies the sell condition, i.e. opening price is higher than 9-day EMA, closing price is lower than 9-day EMA
- If satisfied, exit the previous long position, with take profit set at previous low
The above constitutes the complete logic of buy and sell.
Advantage Analysis
This is a relatively simple trend following strategy with the following strengths:
- Using EMA to judge trend direction can effectively filter out price noise
- Taking positions at EMA breakout can timely capture trend reversal
- Adopting previous high as stop loss and previous low as take profit can lock in trend profits
- The trading rules are clear and simple, easy to understand and implement, suitable for beginners
- High capital usage efficiency, no need to hold positions all the time, only short-term positions at trend breakouts
Risks and Optimization
The strategy also has some risks and deficiencies, which can be further optimized from the following aspects:
- The 9-day EMA period setting may not be flexible enough for different products and market conditions, adaptive EMA period can be introduced
- Using only 9-day EMA to judge trend may be too simple, multiple time frame EMAs or other indicators can be combined
- Transaction costs and slippage are not considered, which can significantly affect PnL in live trading
- No stop loss and take profit ratios are set, unable to control risk reward of individual trades
- Entry signals may oscillate multiple times, generating unnecessary small orders, filters can be added
In summary, the strategy can be improved through dynamic parameter optimization, multifactor judgement, transaction cost management, risk-reward control etc, to make the strategy more robust across different market conditions.
Conclusion
The Williams 9-day breakout strategy is a relatively classic short-term trend following strategy. The core idea is simple and clear, using EMA to determine trend direction, taking positions at breakout points, following the trend and managing risks. The strategy is easy to understand and implement, with high capital usage efficiency, but also has some deficiencies. We can optimize it from multiple perspectives to make the parameters more dynamic, judgement rules more rigorous, risk control more complete, thereby adapting to a wider range of market conditions and improving the stability and profitability.
Source Pine Script
/*backtest
start: 2023-09-16 00:00:00
end: 2023-10-16 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("larry willians teste2", overlay=true)
//Window of time
start = timestamp(2019, 00, 00, 00, 00) // backtest start window
finish = timestamp(2019, 12, 31, 23, 59) // backtest finish window
window() => true // create function "within window of time"
ema9=ema(close,9) // Ema de 9 periodos
//Condições de compra
c1= (open< ema9 and close > ema9) //abrir abaixo da ema9 e fechar acima da ema9
if(window())
if(c1)
strategy.entry("Compra", true, stop = high) // Coloca ordem stopgain no topo anterior
else
strategy.cancel("Compra") // Cancela a ordem se o proximo candle não "pegar"
//codições de venda
v1= (open> ema9 and close < ema9) // abrir acima da ema9 e fechar abaixo ema9
if(window())
if (v1)
strategy.exit("Venda", from_entry = "Compra", stop = low) // Saida da entrada com stop no fundo anterior
else
strategy.cancel("Venda") //Cancela a ordem se o proximo candle não "pegar"
Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-17. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Williams-9-Days-Breakout-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- BB Breakout StrategyPine Script · Breakout · 1d
- BMSB Breakout Strategy BMSBPine Script · Breakout · 1h
- Bollinger Band T3 Moving Average StrategyPine Script · Breakout · 10m
- Bollinger Bands Dual track Breakthrough StrategyPine Script · Breakout · 30m
- Bollinger Breakout StrategyPine Script · Breakout · 30m