AlterTrend
Download scriptThis script is designed as a visual market indicator for MetaTrader 5. Its primary purpose is to "filter" the price action on your chart by identifying and highlighting significant trend movements while ignoring minor market noise. It achieves this by combining volatility analysis with dynamic price range detection.
Core Logic Overview
The indicator functions by looking at two main components of the market: the strength/speed of the current move (using an ADX-based calculation) and the relative position of the current price compared to recent historical highs and lows.
1. Volatility and Momentum Sensing The script starts by analyzing how much "energy" is currently in the market. It uses a period-based lookback to determine the average range of price movement. If the market is moving significantly more than usual, it adjusts its sensitivity to ensure that the highlighted trends are meaningful and not just tiny fluctuations.
2. Dynamic Range Detection For every new price candle, the script scans back through history to find the highest high and the lowest low within a specific window. This window size is not fixed; it expands or contracts based on the current market volatility.
- If the market is moving very fast, the script looks at a shorter window of time.
- If the market is moving slowly, it looks further back into the past to find significant price levels.
3. Trend Filtering (The "Alternative" Trend) Once it knows the historical highs and lows for a specific period, it calculates a "buffer zone" (controlled by a user-defined percentage).
- Bullish Identification: If the current price closes above the calculated high threshold, the script identifies this as a valid upward trend. It then colors the candle based on whether the move was positive or negative relative to the opening price.
- Bearish Identification: If the current price closes below the calculated low threshold, it identifies this as a valid downward trend and assigns colors accordingly.
4. Visual Representation Instead of simply drawing lines, the script overlays "Alternative Candles." It replaces the standard price data with these filtered results. By doing this, it visually cleans up the chart, allowing a trader to see only the confirmed structural trends while "muting" the minor fluctuations that happen within the established range.
Summary for the User
Essentially, this tool acts as a trend stabilizer. It tells you: "Ignore the small zig-zags; here is where the price has actually broken out of its previous boundary to start a significant new move." It helps traders stay on the right side of a trend by only highlighting movements that have enough momentum and volume to be considered "significant" by the algorithm.
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | A l t e r T r e n d . m q 5 |
/ / | C o p y r i g h t © 2 0 0 5 , O l e g V S |
/ / | |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / - - - 02B>@AB2> 8=48:0B>@0
# p r o p e r t y c o p y r i g h t "