MM Labelled AVWAPTradingView provides a tool to show anchored VWAP plots on your screen, but there is no way to label the plots to add additional context to the level. Instead, users are forced to use the plot style (color, line style, line thickness, etc) to indicate what the plots are for and then they have to remember that meaning when looking at different charts. It also means that for key market-wide moments, users will need to add the plot for every symbol.
Now, for the first time on TradingView, you can create anchored VWAP plots with labels on them so you can understand the meaning behind the key moments you care about and don't need to remember what they mean by using styles like color or thickness. You can use this indicator to track key moments like the 2022 market bottom, or the Aug 9, 2024 "Carry Trade Unwind" bottom. The labelled AVWAP plots are visible on every chart by default. If you have an AVWAP moment that is only relevant to a small number of symbols, you can configure the indicator to only appear on those symbols.
Tìm kiếm tập lệnh với "tradingview+金龙指数"
Intrabar Polarity DivergencesTradingview Pinescript just introduced a new exciting ability to get intrabars candle information from a higher time frame chart!
This indicator is based on Tradingview example but with enhanced capabilities to show the percentage of intrabars opposite bars with the ability to display the mid-day candle close price drawn by a blue line.
This indicator can show you that in some cases a GREEN candle on the daily chart, for example, can have more red candles in a lower time frame. which may or may not indicate on a change of direction :)
This is an ongoing experiment and I plan to release more indicators based on these new pinescript capabilities.
Like if you like and Follow to stay updated!
Systematic Investment PlanTradingview default strategy tester has few limitations. To name some:
Tradingview default strategy tester does not have option for periodic investment.
Does not allow reduce and refill kind of operations.
Comparison to buy and hold equity does not take into consideration on number of days invested
Hence, I created this as base for my further experiments with respect to strategies involving market timing.
Settings are quite simple and self explanatory.
Multi Oscillator Divergence IndicatorTradingview Built-in Divergence Indicator with RSI is extended for Price Divergence with
- RSI
- MACD
- Sochastic
- Money Flow
- Demand Index
- Chaikin Money Flow
Thanks to tradingview for providing this unique indicator.
Synthetic VX3! & VX4! continuous /VX futuresTradingView is missing continuous 3rd and 4th month VIX (/VX) futures, so I decided to try to make a synthetic one that emulates what continuous maturity futures would look like. This is useful for backtesting/historical purposes as it enables traders to see how their further out VX contracts would've performed vs the front month contract.
The indicator pulls actual realtime data (if you subscribe to the CBOE data package) or 15 minute delayed data for the VIX spot (the actual non-tradeable VIX index), the continuous front month (VX1!), and the continuous second month (VX2!) continually rolled contracts. Then the indicator's script applies a formula to fairly closely estimate how 3rd and 4th month continuous contracts would've moved.
It uses an exponential mean‑reversion to a long‑run level formula using:
σ(T) = θ+(σ0−θ)e−kT
You can expect it to be off by ~5% or so (in times of backwardation it might be less accurate).
TradingView Financial Data ViewerTrading view provides request.security function to view the financial information of a script. The available sets of data is documented on below link
www.tradingview.com
The problem is there is no easy way to view this data as there are limitations to the # of unique requests that can be made. The limit is 40 for general paid accounts. So its makes it impossible to view the data in case you are looking to build a plugin related to some financial analysis.
So I came up with this trading view plugin which based on the documentation bifurcates the values available in the FQ, TTM and FY periods. Then you can select which period you would like to see. How many values you want to see at a time. And then next set of data can be viewed by increasing the Set # from 1 to which ever number keeps giving you the data.
Notes:
This is a data view only indicator and it will only display the latest data available for which quarter was there.
In case you want to view past data then you should go to replay mode and cut to the relative earning tags where you want to view the data
This is again for educational or study purpose only and is majorly helpful for those who want to create indicators based on Trading view supported financials and want to view what values are given for specific financial ids
The documentation reference and source of the plugin can be checked
S&P 500 Quandl Data & RatiosTradingView has a little-known integration that allows you to pull in 3rd party data-sets from Nasdaq Data Link, also known as Quandl. Today, I am open-sourcing for the community an indicator that uses the Quandl integration to pull in historical data and ratios on the S&P500. I originally coded this to study macro P/E ratios during peaks and troughs of boom/bust cycles.
The indicator pulls in each of the following datasets, as defined and provided by Quandl. The user can select which datasets to pull in using the indicator settings:
Dividend Yield : S&P 500 dividend yield (12 month dividend per share)/price. Yields following June 2022 (including the current yield) are estimated based on 12 month dividends through June 2022, as reported by S&P. Sources: Standard & Poor's for current S&P 500 Dividend Yield. Robert Shiller and his book Irrational Exuberance for historic S&P 500 Dividend Yields.
Price Earning Ratio : Price to earnings ratio, based on trailing twelve month as reported earnings. Current PE is estimated from latest reported earnings and current market price. Source: Robert Shiller and his book Irrational Exuberance for historic S&P 500 PE Ratio.
CAPE/Shiller PE Ratio : Shiller PE ratio for the S&P 500. Price earnings ratio is based on average inflation-adjusted earnings from the previous 10 years, known as the Cyclically Adjusted PE Ratio (CAPE Ratio), Shiller PE Ratio, or PE 10 FAQ. Data courtesy of Robert Shiller from his book, Irrational Exuberance.
Earnings Yield : S&P 500 Earnings Yield. Earnings Yield = trailing 12 month earnings divided by index price (or inverse PE) Yields following March, 2022 (including current yield) are estimated based on 12 month earnings through March, 2022 the latest reported by S&P. Source: Standard & Poor's
Price Book Ratio : S&P 500 price to book value ratio. Current price to book ratio is estimated based on current market price and S&P 500 book value as of March, 2022 the latest reported by S&P. Source: Standard & Poor's
Price Sales Ratio : S&P 500 Price to Sales Ratio (P/S or Price to Revenue). Current price to sales ratio is estimated based on current market price and 12 month sales ending March, 2022 the latest reported by S&P. Source: Standard & Poor's
Inflation Adjusted SP500 : Inflation adjusted SP500. Other than the current price, all prices are monthly average closing prices. Sources: Standard & Poor's Robert Shiller and his book Irrational Exuberance for historic S&P 500 prices, and historic CPIs.
Revenue Per Share : Trailing twelve month S&P 500 Sales Per Share (S&P 500 Revenue Per Share) non-inflation adjusted current dollars. Source: Standard & Poor's
Earnings Per Share : S&P 500 Earnings Per Share. 12-month real earnings per share inflation adjusted, constant August, 2022 dollars. Sources: Standard & Poor's for current S&P 500 Earnings. Robert Shiller and his book Irrational Exuberance for historic S&P 500 Earnings.
Disclaimer: This is not financial advice. Open-source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
Candle Close ConfirmationTradingview doesn't provide a way to prevent unclosed candles from displaying in real time.
This script helps to reduce errors that span from reading unconfirmed candles by preventing the unconfirmed candle from displaying across all timeframes.
Ideal for traders with strategies that rely on candle confirmation signals.
NOTE: It works by drawing new candles based on the normal candles and stops just before the current unconfirmed candle, so you need to disable regular bar chart candles for this to work properly.
How to do that -
Chart Settings >
Symbols >
Candles >
Disable (Body, Borders, Wick)
Timed AlertTradingView doesn't offer a way easily set timed alerts. This script solves that problem and also allows you to set variables in the script similar to other alerts.
The variables can be found here .
McDonald's Pattern [LuxAlgo]Tradingview asked, we delivered. This script fits a cubic Bezier curve using tops/bottoms in order to approximate a McDonalds pattern, a popular meme pattern in the crypto trading community.
Traditionally the McDonalds pattern is described by an M pattern with deep retracement (> 50%), forming a McDonalds logo.
Please note that this indicator is a meme & should not be taken seriously. Some aspects of this indicator are not real-time and meant for descriptive analysis alongside other components of this script, in this case, for entertainment purposes. We suggest looking through our other open-source scripts if you’re looking for more serious tools.
🔶 USAGE
The script fits Bezier curves using specific tops/bottoms as control points. When the distance between tops and bottoms values is relatively small, the user can more easily identify the pattern.
A score is shown on the top right of the chart, aiming to return how close the returned pattern is to the original logo.
A regular Mcdonalds pattern would return a red background, while an inverted pattern would return a green one.
🔶 SETTINGS
Length: Sensitivity of tops/bottoms detection. The method does not make use of pivot points, using rolling maximums/minimums instead.
Use First Bar As Vertex: Use the price and bar index of the last bar as vertex.
[cache_that_pass] 1m 15m Function - Weighted Standard DeviationTradingview Community,
As I progress through my journey, I have come to the realization that it is time to give back. This script isn't a life changer, but it has the building blocks for a motivated individual to optimize the parameters and have a production script ready to go.
Credit for the indicator is due to @rumpypumpydumpy
I adapted this indicator to a strategy for crypto markets. 15 minute time frame has worked best for me.
It is a standard deviation script that has 3 important user configured parameters. These 3 things are what the end user should tweak for optimum returns. They are....
1) Lookback Length - I have had luck with it set to 20, but any value from 1-1000 it will accept.
2) stopPer - Stop Loss percentage of each trade
3) takePer - Take Profit percentage of each trade
2 and 3 above are where you will see significant changes in returns by altering them and trying different percentages. An experienced pinescript programmer can take this and build on it even more. If you do, I ask that you please share the script with the community in an open-source fashion.
It also already accounts for the commission percentage of 0.075% that Binance.US uses for people who pay fees with BNB.
How it works...
It calculates a weighted standard deviation of the price for the lookback period set (so 20 candles is default). It recalculates each time a new candle is printed. It trades when price lows crossunder the bottom of that deviation channel, and sells when price highs crossover the top of that deviation channel. It works best in mid to long term sideways channels / Wyckoff accumulation periods.
Line Chart Enhancer by makuchakuTradingview has a good line chart, but I wanted to make it even more awesome.
Some shortcomings which this line chart enhancer script fixes
Colors up move as green, down move as red (you can change them as you like)
Plots high and low - so that one can be aware about what the price is doing
To achieve the look with markers as shown above
Goto Symbol settings > Type > Select "With Markers"
Feedback welcome!
Custom Screener with Alerts V2 [QuantNomad]TradingView just recently announced the alert() function that allows you to create dynamic alerts from both strategies and studies.
So I decided to update custom screener I published before. It was based on alerts from orders in strategies, that was the only way to create dynamic alerts in PineScript at that point.
With the alert() function code become cleaner and more readable.
It works for up to 40 symbols at the same time.
You can create an alert from it easily by selecting screener name from the list and then selecting "Any alert() function call".
No additional configuration is required, message and alert on close I set up in the code.
I created as an example a screener that tracks both overbought (RSI > 70) and oversold stocks (RSI < 30).
To create your own screener you have to change only screenerFunc().
By design it should output 2 values:
cond - True/False Boolean variable. Should this instrument be displayed in the screener?
value - Additional numeric value you can display in your screener. I display RSI level for selected stocks for example.
Link to the old screener:
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as good as in historical backtesting.
This post and the script don’t provide any financial advice.
COVID-19 Country CodesTradingView's available country COVID-19 data. "TOTAL" refers to all cases of COVID-19. Let me know if I am missing some. I cannot find Taiwan.
Options to show: confirmed, deaths, recovered, and a delta of the total.
Option to transform data to show daily change.
There are much more comprehensive tools with more utility than mine; ideally this would be helpful towards another indicator.
Will add syminfo.description in the future for easier use.
US COVID-19 CodesTradingView's available state, province, and the two ships Diamond Princess and Grand Princess COVID-19 data.
Options to show: confirmed, deaths, recovered, and a delta of the total. There seems to be missing data for the recovered cases.
Option to transform data to show daily change.
ChimichangasTradingView has released fractional contracts for cryptocurrencies. Very cool, very swag. This script is to see how it works, and to test the efficiency of position sizing.
(I would like to see % based stops or take profits instead of ticks added too)
Elder's Force Index Function (with source)TradingView has built in functions for RSI, Momentum, and many other oscillators. Why the source isn't available for Elder's Force Index is beyond me. To me it's one of the Holy Grail indicators. This is EFI indicator with a simple function inside the source code. You're can easily copy this function into any study(indicator) or strategy that uses built-in oscillators, as a replacement.
Example using EFI instead of RSI in built-in Divergence Indicator:
gyazo.com
//Discord: Sheldon#7775
//Server: discord.gg
RSI with SMA ( Normal Formula of RSI)Tradingview has a different type of RSI. I prepare a normal formula for RSI to calculate better backtest performance.
Tradingview Rating Estimatewww.tradingview.com
Strong buy above 0.5
Buy above 0
I am missing a couple indicators but the rating seems to be working for the most part.
MTF function is in works.
etc...
BitMEX Funding [R1984]TradingView Pine script for the BitMEX XBTUSD perpetual swaps contract premium index (XBTUSDPI) and emulated predicted funding rate.
EMA20 Cross Strategy with countertrades and signalsEMA20 Cross Strategy Documentation
Overview
The EMA20 Cross Strategy with Counter-Trades and Instant Signals is a Pine Script (version 6) trading strategy designed for the TradingView platform. It implements an Exponential Moving Average (EMA) crossover system to generate buy and sell signals, with optional trend filtering, session-based trading, instant signal processing, and visual/statistical feedback. The strategy supports counter-trades (closing opposing positions before entering new ones) and operates with a fixed trade size in EUR.
Features
EMA Crossover Mechanism:
Uses a short-term EMA (configurable length, default: 1) and a long-term EMA (default: 20) to detect crossovers.
A buy signal is generated when the short EMA crosses above the long EMA.
A sell signal is generated when the short EMA crosses below the long EMA.
Instant Signals:
If enabled (useInstantSignals), signals are based on the current price crossing the short EMA, rather than waiting for the candle close.
This allows faster trade execution but may increase sensitivity to price fluctuations.
Trend Filter:
Optionally filters trades based on the trend direction (useTrendFilter).
Long trades are allowed only when the short EMA (or price, for instant signals) is above the long EMA.
Short trades are allowed only when the short EMA (or price) is below the long EMA.
Session Filter:
Restricts trading to specific market hours (sessionStart, default: 09:00–17:00) if enabled (useSessionFilter).
Ensures trades occur only during active market sessions, reducing exposure to low-liquidity periods.
Customizable Timeframe:
The EMA calculations can use a higher timeframe (e.g., 5m, 15m, 1H, 4H, 1D, default: 1H) via request.security.
This allows the strategy to base signals on longer-term trends while operating on a shorter-term chart.
Trade Management:
Fixed trade size of €100,000 per trade (tradeAmount), with a maximum quantity cap (maxQty = 10,000) to prevent oversized trades.
Counter-trades: Closes short positions before entering a long position and vice versa.
Trades are executed with a minimum quantity of 1 to ensure valid orders.
Visualization:
EMA Lines: The short EMA is colored based on the last signal (green for buy, red for sell, gray for neutral), and the long EMA is orange.
Signal Markers: Displays buy/sell signals as arrows (triangles) above/below candles if enabled (showSignalShapes).
Background/Candle Coloring: Optionally colors the chart background or candles green (bullish) or red (bearish) based on the trend (useColoredBars).
Statistics Display:
If enabled (useStats), a label on the chart shows:
Total closed trades
Open trades
Win rate (%)
Number of winning/losing trades
Profit factor (gross profit / gross loss)
Net profit
Maximum drawdown
Configuration Inputs
EMA Short Length (emaLength): Length of the short-term EMA (default: 1).
Trend EMA Length (trendLength): Length of the long-term EMA (default: 20).
Enable Trend Filter (useTrendFilter): Toggles trend-based filtering (default: true).
Color Candles (useColoredBars): Colors candles instead of the background (default: true).
Enable Session Filter (useSessionFilter): Restricts trading to specified hours (default: false).
Trading Session (sessionStart): Defines trading hours (default: 09:00–17:00).
Show Statistics (useStats): Displays performance stats on the chart (default: true).
Show Signal Arrows (showSignalShapes): Displays buy/sell signals as arrows (default: true).
Use Instant Signals (useInstantSignals): Generates signals based on live price action (default: false).
EMA Timeframe (emaTimeframe): Timeframe for EMA calculations (options: 5m, 15m, 1H, 4H, 1D; default: 1H).
Strategy Logic
Signal Generation:
Standard Mode: Signals are based on EMA crossovers (short EMA crossing long EMA) at candle close.
Instant Mode: Signals are based on the current price crossing the short EMA, enabling faster reactions.
Trade Execution:
On a buy signal, closes any short position and opens a long position.
On a sell signal, closes any long position and opens a short position.
Position size is calculated as the minimum of €100,000 or available equity, divided by the current price, capped at 10,000 units.
Filters:
Trend Filter: Ensures trades align with the trend direction (if enabled).
Session Filter: Restricts trades to user-defined market hours (if enabled).
Visual Feedback
EMA Lines: Provide a clear view of the short and long EMAs, with the short EMA’s color reflecting the latest signal.
Signal Arrows: Large green triangles (buy) below candles or red triangles (sell) above candles for easy signal identification.
Chart Coloring: Highlights bullish (green) or bearish (red) trends via background or candle colors.
Statistics Label: Displays key performance metrics in a label above the chart for quick reference.
Usage Notes
Initial Capital: €100,000 (configurable via initial_capital).
Currency: EUR (set via currency).
Order Processing: Orders are processed at candle close (process_orders_on_close=true) unless instant signals are enabled.
Dynamic Requests: Allows dynamic timeframe adjustments for EMA calculations (dynamic_requests=true).
Platform: Designed for TradingView, compatible with any market supported by the platform (e.g., stocks, forex, crypto).
Example Use Case
Scenario: Trading on a 5-minute chart with a 1-hour EMA timeframe, trend filter enabled, and session filter set to 09:00–17:00.
Behavior: The strategy will:
Calculate EMAs on the 1-hour timeframe.
Generate buy signals when the short EMA crosses above the long EMA (and price is above the long EMA).
Generate sell signals when the short EMA crosses below the long EMA (and price is below the long EMA).
Execute trades only during 09:00–17:00.
Display green/red candles and performance stats on the chart.
Limitations
Instant Signals: May lead to more frequent signals, increasing the risk of false positives in volatile markets.
Fixed Trade Size: Does not adjust dynamically based on market conditions beyond equity and max quantity limits.
Session Filter: Simplified and may not account for complex session rules or holidays.
Statistics: Displayed on-chart, which may clutter the view in smaller charts.
Customization
Adjust emaLength and trendLength to suit different market conditions (e.g., shorter for scalping, longer for swing trading).
Toggle useInstantSignals for faster or more stable signal generation.
Modify sessionStart to align with specific market hours.
Disable useStats or showSignalShapes for a cleaner chart.
This strategy is versatile for both manual and automated trading, offering flexibility for various markets and trading styles while providing clear visual and statistical feedback.
Optimized ADX DI CCI Strategy### 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- (or DI- crosses over DI+), CCI < MA (or CCI crosses under MA), and optional ADX/RSI filters are satisfied.
3. **Trade Execution**:
- **Entry**: Long or short trades are opened using `strategy.entry` when signals are detected, provided trading is allowed (`allow_long`/`allow_short`) and equity is positive.
- **Exit**: Trades can be closed based on:
- Opposite signal (if no other exit conditions are used).
- MA cross (price crossing below/above the exit MA for long/short trades).
- ADX percentage change exceeding a threshold.
- Performance-based stop-loss (trade loss exceeding a percentage).
- **Countertrading**: If enabled, closing a trade triggers an opposite trade (e.g., closing a long opens a short).
4. **Visualization**:
- Labels are plotted at trade entries/exits (e.g., "BUY," "SELL," arrows).
- Optional background coloring highlights open trades (green for long, red for short).
- A statistics table displays real-time metrics (e.g., capital, win rates).
5. **Trade Tracking**:
- Tracks the number of long/short trades, wins, and overall performance.
- Monitors equity to prevent trading if it falls to zero.
### 2.3 Key Components
- **Indicator Calculations**: Uses `request.security` to fetch indicator data for the specified timeframe.
- **MA Function**: A custom `ma_func` handles different MA types for CCI and exit conditions.
- **Signal Logic**: Combines crossover/under checks with recent bar windows for flexibility.
- **Exit Conditions**: Multiple configurable exit strategies for risk management.
- **Statistics Table**: Updates dynamically with trade and capital metrics.
## 3. Configuration Options
The script provides extensive customization through input parameters, grouped for clarity in the TradingView settings panel. Below is a detailed breakdown of each setting and its impact.
### 3.1 Strategy Settings (Global)
- **Initial Capital**: Default `10000`. Sets the starting capital for backtesting.
- **Effect**: Determines the base equity for calculating position sizes and performance metrics.
- **Default Quantity Type**: `strategy.percent_of_equity` (50% of equity).
- **Effect**: Controls the size of each trade as a percentage of available equity.
- **Pyramiding**: Default `2`. Allows up to 2 simultaneous trades in the same direction.
- **Effect**: Enables multiple entries if conditions are met, increasing exposure.
- **Commission**: 0.2% per trade.
- **Effect**: Simulates trading fees, reducing net profit in backtesting.
- **Margin**: 100% for long and short trades.
- **Effect**: Assumes no leverage; adjust for margin trading simulations.
- **Calc on Every Tick**: `true`.
- **Effect**: Ensures real-time signal updates for precise execution.
### 3.2 Indicator Settings
- **Indicator Timeframe** (`indicator_timeframe`):
- **Options**: `""` (chart timeframe), `1`, `5`, `15`, `30`, `60`, `240`, `D`, `W`.
- **Default**: `""` (uses chart timeframe).
- **Effect**: Determines the timeframe for ADX, DI, CCI, and RSI calculations. A higher timeframe reduces noise but may delay signals.
### 3.3 ADX & DI Settings
- **DI Length** (`adx_di_len`):
- **Default**: `30`.
- **Range**: Minimum `1`.
- **Effect**: Sets the period for calculating DI+ and DI-. Longer periods smooth trends but reduce sensitivity.
- **ADX Smoothing Length** (`adx_smooth_len`):
- **Default**: `14`.
- **Range**: Minimum `1`.
- **Effect**: Smooths the ADX calculation. Longer periods produce smoother ADX values.
- **Use ADX Filter** (`use_adx_filter`):
- **Default**: `false`.
- **Effect**: If `true`, requires ADX to exceed the threshold for signals to be valid, filtering out weak trends.
- **ADX Threshold** (`adx_threshold`):
- **Default**: `25`.
- **Range**: Minimum `0`.
- **Effect**: Sets the minimum ADX value for valid signals when the filter is enabled. Higher values restrict trades to stronger trends.
### 3.4 CCI Settings
- **CCI Length** (`cci_length`):
- **Default**: `20`.
- **Range**: Minimum `1`.
- **Effect**: Sets the period for CCI calculation. Longer periods reduce noise but may lag.
- **CCI Source** (`cci_src`):
- **Default**: `hlc3` (average of high, low, close).
- **Effect**: Defines the price data for CCI. `hlc3` is standard, but users can choose other sources (e.g., `close`).
- **CCI MA Type** (`ma_type`):
- **Options**: `SMA`, `EMA`, `SMMA (RMA)`, `WMA`, `VWMA`.
- **Default**: `SMA`.
- **Effect**: Determines the moving average type for CCI signal smoothing. EMA is more responsive; VWMA weights by volume.
- **CCI MA Length** (`ma_length`):
- **Default**: `14`.
- **Range**: Minimum `1`.
- **Effect**: Sets the period for the CCI MA. Longer periods smooth the MA but may delay signals.
### 3.5 RSI Filter Settings
- **Use RSI Filter** (`use_rsi_filter`):
- **Default**: `false`.
- **Effect**: If `true`, applies RSI-based overbought/oversold filters to signals.
- **RSI Length** (`rsi_length`):
- **Default**: `14`.
- **Range**: Minimum `1`.
- **Effect**: Sets the period for RSI calculation. Longer periods reduce sensitivity.
- **RSI Lower Limit** (`rsi_lower_limit`):
- **Default**: `30`.
- **Range**: `0` to `100`.
- **Effect**: Defines the oversold threshold for buy signals. Lower values allow trades in more extreme conditions.
- **RSI Upper Limit** (`rsi_upper_limit`):
- **Default**: `70`.
- **Range**: `0` to `100`.
- **Effect**: Defines the overbought threshold for sell signals. Higher values allow trades in more extreme conditions.
### 3.6 Signal Settings
- **Cross Window** (`cross_window`):
- **Default**: `0`.
- **Range**: `0` to `5` bars.
- **Effect**: Specifies the lookback period for detecting DI+/- or CCI crosses. `0` requires crosses on the current bar; higher values allow recent crosses, increasing signal frequency.
- **Allow Long Trades** (`allow_long`):
- **Default**: `true`.
- **Effect**: Enables/disables new long trades. If `false`, only closing existing longs is allowed.
- **Allow Short Trades** (`allow_short`):
- **Default**: `true`.
- **Effect**: Enables/disables new short trades. If `false`, only closing existing shorts is allowed.
- **Require DI+/DI- Cross for Buy** (`buy_di_cross`):
- **Default**: `true`.
- **Effect**: If `true`, requires a DI+ crossover DI- for buy signals; if `false`, 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.