TradingView
ChaseSpeegle
3 May 2023 20:38

BUY/SELL + ADVANCE DECLINE 

SPDR S&P 500 ETF TRUSTArca

Açıklama

This script is a custom trading view indicator that helps to identify potential buy and sell signals based on the RSI (Relative Strength Index) and SMA (Simple Moving Average) indicators. The script also identifies potential reversals using a combination of RSI and price action. It plots buy, sell, and reversal signals on the chart along with an SMA line. Additionally, it provides alerts based on the buy, sell, and reversal conditions.

Changes made to the original script:

Fixed the undeclared identifier 'c' error by calculating the difference between the current closing price and the previous closing price: c = close - close[1].

Added an "ADD Value Floating Label" to the chart. The label shows the difference between the current and previous closing prices (ADD value) along with a "Bullish" or "Bearish" indicator based on the value of 'c'. The label is positioned at the top right of the visible chart area and remains static.

Here's a summary of the major components of the script:

Input settings: Define the input parameters for RSI and SMA.
Calculation of RSI and SMA: Compute the RSI and SMA values based on the input parameters.
Color definitions: Define colors for different conditions and levels.
Condition definitions: Define various conditions for buy, sell, reversal, and other criteria.
Buy and sell conditions: Determine buy and sell signals based on RSI, SMA, and price action.
Reversal conditions: Identify potential reversals using RSI and price action.
Plot signals: Display buy, sell, and reversal signals on the chart.
Bar colors: Color the bars based on the identified signals.
Plot SMA: Display the SMA line on the chart.
Alert conditions: Set up alerts for buy, sell, and reversal conditions.
ADD Value Floating Label: Add a label to the chart showing the ADD value and a "Bullish" or "Bearish" indicator.

Sürüm Notları

Moved ADD Label up 10 units from previous day high. It was kind of in the way prior.

Sürüm Notları

This script corrects the ADD Advance Decline Readings WITH ACCURATE ADD readings as well as moves them to a separate pane. I am still trying to find a way to move the BUY/SELL & Reversal Signals back to the Main Chart, but for now they reside in the ADD pane. Thank you!

Sürüm Notları

Removal of the ADD Label on the Main Chart:

In the previous version of the script, the ADD indicator was plotted on the main chart with a label (+ or -) indicating its direction. In the current version, this label has been removed from the main chart by commenting out the following line:

pinescript
Copy code
// plot(a, title='ADD', color=dircol, linewidth=4)
This change ensures that the ADD label (+ or -) no longer appears on the main chart, but the ADD indicator and its associated up and down arrows for reversals remain in the separate ADD frame.

The removal of the ADD label (INCORRECT READING/CALCULATION) was the only change made in the current version compared to the previous version of the script. All other functionality, including the calculation of various technical indicators, buy/sell signals, and reversal signals, remains the same in both versions.

This is a much CLEANER, more accurate indicator now.


//@version=5
indicator(title='CHASES BUY/SELL INDICATOR + ADVANCE DECLINE', shorttitle='BUY/SELL + ADD', precision=2, overlay=false)

// ADD Indicator
a = request.security('USI:ADD', '5', hlc3)
dircol = a > a[1] ? color.green : color.red

//plot(a, title='ADD', color=dircol, linewidth=4)
m10 = ta.sma(a, 10)
plot(m10, color=color.new(color.black, 0), linewidth=2)

// Input settings
rsi_length = input.int(14, title='RSI Length', step=1)
rsi_upper = input.int(80, title='Higher Value of RSI', step=1)
rsi_lower = input.int(20, title='Lower value of RSI', step=1)
sma_length = input.int(70, title='SMA Length', step=1)

// Calculate RSI and SMA
rsi = ta.rsi(close, rsi_length)
sma = ta.sma(close, sma_length)

// Define colors
color_below_sma = color.new(color.red, 30)
color_above_sma = color.new(color.lime, 30)
color_between = color.new(color.yellow, 30)

