Twisted Forex's Doji + Area StrategyTitle 
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.
Supportandresistancezones
Breaks and Retests - Free990Strategy Description: "Breaks and Retests - Free990" 
The "Breaks and Retests - Free990" strategy is based on identifying breakout and retest opportunities for potential entries in both long and short trades. The idea is to detect price breakouts above resistance levels or below support levels, and subsequently identify retests that confirm the breakout levels. The strategy offers an automated approach to enter trades after a breakout followed by a retest, which serves as a confirmation of trend continuation.
Key Components:
Support and Resistance Detection:
The strategy calculates pivot levels based on historical price movements to define support and resistance areas. A lookback range is used to determine these key levels.
Breakouts and Retests:
The system identifies when a breakout occurs above a resistance level or below a support level.
It then waits for a retest of the previously broken level as confirmation, which is often a better entry opportunity.
Trade Direction Selection:
Users can choose between "Long Only," "Short Only," or "Both" directions for trading based on their market view.
Stop Loss and Trailing Stop:
An initial stop loss is placed at a defined percentage away from the entry.
The trailing stop loss is activated after the position gains a specified percentage in profit.
Long Entry:
A long entry is triggered if the price breaks above a resistance level and subsequently retests that level successfully.
The entry condition checks if the breakout was confirmed and if a retest was valid.
The long entry is only executed if the user-selected direction is either "Long Only" or "Both."
Short Entry:
A short entry is triggered if the price breaks below a support level and subsequently retests that level.
The short entry is only executed if the user-selected direction is either "Short Only" or "Both."
sell_condition checks whether the support has been broken and whether the retest condition is valid.
An initial stop loss is placed when the trade is opened to limit the risk if the trade moves against the position.
The stop loss is calculated based on a user-defined percentage (stop_loss_percent) of the entry price.
pinescript
Copy code
stop_loss_price := strategy.position_avg_price * (1 - stop_loss_percent / 100)
For long positions, the stop loss is placed below the entry price.
For short positions, the stop loss is placed above the entry price.
Trailing Stop:
When a position achieves a certain profit threshold (profit_threshold_percent), the trailing stop mechanism is activated.
For long positions, the trailing stop follows the highest price reached, ensuring that some profit is locked in if the price reverses.
For short positions, the trailing stop follows the lowest price reached.
Code Logic for Trailing Stop:
Exit Execution:
The strategy exits the position when the price hits the calculated stop loss level.
This includes both the initial stop loss and the trailing stop that adjusts as the trade progresses.
Code Logic for Exit:
Summary:
Breaks and Retests - Free990 uses support and resistance levels to identify breakouts, followed by retests for confirmation.
Entry Points: Triggered when a breakout is confirmed and a retest occurs, for both long and short trades.
Exit Points:
Initial Stop Loss: Limits risk for both long and short trades.
Trailing Stop Loss: Locks in profits as the price moves in favor of the position.
This strategy aims to capture the momentum after breakouts and minimize losses through effective use of stop loss and trailing stops. It gives the flexibility of selecting trade direction and ensures trades are taken with confirmation through the retest, which helps to reduce false breakouts.
Original Code by @HoanGhetti

