Gold ATR Master
- Experts
- Muthukrishnan Muthupoilan
- Versione: 3.10
- Attivazioni: 5
1. The Chandelier Exit CalculationThe function BuildChandelier() is the "brain" of the system. It mimics Pine Script's behavior by recalculating the entire history bar-by-bar to ensure no state bugs occur during live trading.ATR Foundation: It uses the Average True Range (ATR) multiplied by a factor (default is $9.0$) to determine the distance of the stop from the price.Extremums: It identifies the highest high or lowest low over a set period (default $22$ bars).The Ratchet Mechanism:Long Stop ($LS$): Calculated as Highest High - (ATR * Multiplier). Crucially, if the price is rising, the stop can only move up; it never moves down.Short Stop ($SS$): Calculated as Lowest Low + (ATR * Multiplier). This stop only moves down as price drops; it never moves up.Directional Logic: The trend direction flips when the price closes on the opposite side of the current stop.2. Signal Generation & ExecutionThe EA executes trades based on Directional Flips—specifically when the trend changes on a newly closed bar.Buy Signal: Occurs when the trend was bearish ($-1$) on the previous bar and turns bullish ($1$) on the current bar.Sell Signal: Occurs when the trend was bullish ($1$) and turns bearish ($-1$).Position Management:Before opening a new trade, the EA checks for an existing opposing position. If found, it closes the old trade first to ensure it is always aligned with the current trend.It uses a fixed lot size and sets the initial Stop Loss exactly at the calculated Chandelier Exit level.Take Profit is calculated as a multiple of the current ATR.3. Dynamic Trailing StopUnlike static EAs, this one uses the Chandelier Exit line as a continuous Trailing Stop. OnTick Updates: While signals are only checked at the start of a new bar, the TrailPosition() function runs on every tick.Protection: It modifies the existing position’s Stop Loss only if the new Chandelier level is "better" (higher for Buys, lower for Sells) than the current one, locking in profits as the trend progresses.4. Technical Summary TableFeatureLogicIndicator BaseChandelier Exit (ATR-based)Entry TimingBar Close (to prevent "repainting" signals)Exit LogicOpposite Signal or Take Profit (ATR-based)Risk ManagementRatchet-style Trailing SLCompatibilityDesigned.
IMPORTENT
H1 TIME FRAME