// Set color based on conditions
sma_color = rsi >= rsi_upper or rsi <= rsi_lower ? color_between : (high < sma ? color_below_sma : color_above_sma)

// Define distances and gaps
dist_sma = 1
candle_length = 1
gap_above_sma = sma + dist_sma
gap_below_sma = sma - dist_sma
gap_value = open / 100 * candle_length

// Define conditions
min_candle_size_buy = high - low > gap_value
min_candle_size_sell = high - low > gap_value
bull = open < close and high - low > 2 * gap_value and close > (high + open) / 2
bear = open > close and high - low > 2 * gap_value and close < (low + open) / 2

// Reversal conditions
rev1 = rsi > 68 and open > close and open > gap_above_sma and high - low > gap_value + 0.5 and low != close
rev1a = rsi > 90 and open < close and close > gap_above_sma and high != close and open != low
sell_reversal = rev1 or rev1a

rev2 = rsi < 50 and open < close and open < gap_below_sma and open == low
rev3 = rsi < 30 and open > close and high > gap_below_sma and open != high and barstate.isconfirmed != bear
rev4 = rsi < 85 and close == high and high - low > gap_value and open < close
rsi_cross_under_upper = ta.crossunder(rsi, rsi_upper)
rsi_cross_over_lower = ta.crossover(rsi, rsi_lower) and open < close

// Buy and sell conditions
volume_increase = volume > volume[1]
buy_condition = open < close and open > sma and ta.cross(close[1], sma) and close > sma
sell_condition = ta.cross(close, sma) and open > close
buy_signal = ta.crossover(close[1], sma) and close[1] > open[1] and high[0] > high[1] and close[0] > open[0]
sell_signal = ta.crossunder(low[1], sma) and close[1] < open[1] and low[0] < low[1] and close[0] < open[0]

// Calculate the value of 'c'
c = close - close[1]

// Plot signals
plotshape(sell_signal, title='SELL', style=shape.labeldown, color=color.new(color.red, 30), text='SELL', textcolor=color.new(color.black, 30))
plotshape(buy_signal, title='BUY', style=shape.labelup, color=color.new(color.aqua, 30), text='BUY', textcolor=color.new(color.black, 30), location=location.belowbar)

// Plot reversals
plotshape(rsi_cross_under_upper, title='Reversal1', style=shape.labeldown, color=color.new(color.yellow, 20), text='↓', textcolor=color.new(color.black, 20))
plotshape(rsi_cross_over_lower, title='Reversal2', style=shape.labelup, color=color.new(color.yellow, 20), text='↑', textcolor=color.new(color.black, 20), location=location.belowbar)

// Bar colors
barcolor(buy_signal ? color.new(color.green, 0) : sell_signal ? color.new(color.maroon, 30) : rsi_cross_under_upper or rsi_cross_over_lower ? color.new(color.yellow, 0) : na)

// Alert conditions
alertcondition(rsi_cross_under_upper or rsi_cross_over_lower, title='Both Reversal Signal', message='Reversal Alert')
alertcondition(sell_signal or buy_signal, title='Buy & Sell Signal Both', message='Buy/Sell Alert')
alertcondition(buy_signal, title='Only Buy Signal', message='Buy Alert')
alertcondition(sell_signal, title='Only Sell Signal', message='Sell Alert')
alertcondition(rsi_cross_under_upper, title='Reversal from Top', message='Down Reversal Alert')
alertcondition(rsi_cross_over_lower, title='Reversal from Down', message='Up Reversal Alert')

Sürüm Notları

Let's highlight the key differences and what this updated script can do compared to the prior version:

Improved Visualization in ADD Pane:

In this updated script, the ADD indicator and BUY/SELL signals are correctly plotted within the ADD pane. This provides a more organized and visually appealing view of key trading information.
Clearer Buy and Sell Signals:

