Candlestick Momentum + MA Stack Strategy by cryptosquanch

By cryptosquanch

Performance Metrics

Description

Candlestick Momentum + MA Stack Strategy is an open-source momentum-burst strategy. It enters after a short run of same-direction candles moves a minimum distance, with an optional moving-average stack filter, structure-based stops and risk:reward targets. It is published as a research and testing framework. The default backtest loses money after costs, and that result is reported below.HOW IT WORKSMomentum signalOn every closed bar the script looks back over a window of completed candles (default 3) and measures how far price travelled across that window:- Body mode (default): from the first candle's open to the last candle's close. Wick mode: from the first candle's extreme to the last candle's extreme in the signal direction.- The move can be measured in pips/units (default 50 pips) or as a percent.- Direction filter (default ON): every candle in the window must close in the signal direction.- Gap handling: include gaps (direct endpoints) or exclude them (sum only the moves inside each candle).- Optional minimum average move per candle, to require a steady push rather than one large bar.A long signal fires when the window rises by at least the required amount, and a short signal when it falls by at least that amount.Why the parts are combinedA fixed-distance burst over a few candles is a simple way to detect a momentum move. The same-direction rule removes windows where one large candle hides a reversal. The optional MA stack (2 to 5 MAs, default EMA 20/50/100/200) restricts trades to the direction of the broader trend. Structure stops place the stop behind the recent swing that the burst came from. Each part can be switched off so you can see what it adds.Entries and exits- Entry on the bar-close confirmation of the signal, one position at a time, no pyramiding.- Default stop: lookback structure, the lowest low (longs) or highest high (shorts) of the last 5 completed candles, plus a 2-pip buffer. Alternatives: fixed pips, percent or ATR.- Default target: 2R (twice the stop distance). Alternatives: fixed pips, percent or ATR.- Optional trailing stop after the base target is touched, with a TP-level or breakeven floor.- Re-entry cooldown of 1 bar after a trade closes.- Time blocks to pause new entries, or to close trades, during chosen windows.DEFAULT SETTINGS AND STRATEGY PROPERTIES (used for the published chart)- Chart: OANDA:USDJPY, 1 hour. Strategy Tester range Jan 2023 to Nov 2026.- Window 3 candles, required move 50 pips (body), all candles same direction, MA stack filter OFF.- Stop: 5-bar structure + 2 pips. Target: 2R. Trailing OFF. Cooldown 1 bar.- Time blocks ON, New York time: 16:45-18:15 (daily rollover, when spreads usually widen) and 08:15-09:30 (scheduled US data releases). New entries only.- Initial capital: 10,000 USD. Order size: 0.10 lot = 10,000 units of USD per trade. Margin 5% (20:1).- Commission 0.005% per side. Slippage 5 ticks per fill (0.5 pip). Together these roughly represent a typical retail spread of about 1 pip round trip.- Risk per trade: in the test period the largest single loss was about 224 USD, roughly 2.2% of starting equity. Structure stops widen after large bursts, so check the stop distance against your own risk limit.WHAT THE BACKTEST SHOWSWith these defaults the strategy made about 200 trades over the test period and lost money after costs: about -14% net, a maximum drawdown of about 18%, and a profit factor below 1 (about 0.87). Roughly a third of trades were winners, which is not enough to cover the losers at a 2R target. Shorts did worse than longs over this mostly rising USDJPY period. I am publishing the honest default result rather than settings tuned to the past. The script is meant for studying momentum bursts and filters, not as a ready-made system. Past results do not predict future performance.HOW TO USE IT1. Set Strategy Properties to match your broker, and set the pip size for your instrument (0.01 for JPY pairs, 0.0001 for most other FX pairs).2. Scale the required move to the timeframe: 50 pips over 3 hourly candles is a large move on USDJPY, while lower timeframes need smaller values.3. Try the MA stack filter, the percent-based measurement and the trailing options, and compare the Strategy Tester results with the defaults.This script is for research and education. It is not financial advice.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView