Optimized ADX DI CCI Strategy by osterhansi_

By osterhansi_

Performance Metrics

Description

### Key Features:- Combines ADX, DI+/-, CCI, and RSI for signal generation.- Supports customizable timeframes for indicators.- Offers multiple exit conditions (Moving Average cross, ADX change, performance-based stop-loss).- Tracks and displays trade statistics (e.g., win rate, capital growth, profit factor).- Visualizes trades with labels and optional background coloring.- Allows countertrading (opening an opposite trade after closing one).1. **Indicator Calculation**: - **ADX and DI+/-**: Calculated using the `ta.dmi` function with user-defined lengths for DI and ADX smoothing. - **CCI**: Computed using the `ta.cci` function with a configurable source (default: `hlc3`) and length. - **RSI (optional)**: Calculated using the `ta.rsi` function to filter overbought/oversold conditions. - **Moving Averages**: Used for CCI signal smoothing and trade exits, with support for SMA, EMA, SMMA (RMA), WMA, and VWMA.2. **Signal Generation**: - **Buy Signal**: Triggered when DI+ > DI- (or DI+ crosses over DI-), CCI > MA (or CCI crosses over MA), and optional ADX/RSI filters are satisfied. - **Sell Signal**: Triggered when DI+ DI- is sufficient.- **Require CCI Cross for Buy** (`buy_cci_cross`): - **Default**: `true`. - **Effect**: If `true`, requires a CCI crossover MA for buy signals; if `false`, CCI > MA is sufficient.- **Require DI+/DI- Cross for Sell** (`sell_di_cross`): - **Default**: `true`. - **Effect**: If `true`, requires a DI- crossover DI+ for sell signals; if `false`, DI+ < DI- is sufficient.- **Require CCI Cross for Sell** (`sell_cci_cross`): - **Default**: `true`. - **Effect**: If `true`, requires a CCI crossunder MA for sell signals; if `false`, CCI < MA is sufficient.- **Countertrade** (`countertrade`): - **Default**: `true`. - **Effect**: If `true`, closing a trade triggers an opposite trade (e.g., close long, open short) if allowed.- **Color Background for Open Trades** (`color_background`): - **Default**: `true`. - **Effect**: If `true`, colors the chart background green for long trades and red for short trades.### 3.7 Exit Settings- **Use MA Cross for Exit** (`use_ma_exit`): - **Default**: `true`. - **Effect**: If `true`, closes trades when the price crosses the exit MA (below for long, above for short).- **MA Length for Exit** (`ma_exit_length`): - **Default**: `20`. - **Range**: Minimum `1`. - **Effect**: Sets the period for the exit MA. Longer periods delay exits.- **MA Type for Exit** (`ma_exit_type`): - **Options**: `SMA`, `EMA`, `SMMA (RMA)`, `WMA`, `VWMA`. - **Default**: `SMA`. - **Effect**: Determines the MA type for exit signals. EMA is more responsive; VWMA weights by volume.- **Use ADX Change Stop-Loss** (`use_adx_stop`): - **Default**: `false`. - **Effect**: If `true`, closes trades when the ADX changes by a specified percentage.- **ADX % Change for Stop-Loss** (`adx_change_percent`): - **Default**: `5.0`. - **Range**: Minimum `0.0`, step `0.1`. - **Effect**: Specifies the percentage change in ADX (vs. previous bar) that triggers a stop-loss. Higher values reduce premature exits.- **Use Performance Stop-Loss** (`use_perf_stop`): - **Default**: `false`. - **Effect**: If `true`, closes trades when the loss exceeds a percentage threshold.- **Performance Stop-Loss (%)** (`perf_stop_percent`): - **Default**: `-10.0`. - **Range**: `-100.0` to `0.0`, step `0.1`. - **Effect**: Specifies the loss percentage that triggers a stop-loss. More negative values allow larger losses before exiting.## 4. Visual and Statistical Output- **Labels**: Displayed at trade entries/exits with arrows (↑ for buy, ↓ for sell) and text ("BUY," "SELL"). A "No Equity" label appears if equity is zero.- **Background Coloring**: Optionally colors the chart background (green for long, red for short) to indicate open trades.- **Statistics Table**: Displayed at the top center of the chart, updated on timeframe changes or trade events. Includes: - **Capital Metrics**: Initial capital, current capital, capital growth (%). - **Trade Metrics**: Total trades, long/short trades, win rate, long/short win rates, profit factor. - **Open Trade Status**: Indicates if a long, short, or no trade is open.## 5. Alerts- **Buy Signal Alert**: Triggered when `buy_signal` is true ("Cross Buy Signal").- **Sell Signal Alert**: Triggered when `sell_signal` is true ("Cross Sell Signal").- **Usage**: Users can set up TradingView alerts to receive notifications for trade signals.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView