A combination strategy that uses a WMA crossover to define trend direction and Williams %R as a filter on those signals. The idea: only act on crossovers that agree with momentum, to skip some of the false signals a crossover alone produces. Educational only — not predictive, and trading involves risk of loss.
Trend trigger — WMA crossover. A moving average (MA) takes the average price over a chosen number of bars and plots it as a single line that updates each bar. Two WMAs of different lengths (e.g. 9 and 21) are plotted; the fast one crossing above the slow one is read as upward momentum, and below as downward.
Filter — Williams %R. Williams %R (Williams Percent Range), developed by Larry Williams, is a momentum oscillator that measures where the current close falls relative to the highest high and lowest low over a chosen lookback period (commonly 14 bars). Here it is used to Williams %R runs from -100 to 0; this filters out the most stretched readings.
Why combine them. A moving-average crossover defines direction but fires on every cross, including in choppy conditions; adding a Williams %R filter tries to skip crossovers that trigger into already-stretched momentum. Both components are lagging by construction, so this reduces some false signals at the cost of entering later — it does not remove risk or guarantee anything.
//@version=6
strategy("WMA Crossover + Williams %R Filter (Educational)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, process_orders_on_close=true)
fastLen = input.int(9, "Fast WMA length", minval=1)
slowLen = input.int(21, "Slow WMA length", minval=1)
fast = ta.wma(close, fastLen)
slow = ta.wma(close, slowLen)
oscVal = ta.wpr(14)
longCond = ta.crossover(fast, slow) and oscVal < -20
shortCond = ta.crossunder(fast, slow) and oscVal > -80
if longCond
strategy.entry("Long", strategy.long)
if shortCond
strategy.entry("Short", strategy.short)
plot(fast, "Fast WMA", color.aqua)
plot(slow, "Slow WMA", color.orange)
// Educational only. Not financial advice. Validate for look-ahead bias &
// repainting before trusting any backtest. Past results do not predict future.It can reduce some false signals by skipping crossovers that fire into stretched momentum, but it also delays or removes some good entries, and it does not make the strategy predictive. Test it out-of-sample and account for costs. This is educational, not advice.
9/21 for the WMAs and standard Williams %R settings are common starting points, but there is no universally correct value — choose lengths that fit your timeframe and validate out-of-sample rather than tuning to past data.
Educational & software only — not financial advice, not a recommendation to trade. Backtests are illustrative; past performance does not predict future results. Trading involves substantial risk of loss.