The script now clearly marks BUY signals with green triangles ('↑') and SELL signals with red triangles ('↓'), making it easier for traders to identify potential entry and exit points.
Enhanced Reversal Signals:

Reversal signals are marked with '↑' and '↓' symbols in the ADD pane, providing additional insights into potential trend changes.
Bar Color Coding:

The script color-codes bars in the main chart to highlight different conditions. Green bars indicate BUY signals, maroon bars indicate SELL signals, and yellow bars indicate reversal signals. This helps traders quickly assess the current market conditions.
Alert System:

The script includes an alert system that can notify traders when specific conditions are met. It can send alerts for both reversals and BUY/SELL signals, allowing traders to stay informed even when they are not actively monitoring the chart.
Customizable Parameters:

The script offers customizable input parameters for RSI length, RSI upper and lower values, and SMA length, allowing traders to adapt the indicator to their preferred trading strategies.
Technical Analysis Features:

The script incorporates various technical analysis features, such as RSI, SMA, and gap-related conditions, to help traders make informed trading decisions.
Consolidated Information:

All key trading information, including the ADD indicator, BUY/SELL signals, and reversals, are now conveniently displayed in one chart. This consolidated view simplifies analysis and decision-making.
Overall, this updated script enhances the visualization, clarity, and functionality of the indicator, making it a valuable tool for traders seeking to identify potential entry and exit points in the market.
Yorumlar
ChaseSpeegle
This pairs nicely with Ripsters EMA clouds ☁️ Like cheese and fine wine.
ChaseSpeegle
Inputs

RSI Length
3
Higher Value of RSI
65
Lower value of RSI
35
SMA Length
8

This is what I’m using. But do what you like :)
ChaseSpeegle
@ChaseSpeegle, Here are some suggested RSI settings:

RSI Length:

For short-term trading, consider using a relatively short RSI length, such as 5, 6, or 9. These values will make the RSI more responsive to recent price changes.
Higher Value of RSI:

The traditional overbought level for RSI is 70. However, for short-term trading, you might want to consider a slightly lower value, like 65 or even 60. This adjustment allows you to identify potential overbought conditions sooner in shorter timeframes.
Lower Value of RSI:

The traditional oversold level for RSI is 30. For short-term trading, you could use a slightly higher value, such as 35 or 40. This adjustment helps you identify potential oversold conditions more quickly in shorter timeframes.
SMA Length (Optional):

Some traders like to add a simple moving average (SMA) to their RSI indicator. This SMA can help smooth out RSI readings and provide additional confirmation. A common SMA length for this purpose is 14.
ChaseSpeegle
While there isn't a definitive cheat sheet for interpreting ADD values, you can use the following general guidelines:

Positive ADD value: A positive ADD value indicates that the current closing price is higher than the previous closing price, which could be a sign of bullishness or upward momentum in the market. The larger the positive value, the stronger the upward movement.

Negative ADD value: A negative ADD value indicates that the current closing price is lower than the previous closing price, which could be a sign of bearishness or downward momentum in the market. The larger the negative value, the stronger the downward movement.

Close to zero or small ADD value: If the ADD value is close to zero or very small, it could indicate a lack of significant price movement or a consolidating market. This could mean that there is indecision in the market, and traders might be waiting for more information or a breakout in either direction.
ChaseSpeegle
Hey! How’re you all liking this indicator? Do you find it helpful? I appreciate your feedback! Thank you!
ChaseSpeegle
Here’s an updated description:

**Description:**
This refined TradingView script provides SPY traders with a powerful visualization of market breadth through the Advanced Decline Line (ADD), integrated with robust buy/sell signals for effective decision-making.

**Key Features:**

- **Market Breadth Visualization**: Merges ADD data directly in the trading pane, offering a comprehensive view of market sentiment alongside SPY's price action.

- **Intuitive Buy/Sell Indicators**: Deploys prominent green upward triangles to signal buying opportunities and red downward triangles for selling cues, aligned with ADD movements.

