This Pine Script code generates a trading indicator that calculates and displays various data points on a stock, including Average Daily Range (ADR%), Market Cap, Current Volume, Free Cash Flow (FCF) Yield %, Float %, whether moving averages (MA) are inline, and the moving averages of certain indexes like the Russell 2000, Nasdaq 100, and S&P 500. Here’s a breakdown of the script and how to use it. Key Concepts and Functionality
Indicator Definition: The script begins by defining the indicator with a title (Swing Data - Optimized ADR%...) and short title (Optimized Swing Data), which will appear on the chart. The overlay=true command ensures that the indicator is drawn on the main price chart rather than in a separate pane.
Sector and Ticker: s = syminfo.tickerid: This stores the ticker ID of the stock being analyzed. sector = syminfo.sector: This retrieves the sector to which the stock belongs. If the sector information is unavailable, it assigns the value "N/A".
Dynamic Inputs: Several input parameters allow you to customize the indicator: adrp_len: Defines the length for ADR% calculation. len: Defines the moving average length for volume. tbl_size, bg_col, and txt_col: Control the table's appearance, including the size of the text, background color, and text color. posTable: Allows positioning of the table on the chart. Options include top-left, top-right, bottom-left, and bottom-right. show_empty_row: Adds an empty row above the displayed values if set to true.
Volume Unit Handling (f_vol_unit): This function converts volume into appropriate units, like thousands (K), millions (M), or billions (B), to make volume easier to read. It’s applied to both the current volume and the average daily volume.
Moving Averages for Indexes (f_ma_indexes): This function calculates the 10-day, 20-day, 50-day, and 200-day simple moving averages (SMAs) for an index (such as Russell 2000 or Nasdaq 100). It also checks whether the MAs are inline, meaning if shorter MAs are above longer MAs, which is usually a bullish sign. It returns the result as "YES" or "NO" and assigns a color (green for yes, red for no).
Volume and Price Data: The script fetches several important data points: vol_display: Current volume in human-readable units. avgDaVol: Average daily volume. adrp: Average Daily Range (ADR%) over a specified length. fcf_yield_percent: Free Cash Flow Yield percentage.
ADR Calculation: The ADR% is calculated using the formula 100 * (ta.sma(high / low, adrp_len) - 1) and is fetched for the daily timeframe.
FCF Yield Color Logic: The Free Cash Flow yield is classified into three categories: Green: Undervalued if FCF yield is over 5%. Yellow: Neutral between 2-5%. Red: Overvalued if below 2%.
MA's Inline Check for the Stock: The script checks if the stock's 10-day, 20-day, 50-day, and 200-day moving averages are inline (i.e., in a bullish alignment where shorter MAs are higher than longer MAs).
Float % Calculation: The float percentage is calculated as the ratio of float shares outstanding (FSO) to total shares outstanding (TSO). The color is set based on its breakout potential:
Price Change %: The script calculates the percentage change in price between the current and previous close.
Volume Color Logic: The color of the "Current Volume" is based on whether it indicates buying or selling pressure:
Green: Volume is higher than average, and the price increased more than ADR%. Red: Volume is higher than average, and the price decreased more than ADR%. Yellow: Default color if neither condition is met.
Market Cap: The market cap is calculated by multiplying the total shares outstanding (TSO) by the current close price, and it’s displayed in a human-readable unit (K, M, or B).
Display Table:
A table is created to display all the calculated data in an organized manner. It includes fields for Market Cap, Avg Volume, ADR%, Current Volume, FCF Yield %, Float %, MA's Inline status, and Sector. Additionally, it shows the inline status for the Russell 2000, Nasdaq 100, and S&P 500. How to Use:
Customization: Users can customize the inputs, including the length of ADR% and volume moving averages, and adjust the table size, text color, and position. Visualization: The indicator provides a comprehensive table on the chart showing key data points for technical analysis, including whether moving averages are inline for both the stock and major indexes.
This indicator is particularly useful for swing traders or technical analysts who want a clear overview of a stock’s volume, volatility (via ADR%), and the alignment of moving averages, combined with fundamental metrics like market cap and free cash flow yield.
Этот скрипт опубликован с закрытым исходным кодом, вы можете свободно им пользоваться. Можно добавить его в избранное и использовать на графике. Вы не можете просматривать или менять его исходный код.
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.