OPEN-SOURCE SCRIPT

Target Trend + Filter Toggles [ChadAnt] V2

91
Minor Update that allows the user to add/remove profit targets!
Indicator Overview and Core Logic CREDIT TO BIGBELUGA FOR THE MAIN INDICATOR
The indicator, named "Target Trend + Filter Toggles", is an overlay that draws directly on the price chart.

1. Core Trend Detection (Modified SMA Channel)
The indicator uses a primary trend-following mechanism based on a custom channel built with Simple Moving Averages (SMAs) and Average True Range (ATR):

SMA High: ta.sma(high, length) + atr_value

SMA Low: ta.sma(low, length) - atr_value

The length is set by the user (default 20).

The atr_value is a smoothed ATR (SMA of ATR(200), multiplied by 0.8), acting as an offset to create a channel around the price action.

Trend Logic:

Uptrend (trend=true): When the close price crosses over the sma_high line.

Downtrend (trend=false): When the close price crosses under the sma_low line.

Visual Trend: The candles are colored based on this determined trend, and the SMA High/Low lines are plotted.

2. Signal Generation (Raw vs. Filtered)
Raw Signal: A raw signal (signal_up_raw or signal_down_raw) is triggered simply when the core trend logic changes (e.g., trend changes from down to up).

Filtered Signal: The final buy/sell signal (signal_up or signal_down) is triggered only when the raw signal is true AND all currently active filter toggles are confirmed within a specified filter_lookback period (default 3 bars).

⚙️ Filter Toggles and Calculations
The script includes an extensive system of boolean (on/off) toggles for various popular technical indicators, allowing the user to customize which filters must be confirmed for a signal to be valid.

FILTER CATEGORIES:
MACD,
VOLUME,
STOCHRSI,
AWESOME OSCILLATOR,
MOVING AVERAGE,
VWAP,
COUNTERTREND MA
COUNTERTREND VWAP


The script uses a for loop to check if the required confirmation happened within the last filter_lookback number of bars.

🎯 Target and Stop-Loss Levels
Upon a valid filtered signal (signal_up or signal_down), the indicator uses an extensive user-defined type (TrendTargets) and a custom draw_targets method to draw potential trade management lines:

Entry Price: The close price of the bar where the filtered signal occurred.

Stop Loss (SL):

For a Long signal: The sma_low line (the lower band of the trend channel).

For a Short signal: The sma_high line (the upper band of the trend channel).

Profit Targets (T1, T2, T3): These are calculated based on the ATR multiplier (atr_value) and an adjustable user input called target (default 1).

Targets are a multiple of atr_value added to (for longs) or subtracted from (for shorts) the Entry Price.

T1: Entry +/- (5 + target) * atr_value

T2: Entry +/- (10 + target * 2) * atr_value

T3: Entry +/- (15 + target * 3) * atr_value

These levels are plotted as extended lines with corresponding labels (e.g., "SL," "Entry," "T1"). The script also includes logic to mark targets with a "✔" and the stop-loss with an "✖" if the price hits those levels.

🎨 Visualization
The script provides clear visual cues:

Candle Coloring: Candles are colored with up_color (Green/Teal) for an uptrend and dn_color (Brown/Orange) for a downtrend.

Trend Lines: The sma_high and sma_low lines are plotted and subtly shaded between the price action.

Signal Shapes: A filtered signal triggers a set of two colored triangles (one small solid, one large transparent) plotted below the low for a long signal and above the high for a short signal.

Trade Zones: The area between the Stop Loss and the Entry line is shaded in the counter-trend color, and the area between the Entry line and the T3 line is shaded in the trend color.

This indicator is essentially a complete trading system that uses a combination of an ATR-based trend channel for entries, a multitude of technical indicators for confirmation, and an ATR-based system for trade management (SL/TPs).

Would you like me to focus on a specific filter's logic, or perhaps help you configure the indicator's inputs for a certain trading style?

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.