This Pine Script indicator plots an "Exposure Oscillator" on the chart, which tracks the cumulative market exposure from a range of technical buy and sell signals. The exposure is measured on a scale from -100% (maximum short exposure) to +100% (maximum long exposure), helping traders assess the strength of their position in the market. It provides an intuitive visual cue to aid decision-making for trend-following strategies.
Buy Signals (Increase Exposure Score by +10%) Buy Signal 1 (Cross Above 21 EMA): This signal is triggered when the price crosses above the 21-period Exponential Moving Average (EMA), where the current bar closes above the EMA21, and the previous bar closed below the EMA21. This indicates a potential upward price movement as the market shifts into a bullish trend.
buySignal1 = ta.crossover(close, ema21)
Buy Signal 2 (Trending Above 21 EMA): This signal is triggered when the price closes above the 21-period EMA for each of the last 5 bars, indicating a sustained bullish trend. It confirms that the price is consistently above the EMA21 for a significant period.
buySignal2 = ta.barssince(close <= ema21) > 5
Buy Signal 3 (Living Above 21 EMA): This signal is triggered when the price has closed above the 21-period EMA for each of the last 15 bars, demonstrating a strong, prolonged uptrend.
buySignal3 = ta.barssince(close <= ema21) > 15
Buy Signal 4 (Cross Above 50 SMA): This signal is triggered when the price crosses above the 50-period Simple Moving Average (SMA), where the current bar closes above the 50 SMA, and the previous bar closed below it. It indicates a shift toward bullish momentum.
buySignal4 = ta.crossover(close, sma50)
Buy Signal 5 (Cross Above 200 SMA): This signal is triggered when the price crosses above the 200-period Simple Moving Average (SMA), where the current bar closes above the 200 SMA, and the previous bar closed below it. This suggests a long-term bullish trend.
buySignal5 = ta.crossover(close, sma200)
Buy Signal 6 (Low Above 50 SMA): This signal is true when the lowest price of the current bar is above the 50-period SMA, indicating strong bullish pressure as the price maintains itself above the moving average.
buySignal6 = low > sma50
Buy Signal 7 (Accumulation Day): An accumulation day occurs when the closing price is in the upper half of the daily range (greater than 50%) and the volume is larger than the previous bar's volume, suggesting buying pressure and accumulation.
Buy Signal 8 (Higher High): This signal occurs when the current bar’s high exceeds the highest high of the previous 14 bars, indicating a breakout or strong upward momentum.
buySignal8 = high > ta.highest(high, 14)[1]
Buy Signal 9 (Key Reversal Bar): This signal is generated when the stock opens below the low of the previous bar but rallies to close above the previous bar’s high, signaling a potential reversal from bearish to bullish.
buySignal9 = open < low[1] and close > high[1]
Buy Signal 10 (Distribution Day Fall Off): This signal is triggered when a distribution day (a day with high volume and a close near the low of the range) "falls off" the rolling 25-bar period, indicating the end of a bearish trend or selling pressure.
Sell Signal 1 (Cross Below 21 EMA): This signal is triggered when the price crosses below the 21-period Exponential Moving Average (EMA), where the current bar closes below the EMA21, and the previous bar closed above it. It suggests that the market may be shifting from a bullish trend to a bearish trend.
sellSignal1 = ta.crossunder(close, ema21)
Sell Signal 2 (Trending Below 21 EMA): This signal is triggered when the price closes below the 21-period EMA for each of the last 5 bars, indicating a sustained bearish trend.
sellSignal2 = ta.barssince(close >= ema21) > 5
Sell Signal 3 (Living Below 21 EMA): This signal is triggered when the price has closed below the 21-period EMA for each of the last 15 bars, suggesting a strong downtrend.
sellSignal3 = ta.barssince(close >= ema21) > 15
Sell Signal 4 (Cross Below 50 SMA): This signal is triggered when the price crosses below the 50-period Simple Moving Average (SMA), where the current bar closes below the 50 SMA, and the previous bar closed above it. It indicates the start of a bearish trend.
sellSignal4 = ta.crossunder(close, sma50)
Sell Signal 5 (Cross Below 200 SMA): This signal is triggered when the price crosses below the 200-period Simple Moving Average (SMA), where the current bar closes below the 200 SMA, and the previous bar closed above it. It indicates a long-term bearish trend.
sellSignal5 = ta.crossunder(close, sma200)
Sell Signal 6 (High Below 50 SMA): This signal is true when the highest price of the current bar is below the 50-period SMA, indicating weak bullishness or a potential bearish reversal.
sellSignal6 = high < sma50
Sell Signal 7 (Distribution Day): A distribution day is identified when the closing range of a bar is less than 50% and the volume is larger than the previous bar's volume, suggesting that selling pressure is increasing.
Sell Signal 8 (Lower Low): This signal occurs when the current bar's low is less than the lowest low of the previous 14 bars, indicating a breakdown or strong downward momentum.
sellSignal8 = low < ta.lowest(low, 14)[1]
Sell Signal 9 (Downside Reversal Bar): A downside reversal bar occurs when the stock opens above the previous bar's high but falls to close below the previous bar’s low, signaling a reversal from bullish to bearish.
sellSignal9 = open > high[1] and close < low[1]
Sell Signal 10 (Distribution Cluster): This signal is triggered when a distribution day occurs three times in the rolling 7-bar period, indicating significant selling pressure.
Users can select the theme mode (Auto, Dark, or Light) to match the chart's background or to manually choose a light or dark theme for the oscillator's appearance.
Exposure Score Calculation: The script calculates a cumulative exposure score based on a series of buy and sell signals.
Buy signals increase the exposure score, while sell signals decrease it. Each signal impacts the score by ±10%.
Signal Conditions: The buy and sell signals are derived from multiple conditions, including crossovers with moving averages (EMA21, SMA50, SMA200), trend behavior, and price/volume analysis.
Oscillator Visualization: The exposure score is visualized as a line on the chart, changing color based on whether the exposure is positive (long position) or negative (short position). It is limited to the range of -100% to +100%.
Position Type: The indicator also indicates the position type based on the exposure score, labeling it as "Long," "Short," or "Neutral."
Horizontal Lines: Reference lines at 0%, 100%, and -100% visually mark neutral, increasing long, and increasing short exposure levels.
Exposure Table: A table displays the current exposure level (in percentage) and position type ("Long," "Short," or "Neutral"), updated dynamically based on the oscillator’s value. Inputs:
Theme Mode: Choose "Auto" to use the default chart theme, or manually select "Dark" or "Light."
Usage: This oscillator is designed to help traders track market sentiment, gauge exposure levels, and manage risk. It can be used for long-term trend-following strategies or short-term trades based on moving average crossovers and volume analysis.
The oscillator operates in conjunction with the chart’s price action and provides a visual representation of the market’s current trend strength and exposure. Important Considerations:
Risk Management: While the exposure score provides valuable insight, it should be combined with other risk management tools and analysis for optimal trading decisions.
Signal Sensitivity: The accuracy and effectiveness of the signals depend on market conditions and may require adjustments based on the user’s trading strategy or timeframe.
Disclaimer: This script is for educational purposes only. Trading involves significant risk, and users should carefully evaluate all market conditions and apply appropriate risk management strategies before using this tool in live trading environments.
ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.