OPEN-SOURCE SCRIPT

FVG Trailing Stop [LuxAlgo]

16 329
The FVG Trailing Stop indicator tracks unmitigated Fair Value Gaps (FVG) data to produce a Trailing Stop indicator able to determine if the market is uptrending or downtrending easily.

🔶 USAGE

anlık görüntü

The FVG Trailing Stop is intended to identify trend directions through its position relative to the closing price:

  • Bullish: Price is located above the Trailing Stop, indicating that all Bearish FVGs have been mitigated and the trend is anticipated to continue upwards.
  • Bearish State: Price is located below the Trailing Stop, indicating that all Bullish FVGs have been mitigated and the trend is anticipated to continue downwards.


The Trailing Stop originates from two extremities obtained from the average of respective unmitigated FVGs. The specific directional average is also displayed as a more transparent secondary line, however, the trailing stop is derived from this value and a new trend will not be detected until the opposite directional average is crossed.

Price reaching the Trailing Stop is caused by retracements and can lead to the following scenarios:

  • Outcome 1: The directional average is crossed next, indicating a new trend direction.
  • Outcome 2: The directional average is held as support or resistance, leading to a new impulse and a continuation of the trend.

    anlık görüntü

    🔹 Reset on Crossanlık görüntü

    While price crossing the Trailing Stop should be considered as a sign of an upcoming trend change; it is possible for the price to still evolve outside it.

    As a solution, we have included the "Reset on Cross" feature, which (as the name suggests) hides and resets the Trailing Stop each time it is crossed, leading to a "Neutral" state.

    This opens the opportunity for the Trailing Stop to be displayed again once the price moves again in the direction of the pre-established trend. A trader might use this to accumulate positions within a specific trend.

    🔶 DETAILS

    The script uses a typical identification method for FVGs. Once identified, the script collects the point of the FVG farthest from the current price when formed.

    • For Upwards FVGs this is the bottom of the FVG.
    • For Downwards FVGs this is the top of the FVG.


    The data is managed only to use the last input lookback of FVGs. If an FVG is mitigated, it frees up a spot in the memory for a new FVG, however, if the lookback is full, the oldest will be deleted.

    From there, it uses a "trailing" logic only to move the Trailing Stop in one direction until the trailing stop resets or the direction flips.

    The extremities used to calculate the Trailing Stop are created from 2 calculation steps, the first step involves taking the raw average of the FVG mitigation levels, and the second step applies a simple moving average (SMA) smoothing of the precedent-obtained averages.

    🔶 SETTINGS
    • Unmitigated FVG Lookback: Sets the maximum number of Unmitigated FVGs that the script will use.
    • Smoothing Length: Sets the smoothing length for the Trailing Stop to reduce erratic results.
    • Reset on Cross: When enabled, hide and reset the Trailing Stop until the price starts moving in the pre-established trend direction again.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.