- **Dynamic Reversal Signals**: Yellow arrows and bars indicate potential reversals, suggesting caution or a change in trade strategy.

- **Bar Color Coding**: Enhances visual analysis with color-coded bars—green for bullish periods, maroon for bearish, and yellow for pending reversals.

- **Integrated Alert System**: Automates notifications for buy, sell, and reversal signals, ensuring traders remain updated without constant chart monitoring.

- **Customizable Sensitivity**: Allows for the adjustment of RSI and SMA lengths, and RSI thresholds to tailor the script to individual trading styles.

- **Technical Analysis Tools**: Combines RSI and SMA calculations with gap analysis to inform trades based on a fusion of technical indicators.

- **Consolidated Signal Dashboard**: Centralizes critical trading information within the ADD pane for streamlined analysis and execution.

**Usage:**
Designed for traders who factor market breadth into their SPY trading decisions. It's optimal for identifying strategic entry and exit points and adjusting positions according to broad market movements.
ChaseSpeegle
Let's go through the interpretation of ADD (Advance-Decline) readings with numerical examples:

Positive ADD Reading:
Interpretation: A positive ADD reading indicates more advancing stocks than declining stocks in the market, suggesting broad market strength.
Example: If there are 2,000 stocks advancing and 1,000 stocks declining, the ADD reading is +1,000 (2,000 - 1,000).
Implication for Trading:
If you receive a BUY signal while the ADD reading is +1,000, it confirms the bullish sentiment in the broader market, strengthening your confidence in the BUY trade.

Negative ADD Reading:
Interpretation: A negative ADD reading indicates more declining stocks than advancing stocks, suggesting broad market weakness.
Example: If there are 1,000 stocks advancing and 2,000 stocks declining, the ADD reading is -1,000 (1,000 - 2,000).
Implication for Trading:
If you receive a SELL signal while the ADD reading is -1,000, it confirms the bearish sentiment in the broader market, strengthening your confidence in the SELL trade.

Divergence Between ADD and Price:
Interpretation: Divergence occurs when ADD readings and price movements move in opposite directions, indicating potential shifts in market sentiment.
Example: SPY is rising (indicating a BUY signal), but the ADD reading is flat or declining.
Implication for Trading:
This divergence suggests that despite the SPY price rising, market breadth is not supporting the move. It could be a sign of caution and might make you reconsider the strength of the BUY signal.
ChaseSpeegle
@ChaseSpeegle

Extreme ADD Readings:
Interpretation: Extremely high or low ADD readings indicate overbought or oversold market conditions.Example: An ADD reading of +2,500 (indicating many more advancing stocks) might be considered extremely positive.
Implication for Trading:
An extremely positive ADD reading could signal a potential overbought condition, possibly leading to a market pullback. It may be wise to exercise caution with BUY signals in such situations.
Market Context:
Interpretation: Consider ADD readings in the context of the broader market trend and events.
Example: If the overall market is in a strong uptrend, even a moderately positive ADD reading may carry more weight.
Implication for Trading:
In a strong uptrend, ADD readings can help confirm the bullish bias and provide additional support for BUY signals.
Intraday Analysis:
Interpretation: When trading SPY 0DTE options on short timeframes, monitor intraday ADD readings for quick sentiment shifts.
Example: On a 5-minute chart, if ADD readings turn strongly negative while SPY is attempting a rally, it could signal short-term bearish sentiment.
Implication for Trading:
Short-term ADD readings can help you assess short-term market breadth and make rapid trading decisions aligned with the intraday sentiment.
Remember that these numerical examples are simplified for illustration. In real-world trading, you'll encounter more dynamic ADD readings and market conditions. Always use ADD readings as a complementary tool alongside other forms of analysis and risk management when making trading decisions.
devinmorell
Im going to give this indicator a try.
ChaseSpeegle
@devinmorell, Hey Devin, I've updated it and made it a much more cleaner indicator, let me know what you think! Thank you!
Daha Fazla