OPEN-SOURCE SCRIPT

Market Trend Levels Non-Repainting [BigBeluga X PineIndicators]

231
This strategy is based on the Market Trend Levels Detector developed by BigBeluga. Full credit for the concept and original indicator goes to BigBeluga.

The Market Trend Levels Detector Strategy is a non-repainting trend-following strategy that identifies market trend shifts using two Exponential Moving Averages (EMA). It also detects key price levels and allows traders to apply multiple filters to refine trade entries and exits.

This strategy is designed for trend trading and enables traders to:
  • Identify trend direction based on EMA crossovers.
  • Detect significant market levels using labeled trend lines.
  • Use multiple filter conditions to improve trade accuracy.
  • Avoid false signals through non-repainting calculations.


How the Market Trend Levels Detector Strategy Works
1. Core Trend Detection Using EMA Crossovers
The strategy detects trend shifts using two EMAs:
  • Fast EMA (default: 12 periods) – Reacts quickly to price movements.
  • Slow EMA (default: 25 periods) – Provides a smoother trend confirmation.

A bullish crossover (Fast EMA crosses above Slow EMA) signals an uptrend, while a bearish crossover (Fast EMA crosses below Slow EMA) signals a downtrend.

2. Market Level Detection & Visualization
Each time an EMA crossover occurs, a trend level line is drawn:
  • Bullish crossover → A green line is drawn at the low of the crossover candle.
  • Bearish crossover → A purple line is drawn at the high of the crossover candle.
  • Lines can be extended to act as support and resistance zones for future price action.


Additionally, a small label (●) appears at each crossover to mark the event on the chart.

3. Trade Entry & Exit Conditions
The strategy allows users to choose between three trading modes:
  • Long Only – Only enters long trades.
  • Short Only – Only enters short trades.
  • Long & Short – Trades in both directions.


Entry Conditions
  • Long Entry:

    A bullish EMA crossover occurs.
    The trade direction setting allows long trades.
    Filter conditions (if enabled) confirm a valid long signal.
  • Short Entry:

    A bearish EMA crossover occurs.
    The trade direction setting allows short trades.
    Filter conditions (if enabled) confirm a valid short signal.

Exit Conditions
  • Long Exit:

    A bearish EMA crossover occurs.
    Exit filters (if enabled) indicate an invalid long position.
  • Short Exit:

    A bullish EMA crossover occurs.
    Exit filters (if enabled) indicate an invalid short position.

Additional Trade Filters
To improve trade accuracy, the strategy allows traders to apply up to 7 additional filters:
  • RSI Filter: Only trades when RSI confirms a valid trend.
  • MACD Filter: Ensures MACD histogram supports the trade direction.
  • Stochastic Filter: Requires %K line to be above/below threshold values.
  • Bollinger Bands Filter: Confirms price position relative to the middle BB line.
  • ADX Filter: Ensures the trend strength is above a set threshold.
  • CCI Filter: Requires CCI to indicate momentum in the right direction.
  • Williams %R Filter: Ensures price momentum supports the trade.


Filters can be enabled or disabled individually based on trader preference.

Dynamic Level Extension Feature
The strategy provides an optional feature to extend trend lines until price interacts with them again:
  • Bullish support lines extend until price revisits them.
  • Bearish resistance lines extend until price revisits them.
  • If price breaks a line, the line turns into a dotted style, indicating it has been breached.


This helps traders identify key levels where trend shifts previously occurred, providing useful support and resistance insights.

Customization Options
The strategy includes several adjustable settings:
  • Trade Direction: Choose between Long Only, Short Only, or Long & Short.
  • Trend Lengths: Adjust the Fast & Slow EMA lengths.
  • Market Level Extension: Decide whether to extend support/resistance lines.
  • Filters for Trade Confirmation: Enable/disable individual filters.
  • Color Settings: Customize line colors for bullish and bearish trend shifts.
  • Maximum Displayed Lines: Limit the number of drawn support/resistance lines.


Considerations & Limitations
  • Trend Lag: As with any EMA-based strategy, signals may be slightly delayed compared to price action.
  • Sideways Markets: This strategy works best in trending conditions; frequent crossovers in sideways markets can produce false signals.
  • Filter Usage: Enabling multiple filters may reduce trade frequency, but can also improve trade quality.
  • Line Overlap: If many crossovers occur in a short period, the chart may become cluttered with multiple trend levels. Adjusting the "Display Last" setting can help.


Conclusion
The Market Trend Levels Detector Strategy is a non-repainting trend-following system that combines EMA crossovers, market level detection, and customizable filters to improve trade accuracy.

By identifying trend shifts and key price levels, this strategy can be used for:
  • Trend Confirmation – Using EMA crossovers and filters to confirm trend direction.
  • Support & Resistance Trading – Identifying dynamic levels where price reacts.
  • Momentum-Based Trading – Combining EMA crossovers with additional momentum filters.


This strategy is fully customizable and can be adapted to different trading styles, timeframes, and market conditions.

Full credit for the original concept and indicator goes to BigBeluga.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน