OPEN-SOURCE SCRIPT

Twisted Forex's Doji + Area Strategy

254
Title
Twisted Forex’s Doji + Area Strategy

Description
What this strategy does
This strategy looks for doji candles forming inside or near supply/demand areas. Areas are built from swing pivots and sized with ATR, then tracked for retests (“confirmations”). When a doji prints close to an area and quality checks pass, the strategy places a trade with the stop beyond the doji and a configurable R:R target.

How areas (zones) are built
• Swings are detected with a user-set pivot length.
• Each swing spawns a horizontal area centered at the pivot price with half-height = zoneHalfATR × ATR.
• Duplicates are de-duplicated by center distance (ATR-scaled).
• Areas fade when broken beyond a buffer or after an optional age (expiry).
• Retests are recorded when price touches and then bounces away from the area; repeated reactions increase the zone’s “strength”.

Signal logic (summary)

Doji detection: strict or loose body criteria with optional minimum wick fractions and ATR-scaled minimum range.

Proximity: price must be inside/near a supply or demand area (proxATR × ATR).

Side resolution: overlap is resolved by (a) which side price penetrates more, (b) fast/slow EMA trend, or (c) nearest distance. Optional “previous candle flip” can bias long after a bearish candle and short after a bullish one.

Optional 1-bar confirmation: the bar after the doji must close away from the area by confirmATR × ATR.

Quality filter (Off/Soft/Strict): four checks—(i) wick rejection past the edge, (ii) doji closes in an edge “band” of the area, (iii) fresh touch (cooldown), (iv) approach impulse over a short lookback. In Strict, thresholds auto-tighten.

Orders & exits
• Long: stop below doji low minus buffer; Short: above doji high plus buffer.
• Target = rrMultiple × risk distance.
• Pyramiding is off by default.

Position sizing
You can size from the script or from Strategy Properties:
Script-driven (default): set Position sizing = “Risk % of equity” and choose riskPercent (e.g., 1.0%). The script applies safe floors/rounding (FX micro-lots by default) so quantity never rounds to zero.
Properties-driven: toggle Use TV Properties → Order size ON, then pick “Percent of equity” in Properties (e.g., 1%). The header includes safe defaults so trades still place.

Key inputs to explore
Zone building: pivotLen, zoneHalfATR, minDepartureATR, expiryBars, breakATR, leftBars, dedupeATR.
Doji & proximity: strictDoji, dojiBodyFrac, minWickFrac, minRangeATR, proxATR, minBarsBetween.
Overlap resolution: usePenetration, useTrend (EMA 21/55), “previous candle flip”, needNextBarConf & confirmATR.
Quality: qualityMode (Off/Soft/Strict), minQualPass/kStrict, wickPenATR, edgeBandFrac, approachLookback, approachMinATR, freshTouchBars.
Zone strength gating: minStrengthSoft / minStrengthStrict.
HTF confluence (optional): useHTFTrend (HTF EMA 34/89) and/or useHTFZoneProx (HTF swing bands).

Tips to make it cleaner / higher quality
• Turn needNextBarConf ON and use confirmATR = 0.10–0.15.
• Increase approachMinATR (e.g., 0.35–0.45) to require a stronger pre-touch impulse.
• Raise minStrengthSoft/Strict (e.g., 4–6) so only well-reacted zones can signal.
• Use signalsOnlyConfirmed ON if you prefer trades only from zones with retests (the script falls back gracefully when none exist yet).
• Nudge proxATR to 0.5–0.6 to demand tighter proximity to the level.
• Optional: enable useHTFTrend to filter counter-trend setups.

Default settings used in this publication
• Initial capital: 100,000 (illustrative).
• Slippage: 1 tick; Commission: 0% (you can raise commission if you prefer—spread is partly modeled by slippage).
• Sizing: Risk % of equity via inputs; riskPercent = 1.0%; FX uses micro-lot floors by default.
• Quality: Off by default (Soft/Strict available).
• HTF trend gate: Off by default.

Backtesting notes
For a meaningful sample size, test on liquid symbols/timeframes that yield 100+ trades (e.g., majors on 5–15m over 1–2 years). Backtests are modelled and broker costs/spread vary—validate on your feed and forward-test.

How to read the chart
Shaded bands are supply (above) and demand (below). Brighter bands are the nearest K per side (visual aid). BUY/SELL labels mark entries; colored dots show entry/SL/TP levels. You can hide zones or unconfirmed zones for a cleaner view.

Disclaimer
This is educational material, not financial advice. Trading involves risk. Always test and size responsibly.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.