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.
Specifically:
The above constitutes the complete logic of buy and sell.
This is a relatively simple trend following strategy with the following strengths:
The strategy also has some risks and deficiencies, which can be further optimized from the following aspects:
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.
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.
/*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"