Trend Meter [MMT]The Trend Meter is a dynamic Pine Script indicator designed to provide traders with a clear, multi-dimensional view of market trends and momentum across different timeframes and metrics. By integrating Exponential Moving Averages (EMAs), Volume-Weighted Average Price (VWAP), higher timeframe (HTF) analysis, and Regular Trading Hours (RTH) breakouts, this indicator offers a comprehensive tool for identifying bullish, bearish, or neutral market conditions. Its customizable visual display and label system make it ideal for traders seeking actionable insights for trend-following, breakout, or reversal strategies.
Key Features:
1. Multi-Metric Trend Analysis:
- Trend Meter : Compares a Fast EMA (default: 9) and Slow EMA (default: 21) to determine short-term trend direction.
- Bias Meter : Uses a longer-term Bias EMA (default: 35) to assess the overall market bias based on the close price.
- VWAP Meter : Evaluates price position relative to the VWAP for dynamic support/resistance insights.
- HTF Meter : Analyzes higher timeframe (default: 60-minute) price action, detecting breakouts of previous highs/lows and candle direction.
- RTH Meter : Tracks price breakouts above/below the US Regular Trading Hours (09:30–16:00 EST) 15m opening range (09:30–09:45 EST).
2. Color-Coded Visuals:
- Each metric is displayed as a horizontal line with customizable colors (green for bullish, red for bearish, gray for neutral).
- Visual style options (dotted, dashed, or solid lines) allow for personalized chart clarity.
3. Dynamic Labels:
- Optional labels for each metric (Trend, Bias, VWAP, HTF, RTH) with customizable text, size (tiny to huge), and color.
- Labels update in real-time, providing clear identification of each meter’s role and current state.
4. Flexible Metric Selection:
- Toggle individual metrics (EMA, VWAP, HTF, RTH) on/off to focus on relevant indicators for your trading style.
- Option to use the previous bar’s close price for calculations, reducing noise in volatile markets.
5. RTH and Opening Range Analysis:
- Calculates the high/low of the opening range (09:30–09:45 EST) during RTH sessions.
- Signals bullish or bearish conditions when the price breaks above/below the opening range outside the initial 15-minute window.
6. Higher Timeframe Breakout Detection:
- Monitors HTF price action to identify breakouts of the previous candle’s high or low, combined with the HTF candle’s direction for trend confirmation.
How to Use:
- Trend Confirmation : Use the Trend and Bias Meters to confirm short-term and long-term market direction.
- Breakout Trading : Leverage the RTH Meter for breakout setups above/below the opening range during US trading hours.
- Support/Resistance : Utilize the VWAP Meter to identify dynamic price levels for entries or exits.
- Higher Timeframe Context : Monitor the HTF Meter for broader market trend alignment, ideal for swing or position trading.
- Customization : Adjust EMA lengths, toggle metrics, and customize visual styles and labels to suit your chart preferences.
Settings:
- Bias Settings :
- Fast EMA (default: 9), Slow EMA (default: 21), Bias EMA (default: 35).
- Higher Timeframe (default: 60-minute).
- Option to use previous close price for calculations.
- Enable/disable individual metrics (EMA, VWAP, HTF, RTH).
- Visual Settings :
- Bullish (green), bearish (red), and neutral (gray) colors.
- Line style (dotted, dashed, solid).
- Label Settings :
- Enable/disable labels.
- Customize label size (tiny, small, normal, large, huge) and text color.
- Custom text for each meter’s label (Trend, Bias, VWAP, HTF, RTH).
Notes:
- Optimized for intraday trading (e.g., 1m, 5m, 15m) but adaptable to any timeframe.
- RTH and opening range calculations are tailored for US markets (EST timezone); adjust session times in the code for other markets.
- Higher timeframe analysis enhances context for multi-timeframe strategies.
Ideal For:
- Intraday traders targeting RTH breakout opportunities.
- Swing traders aligning with higher timeframe trends.
- Traders using VWAP and EMA-based strategies for trend and momentum analysis.
- Those seeking a clean, customizable dashboard for multi-metric market analysis.
Индикаторы и стратегии
Trend Engine [MMT]The Trend Engine is a versatile Pine Script indicator designed to identify trend direction, potential reversals, and key price levels using a combination of Exponential Moving Averages (EMAs), and Anchored Volume-Weighted Average Price (VWAP). This indicator provides traders with a clear visual representation of market bias, momentum, and key support/resistance levels, making it suitable for both trend-following and pullback trading strategies.
Key Features:
1. EMA Cloud System:
- Displays three customizable EMAs (Fast, Pullback, and Slow) with configurable lengths and visibility.
- Creates two cloud fills:
- Fast Cloud : Between the Fast EMA (default: 8) and Pullback EMA (default: 13).
- Slow Cloud : Between the Pullback EMA and Slow EMA (default: 21).
- Clouds are color-coded (green for bullish, red for bearish) based on EMA alignment, with adjustable transparency for clarity.
2. Bias EMA:
- A longer-term EMA (default: 35) indicates the overall market bias.
- Changes color based on whether the regular candle close is above (green) or below (red) the Bias EMA, providing a clear trend direction signal.
3. Heikin Ashi Signals:
- Utilizes Heikin Ashi candles to detect strong bullish or bearish momentum.
- Generates buy/sell signals when a Heikin Ashi candle confirms a trend (bullish HA candle closing above Bias EMA for buy, bearish HA candle closing below for sell).
- Signal arrows are currently disabled but can be enabled via settings for visual confirmation.
4. Anchored VWAP and Standard VWAP:
- Plots both a standard VWAP and an Anchored VWAP (anchored to the US RTH session, 09:30–16:00 EST).
- Customizable line styles (solid, cross, or circles) and colors for both VWAPs, aiding in identifying dynamic support/resistance levels.
5. Background and Candle Coloring:
- Optional background coloring reflects the market bias (green for bullish, red for bearish) based on the regular close relative to the Bias EMA.
- Optional Heikin Ashi candle coloring to visually distinguish bullish and bearish market conditions.
6. Regular Candle Close:
- Option to plot the regular (non-Heikin Ashi) close price with customizable styles (line, circles, or cross) for reference.
7. Alerts:
- Built-in alert conditions for bullish and bearish signals, allowing traders to receive notifications when a Heikin Ashi candle confirms a trend relative to the Bias EMA.
How to Use:
- Trend Identification : Use the Bias EMA and background color to determine the overall market direction.
- Pullback Trading : Monitor the EMA clouds for alignment (bullish or bearish) and use the Pullback EMA for entries during retracements.
- Support/Resistance : Leverage the VWAP and Anchored VWAP as dynamic levels for trade entries or exits.
- Signal Confirmation : Enable signal arrows (when fixed) to spot high-probability trend continuation or reversal setups.
- Customization : Adjust EMA lengths, colors, transparency, and visibility to suit your trading style and timeframe.
Settings:
- EMA Cloud : Customize lengths (default: 8, 13, 21), visibility, and cloud colors/transparency.
- Bias EMA : Adjust length (default: 35) and colors for above/below states.
- VWAP : Toggle standard and Anchored VWAP, with customizable styles and colors.
- Background/Candles : Enable/disable background and candle coloring for visual clarity.
- Regular Close : Show/hide the regular close price with style options.
Notes:
- Designed for use on any timeframe, but most effective on intraday (e.g., 5m, 15m) or daily charts.
- Best used in conjunction with other technical analysis tools for confirmation.
- Anchored VWAP is tailored for US markets (RTH session) but can be adjusted for other sessions by modifying the anchor time in the code.
Ideal For:
- Day traders and swing traders looking for trend direction and pullback opportunities.
- Traders using VWAP-based strategies for intraday support/resistance.
- Those seeking a clean, customizable visual aid for market bias and momentum.
This indicator is a powerful tool for traders aiming to capture trends and manage risk effectively, with extensive customization to adapt to various markets and trading styles.
Top Finder & Dip Hunter [BackQuant]Top Finder & Dip Hunter
A practical tool to map where price is statistically most likely to exhaust or mean-revert. It builds objective support for dips and resistance for tops from multiple methodologies, then filters raw touches with volume, momentum, trend, and price-action context to surface higher-quality reversal opportunities.
What this does
Draws a Dip Support line and a Top Resistance line using the method you select, or a blended hybrid.
Evaluates each touch/penetration against Quality Filters and assigns a 0–100 composite score.
Prints clean DIP and TOP signals only when depth/extension and quality pass your thresholds.
Optionally annotates the chart with the computed quality score at signal time.
Why it’s useful
Objectivity: Converts vague “looks extended” into rules, reduces discretion creep.
Signal hygiene: Filters raw touches using trend, volume, momentum, and candle structure to avoid obvious traps.
Adaptable regimes: Switch methods, sensitivity, and lookbacks to match choppy vs trending conditions.
How support and resistance are built
Pick one per side, or use “Hybrid.”
Dynamic: Anchors to the extreme of a lookback window, padded by recent ATR, so buffers expand in volatile periods and contract when calm.
Fibonacci: Uses the 0.618/0.786 retracement pair inside the current swing window to target common reaction zones.
Volatility: Uses a moving-average basis with standard-deviation bands to capture statistically stretched moves.
Volume-Weighted: Centers off VWAP and penalizes deviations using dispersion of price around VWAP, helpful on intraday instruments.
Hybrid: A weighted average of the above to smooth out single-method biases.
When a touch becomes a signal
Depth/extension test:
Dips must penetrate their support by at least Min Dip Depth % .
Tops must extend above resistance by at least Min Top Rise % .
Quality Score gate: The composite must clear Min Quality Score . Components:
Trend alignment: Favor dips in bullish regimes and tops in bearish regimes using EMAs and RSI.
Volume confirmation: Reward expansion or spikes versus a 20-period baseline.
RSI context: Prefer oversold for dips, overbought for tops.
Momentum shift: Look for short-term momentum turning in the expected direction.
Candle structure: Reward hammer/shooting-star style responses at the level.
How to use it
Pick your regime:
Range/chop, small caps, mean-revert intraday → Volatility or Volume Weighted .
Cleaner swings/trends → Dynamic or Fibonacci .
Unsure or mixed conditions → Hybrid .
Set windows: Start with Lookback = 50 for both sides. Increase in higher timeframes or slow assets, decrease for fast scalps.
Tune sensitivity: Raise Dip/Top Sensitivity to widen buffers and reduce noise. Lower to be more aggressive.
Gate with quality: Begin with Min Quality Score = 60 . Push to 70–80 for cleaner swing entries, relax to 50–60 for scalps.
Act on first prints: The script only fires on new qualified events. Use the score label to prioritize A-setups.
Typical workflows
Intraday futures/crypto: Volume-Weighted or Volatility methods for both sides, higher Sensitivity , require Volume Filter and Momentum Filter on. Look for DIP during opening drive exhaustion and TOP near late-session fatigue.
Swing equities/FX: Dynamic or Fibonacci with moderate sensitivity. Keep Trend Filter on to only take dips above the 200-EMA and tops below it.
Countertrend scouts: Lower Min Dip Depth % / Min Top Rise % slightly, but raise Min Quality Score to compensate.
Reading the chart
Lines: “Dip Support” and “Top Resistance” are the current actionable rails, lightly smoothed to reduce flicker.
Signals: “DIP” prints below bars when a qualified dip appears, “TOP” prints above for qualified tops.
Scores: Optional labels show the composite at signal time. Favor higher numbers, especially when aligned with higher-timeframe trend.
Background hints: Light highlights mark raw touches meeting depth/extension, even if they fail quality. Treat these as early warnings.
Tuning tips
If you get too many false DIP signals in downtrends, raise Min Dip Depth % and keep Trend Filter on.
If tops appear late in squeezes, lower Top Sensitivity slightly or switch top side to Fibonacci .
On assets with erratic volume, prefer Volatility or Dynamic methods and down-weight the Volume Filter .
For strict systems, increase Min Quality Score and require both Volume and Momentum filters.
What this is not
It is not a blind reversal signal. It’s a structured context tool. Combine with your risk plan and higher-timeframe map.
It is not a guarantee of mean reversion. In strong trends, expect fewer, higher-score opportunities and respect invalidation quickly.
Suggested presets
Scalp preset: Lookback 30–40, Sensitivity 1.2–1.5, Quality ≥ 55, Volume & Momentum filters ON.
Swing preset: Lookback 75–100, Sensitivity 1.0–1.2, Quality ≥ 70, Trend & Volume filters ON.
Chop preset: Volatility/Volume-Weighted methods, Quality ≥ 60, Momentum filter ON, RSI emphasis.
Input quick reference
Dip/Top Method: Choose the model for each side or “Hybrid” to blend.
Lookback: Swing window the levels are built from.
Sensitivity: Scales volatility padding around levels.
Min Dip Depth % / Min Top Rise %: Minimum breach/extension to qualify.
Quality Filters: Trend, Volume, Momentum toggles, plus Min Quality Score gate.
Visuals: Colors and whether to print score labels.
Best practices
Map higher-timeframe trend first, then act on lower-timeframe DIP/TOP in the trend’s favor.
Use the score as triage. Skip mediocre prints into news or at session open unless score is exceptional.
Pre-define stop placement relative to the level you used. If a DIP fails, exit on loss of structure rather than waiting for the next print.
Bottom line: Top Finder & Dip Hunter codifies where reversals are most defensible and only flags the ones with supportive context. Tune the method and filters to your market, then let the score keep your playbook disciplined.
Target Trend + Filter Toggles Strategy [ChadAnt]The strategy aims to enter a trade when the price crosses over/under a dynamic trend band and when a combination of user-selected filters confirms the move.
1. Trend Bands (Entry)
The core trend is defined by two smoothed moving averages (SMA based on length input) offset by a smoothed Average True Range (ATR) value.
Upper Band (sma_high): ta.sma(high, length) + atr_value
Lower Band (sma_low): ta.sma(low, length) - atr_value
atr_value is ta.sma(ta.atr(atrLength), smaLength) * atrMultiplier.
Trend Determination:
Long Trend (trend = true): Price crossovers the sma_high band.
Short Trend (trend = false): Price crossesunder the sma_low band.
Raw Signal: A trade signal (signal_up_raw / signal_down_raw) is triggered only when the trend state changes.
2. Stop Loss and Take Profit
Stop Loss (SL):
For a Long entry, the original stop price is the Lower Band (sma_low) at the time of the cross.
For a Short entry, the original stop price is the Upper Band (sma_high) at the time of the cross.
The Stop Loss Price is calculated using the distance from the entry price to the original stop, adjusted by the slAdjustment multiplier.
Take Profit (TP):
Calculated based on a Risk/Reward (R:R) ratio, which is rr_increment * tp_target_number.
TP Distance = Adjusted Stop Distance * R:R Ratio.
The strategy enters and exits in a single order pair using strategy.entry and strategy.exit, using the calculated stop_loss_price and take_profit_price.
3. Filters and Confirmation
The strategy includes toggles (use_..._filter) for many popular indicators: MACD, Volume, StochRSI, Awesome Oscillator (AO), and Moving Average/VWAP (Trend/Counter-Trend).
Filter Logic: Each filter checks for its specific confirmation condition (e.g., MACD zero-cross, AO color change, StochRSI out of extreme, Volume > SMA, Price above MA).
Lookback Period: The script uses a for loop (i = 0 to filter_lookback) to check if the required confirmation happened within the last filter_lookback bars.
Final Signal: The actual entry signal (signal_up / signal_down) is triggered only if the Raw Trend Change Signal occurs AND all currently active (toggled on) filters had their required confirmation event within the lookback period AND the trade is within the Time Window.
The draw_targets method is responsible for the powerful visual display on the chart:
When a new filtered signal occurs, it clears any old lines/labels and draws the new:
Entry line
Stop Loss line
Multiple Take Profit lines (up to num_targets), with the strategy's active TP level highlighted (🎯).
It also features logic to dynamically change the label/line of a TP level to a "✔" or the SL level to a "✖" if the price touches that level on subsequent bars.
The strategy is a highly flexible, multi-factor system built on the concept of trend reversal confirmation.
Aroon with RSI Confirmation (92.86%)This script is an analytical tool designed to identify moments in market behavior when price momentum is shifting. It does this by combining two concepts: **Aroon Levels** (to measure trend maturity) and **RSI Slope Behavior** (to measure short-term momentum pressure).
**Functional Concept (Professional Description)**
The indicator examines when either the *Aroon Up* or *Aroon Down* value reaches approximately **92.86%**, which statistically represents a phase where price has recently made an extreme high or low relative to the selected period. This level suggests the trend is nearing a point of *decision*—either continuation or exhaustion.
At the same time, the script analyzes the **relationship between the RSI and its smoothed average**. The difference between the two reflects whether momentum is accelerating in the current direction or slowing. A small difference indicates **market stability**, while whether RSI is positioned above or below the smoothed line indicates **who has control**—buyers or sellers.
By requiring both conditions to align, the script filters out random noise and highlights moments where **trend structure and momentum sentiment converge**.
* **Buy Signal:** Occurs when the market has recently formed a significant low (Aroon Down ≈ 92.86) and buyers begin to regain control (RSI crosses above its smoothed value with low volatility).
* **Sell Signal:** Occurs when the market has recently reached a significant high (Aroon Up ≈ 92.86) and sellers begin to dominate (RSI slips below its smoothed value with low volatility).
---
**Psychological Interpretation**
Markets are driven by cycles of **attention**, **emotion**, and **participation**.
This script targets moments when:
1. **Price has made a meaningful extreme** (a recent new high or low).
This is where crowd sentiment is often strongest—either euphoria near highs or pessimism near lows.
2. **Traders are reassessing direction**, shown by momentum flattening (small RSI difference).
This reveals that participants are hesitating, watching, and waiting.
The market is effectively *thinking*.
3. **Control shifts subtly**, when RSI moves relative to its smoothed trend.
This indicates that early, informed participation is beginning to form—before the broader crowd reacts.
In psychological terms, the script highlights the **transitional turning points** where:
* Fear begins to weaken and confidence returns (buy setup), or
* Confidence begins to crumble and caution emerges (sell setup).
These are the earliest moments when market sentiment **changes hands**, often preceding visible trend reversals. The indicator is not reacting to outcomes—it is observing the underlying shift in **decision-making pressure** among market participants.
---
In essence, this tool identifies **behavioral inflection points**—where the market transitions from one emotional state to the next—providing traders with signals grounded in both structural trend positioning and real-time crowd momentum behavior.
Enhanced Auto Levels & TrendlinesOverview
The Enhanced Auto Levels & Trendlines (EAL&T) is a powerful, all-in-one indicator designed to automate the detection and visualization of key market structures. It combines auto-drawn trendlines, support/resistance levels with volume-based shadows and labels, and auto-flipping Fibonacci retracements/extensions. This tool helps traders identify potential reversals, breakouts, and targets without manual drawing.
Built on Pine Script v5, it uses pivot-based calculations for accuracy and includes customizable options for repainting, extensions, and sources. It's ideal for swing traders, scalpers, and analysts who want clean, dynamic charts.
Key Features
Auto Trendlines: Detects bullish/bearish trends based on pivots, with breakout detection and optional extensions/targets.
Auto Levels: Draws horizontal S/R levels from recent pivots, with "wick shadows" (boxes) highlighting volume strength and % buy/sell labels for sentiment.
Fibonacci Levels: Auto-flips between latest pivot high/low, showing retracements (0.236–0.786) and extensions (1.272–3.0) with customizable styles.
Customization: Override price sources, adjust lengths, colors, styles, and more. Supports repainting for real-time accuracy.
Performance: Limited to 500 bars back and 500 lines for efficiency; no heavy computations.
Visual Aids: Transparent shadows, extendable lines, and small labels for uncluttered charts.
How to Use
Step-by-Step Guide
Add to Chart: Load the indicator. Start with defaults.
Interpret Visuals:
Trendlines: Green (bullish/up), Red (bearish/down). Watch for breakouts – line "breaks" and extends if enabled.
Levels: Horizontal lines with shadows (boxes) showing wick strength. Green above price (resistance), Red below (support). Labels show % buy/sell sentiment.
Fibs: From latest swing low (0.0) to high (1.0). Use 0.5/0.618 for retracements; 1.272+ for targets. Flips automatically on trend change.
Customize for Your Strategy:
Volatile Markets (e.g., Crypto): Increase tl_length to 20+ for fewer false trends. Enable repainting for real-time.
Ranging Markets (e.g., Forex): Set override_source=true, custom_source=close for wick-ignoring pivots.
Fib Focus: Increase fib_extension_bars for longer projections. Hide trendlines if cluttered.
Levels Tuning: Shorten pivot lengths (e.g., 20) for intraday; lengthen (100+) for swings. Set shadow transparency to 100 to hide boxes.
Trading Ideas:
Breakout Trade: Buy on bull trendline break + Fib 0.618 confirmation.
Reversal: Sell at resistance level with high sell% label.
Targets: Use Fib extensions or trend targets for TP; levels for SL.
Combine: Overlay with MA crossover or volume for signals.
Tips & Troubleshooting:
Clutter? Toggle sections off or increase lengths.
No Lines? Ensure show_* is true; check chart history (needs 2x pivot length bars).
Repainting: Normal for real-time; disable for backtesting.
Custom Source: Test on demo – e.g., hl2 for median prices.
Updates: If lines don't extend, verify extend_bars > 0.
Credit : Auto Trendline Lib by HoanGhetti/SimpleTrendlines
Neeson ATR ProOverview
Neeson ATR Pro is an advanced technical analysis indicator that combines multiple technical tools to provide comprehensive market analysis. This indicator is primarily used to identify trend directions, determine entry and exit points, and manage risks through dynamic stop loss.
Key Features
ATR Trailing Stop System
Dynamic stop loss line based on Average True Range (ATR)
Automatically adjusts stop position according to price volatility
Stop line color changes with market conditions (Long-Orange, Short-Blue, Neutral-White)
VWMA Volume Weighted Moving Average
Moving average incorporating volume information
Works in conjunction with ATR line for more accurate signals
Dual Moving Average Filter System
SMA(20) and EMA(50) dual filtering
Color-changing moving averages that change color on crossover
Provides additional trend confirmation signals
Intelligent Signal Generation
Automatically identifies buy and sell signals
Combines multiple indicator conditions to reduce false signals
Clear visual markers (Buy-green label below, Sell-red label above)
Customizable Label System
Real-time display of indicator values
Adjustable label position and size
Customizable label colors
Alert System
Automatic alerts for buy and sell signals
Suitable for automated trading systems
Usage Instructions
Basic Settings
ATR Period: Default 21, adjustable based on market volatility
ATR Multiplier: Default 6.3, controls stop loss range
Smooth Period: Default 100, controls VWMA smoothness
Signal Interpretation
Buy Signal: Price crosses above ATR stop line and meets moving average filter conditions
Sell Signal: Price crosses below ATR stop line and meets moving average filter conditions
Trend Confirmation: Observe consistency between ATR line and candlestick colors
Risk Management
Use ATR stop line as dynamic stop loss level
Confirm trend direction with moving averages
Recommended to use with other indicators for multiple confirmations
风险提示 / Risk Warning
本指标仅供学习交流使用,不构成任何投资建议。金融市场存在高风险,投资者应自行承担交易风险。
This indicator is for educational and communication purposes only and does not constitute any investment advice. Financial markets involve high risks, and investors should bear their own trading risks.
版权信息 / Copyright
X Account: @neeson1987
Copyright © 2024 Neeson ATR Pro. All rights reserved.
Pulse RSI | Lyro RSPulse RSI | Lyro RS
The Pulse RSI is a momentum oscillator that enhances the traditional RSI by incorporating volume-weighted price and linear regression. It generates multiple trading signals, including trend shifts, overbought/oversold conditions, and custom threshold levels.
By integrating both price and volume into its calculation, Pulse RSI is more robust and responsive than the standard RSI. This helps you identify trends faster, spot potential reversals sooner, and set up custom alerts based on your own strategy.
Key Features
Four Signal Types:
Type 1 (Trend): Triggers when the indicator's current value crosses its previous value, highlighting short-term momentum shifts.
Type 2 (Midline Trend): The classic midline cross. A bullish bias is indicated above 50, while a bearish bias is indicated below 50.
Type 3 (Overbought/Oversold): Flags potential reversal zones, suggesting where buying or selling opportunities may emerge.
Type 4 (Custom Thresholds): This type lets you define your own threshold levels. Instead of following a trend, use it to mark your specific conditions for a reversal. For example, set a long reversal at a low level (e.g., 5) for an early buy signal, or a short reversal at a high level (e.g., 80) for an early sell signal.
Calculation Method:
The indicator uses a volume-weighted price (Close * High * Low) and applies linear regression to smooth the data. This creates a unique and more stable oscillator, avoiding the chaotic movement seen in others.
Color System:
Choose from multiple color themes like Classic, Mystic, Accented, and Royal, or create your own custom colors for bullish and bearish signals.
Visual Plotting:
Features a clear plot with a glow effect, a midline, adjustable threshold lines, and shapes/labels to mark long/short and overbought/oversold signals.
Alerts:
Instant alerts are available for every signal type, which you can quickly enable based on your trading conditions.
How It Works:
Core Calculation
The indicator calculates a volume-weighted price using (Close * High * Low) multiplied by the absolute volume. This value is then smoothed with linear regression and converted into an oscillator, normalized to a 0-100 scale.
Trading Logic:
Bullish Signals: Trigger when the main plot line crosses above a key level—be it the previous value, the 50 midline, or a custom threshold.
Bearish Signals: Trigger when the main plot line crosses below a key level.
Visual Logic:
The system displays a main plot line, colors candles, and plots signal shapes, all customizable through a variety of color schemes.
Practical Use
Trend Confirmation (Types 1 & 2): Use Type 1 for early momentum shifts and Type 2 to confirm the overall trend direction.
Reversals (Type 3): Consider long entries when oversold signals fire, suggesting an asset is undervalued. Look for exits at overbought signals, which suggest a potential downward reversal.
Custom Thresholds (Type 4): Set tight thresholds to catch early trends and reversals. Be aware that more sensitive settings may also increase false positives.
Customization:
Adjust the Length: A higher setting makes the indicator more suited for long-term trends, while a lower setting makes it more sensitive for short-term moves.
Enable/Disable Signals: Turn the four signal types on or off to match your trading style.
Set Your Levels: Fully adjustable thresholds for Type 4 long/short conditions.
Choose Your Colors: Select from a variety of color schemes for all bullish and bearish elements.
⚠️ Disclaimer
This indicator is a tool for technical analysis and does not guarantee results. It should be used alongside other analysis methods and solid risk management practices. The creators are not responsible for any financial decisions made based on its signals.
iFVG CE Break with alertHere’s a clear, user-friendly rundown of what the indicator does and how to tune it.
What it does
- Detects Fair Value Gaps (FVGs) in both directions:
- UP FVG (bearish imbalance) and DOWN FVG (bullish imbalance).
- Draws the CE (Consequence/Equilibrium) line for each FVG (default yellow, dotted).
- Entry arrows (iFVG): plots an arrow when the candle body breaks & closes across a stored CE, both up and down.
- Keeps a history of past CEs (per side) and will still signal even if the original FVG has been mitigated/filled
Signals & logic
- Body break rules:
- Up arrow: open <= CE and close > CE.
- Down arrow: open >= CE and close < CE.
- Multiple triggers per CE: each CE can fire up to 3 times (configurable).
- One arrow per bar per direction: if several CEs are crossed the same bar, you still get a single up and/or down arrow on that bar (cleaner chart).
- History window: checks the last N CEs per side (default 1 for early entry, range 1–10)
Range Trading StrategyOVERVIEW
The Range Trading Strategy is a systematic trading approach that identifies price ranges
from higher timeframe candles or trading sessions, tracks pivot points, and generates
trading signals when range extremes are mitigated and confirmed by pivot levels.
CORE CONCEPT
The strategy is based on the principle that when a candle (or session) closes within the
range of the previous candle (or session), that previous candle becomes a "range" with
identifiable high and low extremes. When price breaks through these extremes, it creates
trading opportunities that are confirmed by pivot levels.
RANGE DETECTION MODES
1. HTF (Higher Timeframe) Mode:
Automatically selects a higher timeframe based on the current chart timeframe
Uses request.security() to fetch HTF candle data
Range is created when an HTF candle closes within the previous HTF candle's range
The previous HTF candle's high and low become the range extremes
2. Sessions Mode:
- Divides the trading day into 4 sessions (UTC):
* Session 1: 00:00 - 06:00 (6 hours)
* Session 2: 06:00 - 12:00 (6 hours)
* Session 3: 12:00 - 20:00 (8 hours)
* Session 4: 20:00 - 00:00 (4 hours, spans midnight)
- Tracks high, low, and close for each session
- Range is created when a session closes within the previous session's range
- The previous session's high and low become the range extremes
PIVOT DETECTION
Pivots are detected based on candle color changes (bullish/bearish transitions):
1. Pivot Low:
Created when a bullish candle appears after a bearish candle
Pivot low = minimum of the current candle's low and previous candle's low
The pivot bar is the actual bar where the low was formed (current or previous bar)
2. Pivot High:
Created when a bearish candle appears after a bullish candle
Pivot high = maximum of the current candle's high and previous candle's high
The pivot bar is the actual bar where the high was formed (current or previous bar)
IMPORTANT: There is always only ONE active pivot high and ONE active pivot low at any
given time. When a new pivot is created, it replaces the previous one.
RANGE CREATION
A range is created when:
(HTF Mode) An HTF candle closes within the previous HTF candle's range AND a new HTF
candle has just started
(Sessions Mode) A session closes within the previous session's range AND a new session
has just started
Or Range Can Be Created when the Extreme of Another Range Gets Mitigated and We Have a Pivot low Just Above the Range Low or Pivot High just Below the Range High
Range Properties:
rangeHigh: The high extreme of the range
rangeLow: The low extreme of the range
highStartTime: The timestamp when the range high was actually formed (found by looping
backwards through bars)
lowStartTime: The timestamp when the range low was actually formed (found by looping
backwards through bars)
highMitigated / lowMitigated: Flags tracking whether each extreme has been broken
isSpecial: Flag indicating if this is a "special range" (see Special Ranges section)
RANGE MITIGATION
A range extreme is considered "mitigated" when price interacts with it:
High is mitigated when: high >= rangeHigh (any interaction at or above the level)
Low is mitigated when: low <= rangeLow (any interaction at or below the level)
Mitigation can happen:
At the moment of range creation (if price is already beyond the extreme)
At any point after range creation when price touches the extreme
SIGNAL GENERATION
1. Pending Signals:
When a range extreme is mitigated, a pending signal is created:
a) BEARISH Pending Signal:
- Triggered when: rangeHigh is mitigated
- Confirmation Level: Current pivotLow
- Signal is confirmed when: close < pivotLow
- Stop Loss: Current pivotHigh (at time of confirmation)
- Entry: Short position
Signal Confirmation
b) BULLISH Pending Signal:
- Triggered when: rangeLow is mitigated
- Confirmation Level: Current pivotHigh
- Signal is confirmed when: close > pivotHigh
- Stop Loss: Current pivotLow (at time of confirmation)
- Entry: Long position
IMPORTANT: There is only ever ONE pending bearish signal and ONE pending bullish signal
at any given time. When a new pending signal is created, it replaces the previous one
of the same type.
2. Signal Confirmation:
- Bearish: Confirmed when price closes below the pivot low (confirmation level)
- Bullish: Confirmed when price closes above the pivot high (confirmation level)
- Upon confirmation, a trade is entered immediately
- The confirmation line is drawn from the pivot bar to the confirmation bar
TRADE EXECUTION
When a signal is confirmed:
1. Position Management:
- Any existing position in the opposite direction is closed first
- Then the new position is entered
2. Stop Loss:
- Bearish (Short): Stop at pivotHigh
- Bullish (Long): Stop at pivotLow
3. Take Profit:
- Calculated using Risk:Reward Ratio (default 2:1)
- Risk = Distance from entry to stop loss
- Target = Entry ± (Risk × R:R Ratio)
- Can be disabled with "Stop Loss Only" toggle
4. Trade Comments:
- "Range Bear" for short trades
- "Range Bull" for long trades
SPECIAL RANGES
Special ranges are created when:
- A range high is mitigated AND the current pivotHigh is below the range high
- A range low is mitigated AND the current pivotLow is above the range low
In these cases:
- The pivot value is stored in an array (storedPivotHighs or storedPivotLows)
- A "special range" is created with only ONE extreme:
* If pivotHigh < rangeHigh: Creates a range with rangeHigh = pivotLow, rangeLow = na
* If pivotLow > rangeLow: Creates a range with rangeLow = pivotHigh, rangeHigh = na
- Special ranges can generate signals just like normal ranges
- If a special range is mitigated on the creation bar or the next bar, it is removed
entirely without generating signals (prevents false signals)
Special Ranges
REVERSE ON STOP LOSS
When enabled, if a stop loss is hit, the strategy automatically opens a trade in the
opposite direction:
1. Long Stop Loss Hit:
- Detects when: position_size > 0 AND position_size <= 0 AND low <= longStopLoss
- Action: Opens a SHORT position
- Stop Loss: Current pivotHigh
- Trade Comment: "Reverse on Stop"
2. Short Stop Loss Hit:
- Detects when: position_size < 0 AND position_size >= 0 AND high >= shortStopLoss
- Action: Opens a LONG position
- Stop Loss: Current pivotLow
- Trade Comment: "Reverse on Stop"
The reverse trade uses the same R:R ratio and respects the "Stop Loss Only" setting.
VISUAL ELEMENTS
1. Range Lines:
- Drawn from the time when the extreme was formed to the mitigation point (or current
time if not mitigated)
- High lines: Blue (or mitigated color if mitigated)
- Low lines: Red (or mitigated color if mitigated)
- Style: SOLID
- Width: 1
2. Confirmation Lines:
- Drawn when a signal is confirmed
- Extends from the pivot bar to the confirmation bar
- Bearish: Red, solid line
- Bullish: Green, solid line
- Width: 1
- Can be toggled on/off
STRATEGY SETTINGS
1. Range Detection Mode:
- HTF: Uses higher timeframe candles
- Sessions: Uses trading session boundaries
2. Auto HTF:
- Automatically selects HTF based on current chart timeframe
- Can be disabled to use manual HTF selection
3. Risk:Reward Ratio:
- Default: 2.0 (2:1)
- Minimum: 0.5
- Step: 0.5
4. Stop Loss Only:
- When enabled: Trades only have stop loss (no take profit)
- Trades close on stop loss or when opposite signal confirms
5. Reverse on Stop Loss:
- When enabled: Hitting a stop loss opens opposite trade with stop at opposing pivot
6. Max Ranges to Display:
- Limits the number of ranges kept in memory
- Oldest ranges are purged when limit is exceeded
KEY FEATURES
1. Dynamic Pivot Tracking:
- Pivots update on every candle color change
- Always maintains one high and one low pivot
2. Range Lifecycle:
- Ranges are created when price closes within previous range
- Ranges are tracked until mitigated
- Mitigation creates pending signals
- Signals are confirmed by pivot levels
3. Signal Priority:
- Only one pending signal of each type at a time
- New signals replace old ones
- Confirmation happens on close of bar
4. Position Management:
- Closes opposite positions before entering new trades
- Tracks stop loss levels for reverse functionality
- Respects pyramiding = 1 (only one position per direction)
5. Time-Based Drawing:
- Uses time coordinates instead of bar indices for line drawing
- Prevents "too far from current bar" errors
- Lines can extend to any historical point
USAGE NOTES
- Best suited for trending and ranging markets
- Works on any timeframe, but HTF mode adapts automatically
- Sessions mode is ideal for intraday trading
- Pivot detection requires clear candle color changes
- Range detection requires price to close within previous range
- Signals are generated on bar close, not intra-bar
The strategy combines range identification, pivot tracking, and signal confirmation to
create a systematic approach to trading breakouts and reversals based on price structure, past performance does not in any way predict future performance
RSI + MACD Multi-Timeframe StrategyThis strategy combines the Relative Strength Index (RSI) from the daily timeframe with the Moving Average Convergence Divergence (MACD) from the 4-hour timeframe to generate precise long entry and exit signals.
The system uses a multi-timeframe approach to align longer-term trend conditions with shorter-term momentum shifts — allowing traders to catch dips with confirmation and exit before reversals.
🧠 Strategy Logic
✅ Long Entry Condition:
- RSI on the daily (1D) timeframe is oversold (below your defined threshold)
- MACD on the 4H timeframe crosses above the signal line
→ A long trade is opened when these two align
✅ Long Exit Condition:
- RSI on the daily timeframe is overbought
- MACD on the 4H timeframe crosses below the signal line
→ The long trade is closed when these two conditions are met
💡 This strategy currently supports long entries only. Short logic can be added if needed.
📊 Indicator Components
🔹 RSI (Relative Strength Index):
- A momentum oscillator that measures the speed and magnitude of price changes.
- Helps identify overbought (potential sell) and oversold (potential buy) conditions.
- Applied on the 1D timeframe (by default) to reflect broader market trend or exhaustion levels.
🔹 MACD (Moving Average Convergence Divergence):
- A trend-following momentum indicator based on moving averages.
- The MACD Line (fast EMA - slow EMA) crossing above the Signal Line indicates bullish momentum.
- Used here on the 4-hour timeframe (by default) for shorter-term momentum confirmation.
🔹 Multi-Timeframe (MTF) Logic:
- Uses request.security() to pull higher timeframe data (1D for RSI, 4H for MACD).
- Ensures no repainting, as it only uses closed candles from the higher timeframe.
- Aligns longer-term signals with shorter-term entries, reducing false signals.
📈 Plotting Options
The script includes a plot selector input allowing you to toggle between:
- RSI Plot (with overbought/oversold lines)
- MACD Plot (MACD line and signal line)
- This helps visualize signal conditions clearly on your chart.
🛠 Customization
- RSI & MACD settings are fully configurable
- RSI and MACD timeframes can be adjusted independently
⚠️ Disclaimer
This strategy is provided for educational and informational purposes only.
It is not financial advice or a recommendation to buy or sell any asset.
Past performance does not guarantee future results. Always test strategies in a simulated environment before live use, and consult with a licensed financial advisor for investment decisions.
Close-Only Market StructureDYOR NFA
Function of the Close-Only Market Structure Script
The script is a custom indicator designed to display the market's structural trend based only on closing prices, ignoring price wicks (highs and lows) to focus on conviction.
pivotLengthInt Input: This user setting controls the sensitivity of the structure detection. It determines how many bars to look left and right to define a swing point (e.g., a setting of 5 means a bar's close must be the highest/lowest of the 5 preceding and 5 succeeding bars).
Swing Point Identification (SH/SL): It uses the ta.pivothigh() and ta.pivotlow() functions on the close price series to define Swing Highs (SH) and Swing Lows (SL).
Structure Tracking (structureType): It compares the most recent confirmed SH and SL against the immediately preceding ones (prevSH and prevSL) to classify the trend as one of the following four states:
HH (Higher High, Higher Low): Strong Uptrend
LL (Lower High, Lower Low): Strong Downtrend
HL/LH: Complex structure, consolidation, or reversal zones.
Structure Lines: It plots two continuous stepped lines (lastSH and lastSL) that hold the price of the most recent confirmed swing points, visually defining the current structure boundaries.
BOS Detection (Break of Structure): It identifies and plots a marker (BOS) when the current bar's close definitively breaks (closes above) the lastSH or closes below the lastSL, signaling a continuation of the trend or a major structural change.
Visual Confirmation:
Plots small SH/SL labels at the confirmed swing points.
Plots small HH/HL/LH/LL labels at the swing points to show the confirmed structural state.
Applies a light background color (green for bullish/ranging-up, red for bearish/ranging-down) for an at-a-glance view of the bias.
Alerts: It provides conditions for setting up notifications when a Bullish BOS or Bearish BOS occurs.
🚀 How to Use the Script
Open TradingView: Go to the chart where you want to apply the indicator.
Open Pine Editor: Click the Pine Editor tab at the bottom of the screen.
Paste and Save:
Copy the final, corrected Pine Script code.
Delete any existing code in the editor and paste the new code.
Click the Save button (or name the script) and then click Add to Chart.
Adjust Settings:
On the chart, hover over the indicator name ("Close-MS v6") and click the Gear Icon (Settings).
Pivot Lookback (L&R): Change this value to adjust sensitivity:
Smaller number (e.g., 3): More swings detected, structure changes faster, more noise.
Larger number (e.g., 10): Fewer swings detected, structure is more significant, less noise (recommended for higher timeframes).
Interpret the Chart:
The Red Stepped Line shows your current resistance (SH).
The Green Stepped Line shows your current support (SL).
Green Background: General bullish bias (making Higher Highs/Lows).
Red Background: General bearish bias (making Lower Highs/Lows).
BOS Triangle: Signals that the price has closed and validated a break of the previous structural high or low.
Set Alerts (Optional):
Click the Alert button (bell icon) on the TradingView toolbar.
Set the Condition to the indicator ("Close-MS v6").
Select the specific Alert Condition you want to monitor (e.g., "Bullish BOS" or "Bearish BOS").
TopBot [CHE] TopBot — Structure pivots with buffered acceptance and gradient trend visualization
Summary
TopBot detects swing structure from confirmed pivot highs and lows, derives support and resistance levels, and switches trend only after a buffered and accepted break. It renders labels for recent structure points, maintains dynamic support and resistance lines that freeze on contact, and colors candles using a gradient that reflects consecutive trend persistence. The gradient communicates strength without extra panels, while the buffered acceptance reduces fragile flips around key levels. Everything runs in the main chart for immediate context.
Motivation: Why this design?
Classical swing tools often flip on single-bar spikes and produce lines that extend forever without acknowledging when price invalidates them. This script addresses that by requiring a user-controlled buffer and a run of consecutive closes before changing trend, while also freezing lines once price interacts with them. The gradient color layer communicates regime persistence so users can quickly judge whether a move is maturing or just starting.
What’s different vs. standard approaches?
Baseline reference: Simple pivot labeling and unbuffered break-of-structure tools.
Architecture differences:
Buffered level testing using ticks, percent, or ATR.
Acceptance logic that requires multiple consecutive closes.
Synchronized structure labeling with a single Top and Bottom within the active set.
Progressive support and resistance management that freezes lines on first contact.
Gradient candle and wick coloring driven by consecutive trend counts with windowed normalization and gamma control.
Practical effect: Fewer whipsaw flips, clearer status of active levels, and visual feedback about trend persistence without a secondary pane.
How it works (technical)
The script confirms swing points using left and right bar pivots, then forms a current structure window to classify each pivot as higher high, lower high, higher low, or lower low. Recent labels are trimmed to a user cap, and a postprocess step ensures one highest and one lowest label while preserving side information for the others. Support updates on higher low events, resistance on lower high events. Trend flips only after the close has moved beyond the active level by a chosen buffer and this condition holds for a chosen number of consecutive bars. Lines for new levels extend to the right and freeze once price touches them. A running count of consecutive trend bars produces a strength score, which is normalized over a rolling window, shaped by gamma, and mapped to user-defined dark and neon colors for both up and down regimes. Wick coloring uses `plotcandle`; fallback bar coloring uses `barcolor`. No higher-timeframe data is requested. Signals confirm only after the right-bar lookback of the pivot function.
Parameter Guide
Left Bars / Right Bars (default five each): Pivot sensitivity. Larger values confirm later and reduce noise; smaller values respond faster with more noise.
Draw S/R Lines (default true): Enables support and resistance line creation and updates.
Support / Resistance Colors (lime, red): Line colors for each side.
Line Style (Solid, Dashed, Dotted; default Dotted) and Width (default three): Visual style of S/R lines.
Max Labels & Lines (default ten): Cap for objects to control clutter and resource usage.
Change Bar Color (default true), Up/Down colors (blue, black): Fallback bar coloring when gradients or wick coloring are disabled.
Show Neutral Candles (default false): Optional coloring when no trend is active.
Enable Gradient Bar Colors (default true): Turns on gradient body coloring from the strength score.
Enable Wick Coloring (default true): Colors wicks and borders using `plotcandle`.
Collection Period (default one hundred): Rolling window used to scale the strength score. Shorter windows react faster but vary more.
Gamma Bars / Gamma Plots (defaults zero point seven and zero point eight): Shapes perceived contrast of bar and wick gradients. Lower values brighten early; higher values compress until stronger runs appear.
Gradient Transparency / Wick Transparency (default zero): Visual transparency for bodies and wicks.
Up/Down Trend Dark and Neon Colors: Endpoints for gradient mapping in each regime.
Acceptance closes (n) (default two): Number of consecutive closes beyond a level required before trend flips. Larger values reduce false breaks but react later.
Break buffer (None, Ticks, Percent, ATR; default ATR) and Value (default zero point five) and ATR Len (default fourteen): Defines the safety margin beyond the level. ATR mode adapts to volatility; Percent and Ticks are static.
Reading & Interpretation
Labels: “Top” and “Bottom” mark the most extreme points in the active set; “LT” and “HB” indicate side labels for lower top and higher bottom.
Lines: New support or resistance is drawn when structure confirms. A line freezes once price touches it, signaling that the dynamic phase ended.
Trend: Internal state switches to up or down only after buffered acceptance.
Colors: Brighter neon tones indicate stronger and more persistent runs; darker tones suggest early or weakening runs. When gradients are off, fallback bar colors indicate trend sign.
Practical Workflows & Combinations
Trend following: Wait for a buffered and accepted break through the most recent level, then use gradient intensity to stage entries or scale-ins.
Structure-first filtering: Trade only in the direction of the last accepted trend while price remains above support or below resistance.
Exits and stops: Consider exiting on loss of gradient intensity combined with a return through the most recent structure level.
Multi-asset / Multi-timeframe: Works on liquid symbols across common timeframes. Use larger pivot bars and higher acceptance on lower timeframes. No built-in higher-timeframe aggregation is used.
Behavior, Constraints & Performance
Repaint/confirmation: Pivot confirmation waits for the right bar window; trend acceptance is based on closes and can change during a live bar. Final signals stabilize on bar close.
security/HTF: Not used. No cross-timeframe data.
Resources: Arrays and loops are used for labels, lines, and structure search up to a capped historical span. Object counts are clamped by user input and platform limits.
Known limits: Delayed confirmation at sharp turns due to pivot windows; rapid gaps can jump over buffers; gradient scaling depends on the chosen collection period.
Sensible Defaults & Quick Tuning
Start with the defaults: pivot windows at five, ATR buffer with value near one half, acceptance at two, collection period near one hundred, gamma near zero point seven to zero point eight.
Too many flips: increase acceptance, increase buffer value, or increase pivot windows.
Too sluggish: reduce acceptance, reduce buffer value, or reduce pivot windows.
Colors too flat: lower gamma or shorten the collection period.
Visual clutter: reduce the max labels and lines cap or disable wicks.
What this indicator is—and isn’t
This is a visualization and signal layer that encodes swing structure, level state, and regime persistence. It is not a complete trading system, not predictive, and does not manage orders. Use it with broader context such as higher timeframe structure, session behavior, and defined risk controls.
Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.
Best regards and happy trading
Chervolino
Acknowledgment
Thanks to LonesomeTheBlue for the fantastic and inspiring "Higher High Lower Low Strategy" .
Original script:
Credit for the original concept and implementation goes to the author; any adaptations or errors here are mine.
MechArt Moving Average and % Above V1.1MechArt Moving Average and % Above V1.1
Unlock the power of custom analysis with this Adjustable Moving Average Indicator! Whether you're a day trader, swing trader, or long-term investor, this tool helps you track price action with precision and flexibility. Tailor your trading strategy to your needs by adjusting the type of moving average, price triggers, and percentage levels.
🔑 Key Features:
Choose Your Moving Average Type 🌀
Select from four popular moving averages:
SMA (Simple Moving Average)
EMA (Exponential Moving Average)
WMA (Weighted Moving Average)
VWMA (Volume Weighted Moving Average)
Find the one that best fits your trading style!
Adjustable Trigger Price
Choose between four price types to trigger signals:
Open
High
Low
Close
Pick the price type that makes the most sense for your strategy!
Percentage Above the Moving Average 📈🔽
Set a custom percentage above the moving average to generate alerts when the price reaches key levels.
Customizable Alerts 🔔
Get notified when the price is above the target price or below the moving average. Perfect for timely trades!
📉 Visual Alerts:
🔴 Red Background: When the selected price is above the target price (percentage above the moving average).
🟩 Green Background: When the selected price is below the moving average.
🚀 How This Indicator Helps You:
Precision 🎯: Visual signals with clear red and green backgrounds help you make quick decisions based on the price's relationship to your moving average.
Flexibility 🔄: Customize the type of moving average and the price used for triggers to fit your trading style.
📊 Perfect For:
Swing Traders 📈: Use the indicator to identify price trends and reversals based on moving averages.
Day Traders ⏳: Set short-term percentage levels to catch immediate price movements.
Long-Term Investors 💼: Track longer-term trends and set alerts when prices deviate significantly from your moving average.
Take control of your trading strategy with this Adjustable Moving Average Indicator and start making more informed decisions today! 🏅
Change from V1.0: Fixed Timeframe setting to match chart.
مستويات الاتزان السعري (Equilibrium Price Levels)Equilibrium Price Levels is an educational tool that helps traders quantify “fair value” and key extension zones based on a single reference swing.
The script uses two manual inputs (reference High and Low) to compute a structured set of equilibrium and extension levels, rather than scanning swings automatically. This gives full control over which range the calculations are based on.
Calculated levels include:
• Retracement / equilibrium band from the selected range: 38.2%, 50.0%, 61.8%
• Upside extension targets from the same range: 125%, 1.618, 1.80, 2.50, 3.10, 3.86, 4.236
Features:
• Separate toggles for supports, targets, and reference high/low
• Per-level visibility switches for each extension (e.g., only show 1.618 and 2.50)
• Customizable colors for supports, targets, and reference lines
• Optional labels with configurable size and offset to keep the chart clean
• Multiple line extension modes (left, both sides, or no extension)
Typical use cases:
• Marking an equilibrium zone inside a major swing to watch for reaction or trend continuation
• Building a consistent “price map” of where mean-reversion vs. extension behavior is likely
• Combining with other tools (price action, volume, order blocks, etc.) to refine trade plans
This script is for educational and analytical purposes only and does not constitute financial advice, trade signals, or performance guarantees.
مستويات الاتزان السعري هي أداة تعليمية تساعد المتداول على قياس “السعر العادل” ومناطق التمدد المحتملة اعتمادًا على نطاق سعري واحد يحدده بنفسه.
المؤشر لا يختار القمم والقيعان آليًا، بل يعتمد على إدخال قمّة وقاع مرجعيين يدويًا، مما يعطي تحكمًا كاملًا في النطاق المستخدم في الحسابات.
المؤشر يحسب ما يلي:
• نطاق الاتزان/التراجع من القمة إلى القاع: 38.2%، 50.0%، 61.8%
• أهداف وتمددات سعرية أعلى النطاق: 125%، 1.618، 1.80، 2.50، 3.10، 3.86، 4.236
المزايا:
• مفاتيح تشغيل/إخفاء مستقلة لمستويات الدعم، الأهداف، والقمة/القاع المرجعيين
• إمكانية تفعيل/إلغاء كل هدف بشكل منفصل (مثل إظهار 1.618 و 2.50 فقط)
• تخصيص ألوان خطوط الدعم، الأهداف، وخطوط القمة والقاع
• ملصقات توضيحية اختيارية مع تحكم في حجمها وموقعها على الشارت
• خيارات امتداد للخطوط: لليسار فقط، أو يمين ويسار، أو بدون امتداد
الاستخدامات الشائعة:
• تحديد منطقة الاتزان داخل موجة رئيسية لمراقبة احتمالات الارتداد أو استمرار الاتجاه
• بناء “خريطة سعرية” ثابتة لمناطق التوازن والتمدد على مدى زمني واسع
• دمج المستويات مع أدوات أخرى مثل السلوك السعري أو الحجم أو مناطق التجميع/التصريف لتحسين قرارات الدخول والخروج
هذا السكربت موجه لأغراض تعليمية وتحليلية فقط، ولا يُعتبر نصيحة استثمارية أو توصية بيع/شراء، ولا يضمن أي أداء مستقبلي للأسعار أو النتائج.
RastaRasta — Educational Strategy (Pine v5)
Momentum · Smoothing · Trend Study
Overview
The Rasta Strategy is a visual and educational framework designed to help traders study momentum transitions using the interaction between a fast-reacting EMA line and a slower smoothed reference line.
It is not a signal generator or profit system; it’s a learning tool for understanding how smoothing, crossovers, and filters interact under different market conditions.
The script displays:
A primary EMA line (the fast reactive wave).
A Smoothed line (using your chosen smoothing method).
Optional fog zones between them for quick visual context.
Optional DNA rungs connecting both lines to illustrate volatility compression and expansion.
Optional EMA 8 / EMA 21 trend filter to observe higher-time-frame alignment.
Core Idea
The Rasta model focuses on wave interaction. When the fast EMA crosses above the smoothed line, it reflects a shift in short-term momentum relative to background trend pressure. Cross-unders suggest weakening or reversal.
Rather than treating this as a trading “signal,” use it to observe structure, study trend alignment, and test how smoothing type affects reaction speed.
Smoothing Types Explained
The script lets you experiment with multiple smoothing techniques:
Type Description Use Case
SMA (Simple Moving Average) Arithmetic mean of the last n values. Smooth and steady, but slower. Trend-following studies; filters noise on higher time frames.
EMA (Exponential Moving Average) Weights recent data more. Responds faster to new price action. Momentum or reactive strategies; quick shifts and reversals.
RMA (Relative Moving Average) Used internally by RSI; smooths exponentially but slower than EMA. Momentum confirmation; balanced response.
WMA (Weighted Moving Average) Linear weights emphasizing the most recent data strongly. Intraday scalping; crisp but potentially noisy.
None Disables smoothing; uses the EMA line alone. Raw comparison baseline.
Each smoothing method changes how early or late the strategy reacts:
Faster smoothing (EMA/WMA) = more responsive, good for scalping.
Slower smoothing (SMA/RMA) = more stable, good for trend following.
Modes of Study
🔹 Scalper Mode
Use short EMA lengths (e.g., 3–5) and fast smoothing (EMA or WMA).
Focus on 1 min – 15 min charts.
Watch how quick crossovers appear near local tops/bottoms.
Fog and rung compression reveal volatility contraction before bursts.
Goal: study short-term rhythm and liquidity pulses.
🔹 Momentum Mode
Use moderate EMA (5–9) and RMA smoothing.
Ideal for 1 H–4 H charts.
Observe how the fog color aligns with trend shifts.
EMA 8 / 21 filter can act as macro bias; “Enter” labels will appear only in its direction when enabled.
Goal: study sustained motion between pullbacks and acceleration waves.
🔹 Trend-Follower Mode
Use longer EMA (13–21) with SMA smoothing.
Great for daily/weekly charts.
Focus on periods where fog stays unbroken for long stretches — these illustrate clear trend dominance.
Watch rung spacing: tight clusters often precede consolidations; wide rungs signal expanding volatility.
Goal: visualize slow-motion trend transitions and filter whipsaw conditions.
Components
EMA Line (Red): Fast-reacting short-term direction.
Smoothed Line (Yellow): Reference trend baseline.
Fog Zone: Green when EMA > Smoothed (up-momentum), red when below.
DNA Rungs: Thin connectors showing volatility structure.
EMA 8 / 21 Filter (optional):
When enabled, the strategy will only allow Enter events if EMA 8 > EMA 21.
Use this to study higher-trend gating effects.
Educational Applications
Momentum Visualization: Observe how the fast EMA “breathes” around the smoothed baseline.
Trend Transitions: Compare different smoothing types to see how early or late reversals are detected.
Noise Filtering: Experiment with fog opacity and smoothing lengths to understand trade-off between responsiveness and stability.
Risk Concept Simulation: Includes a simple fixed stop-loss parameter (default 13%) for educational demonstrations of position management in the Strategy Tester.
How to Use
Add to Chart → “Strategy.”
Works on any timeframe and instrument.
Adjust Parameters:
Length: base EMA speed.
Smoothing Type: choose SMA, EMA, RMA, or WMA.
Smoothing Length: controls delay and smoothness.
EMA 8 / 21 Filter: toggles trend gating.
Fog & Rungs: visual study options only.
Study Behavior:
Use Strategy Tester → List of Trades for entry/exit context.
Observe how different smoothing types affect early vs. late “Enter” points.
Compare trend periods vs. ranging periods to evaluate efficiency.
Combine with External Tools:
Overlay RSI, MACD, or Volume for deeper correlation analysis.
Use replay mode to visualize crossovers in live sequence.
Interpreting the Labels
Enter: Marks where fast EMA crosses above the smoothed line (or when filter flips positive).
Exit: Marks where fast EMA crosses back below.
These are purely analytical markers — they do not represent trade advice.
Educational Value
The Rasta framework helps learners explore:
Reaction time differences between moving-average algorithms.
Impact of smoothing on signal clarity.
Interaction of local and global trends.
Visualization of volatility contraction (tight DNA rungs) and expansion (wide fog zones).
It’s a sandbox for studying price structure, not a promise of profit.
Disclaimer
This script is provided for educational and research purposes only.
It does not constitute financial advice, trading signals, or performance guarantees. Past market behavior does not predict future outcomes.
Users are encouraged to experiment responsibly, record observations, and develop their own understanding of price behavior.
Author: Michael Culpepper (mikeyc747)
License: Educational / Open for study and modification with credit.
Philosophy:
“Learning the rhythm of the market is more valuable than chasing its profits.” — Rasta
SuperTrend Dual RMAOverview
The SuperTrend Dual RMA is a hybrid volatility-based trend-following system that merges two Relative Moving Averages (RMAs) with an Average True Range (ATR)–anchored SuperTrend framework. The primary purpose of this indicator is to offer a smoother and more reliable depiction of directional bias while maintaining sensitivity to price volatility and market volume.
Traditional SuperTrend implementations typically rely on a single moving average and a fixed volatility envelope. This dual RMA structure introduces an adaptive central tendency line that reacts proportionally to both price and volume, allowing for more nuanced identification of trend reversals and continuation patterns.
**Core Concept**
The indicator is built around two key principles — smoothing and volatility adaptation.
1. **Smoothing:** The use of two separate RMAs with configurable lengths creates a dynamic equilibrium between short-term responsiveness and long-term stability. The first RMA captures near-term directional shifts, while the second provides broader market context. The average of both becomes the foundation of the SuperTrend bands.
2. **Volatility Adaptation:** The ATR multiplier and period define the distance between upper and lower bands relative to recent volatility. This ensures that the SuperTrend line remains flexible across varying market conditions — expanding during high volatility and contracting during calm phases.
**Calculation Steps**
* The indicator first computes two volume-weighted RMAs based on the typical price (`hlc3`) multiplied by trading volume.
* Each RMA is normalized by the smoothed volume to maintain proportional weighting.
* These two RMAs are averaged to produce a “basis line” that reflects the current market consensus price.
* The ATR is calculated over a user-defined period, then multiplied by a volatility factor (ATR multiplier).
* The resulting ATR value defines dynamic upper and lower thresholds around the basis line.
* Trend direction is determined by price closing behavior relative to these thresholds:
* When the closing price exceeds the upper band, the trend is considered bullish.
* When it drops below the lower band, the trend turns bearish.
* If price remains within the bands, the prior trend direction is maintained for consistency.
**Visual Structure**
The SuperTrend Dual RMA provides multiple layers of visual feedback for enhanced interpretation:
* Two distinct RMA lines (short and long) are plotted with complementary colors for contrast and clarity.
* A soft fill between the RMA lines highlights the interaction between short- and medium-term momentum.
* The ATR-based SuperTrend bands are drawn above and below the basis, with adaptive coloring that corresponds to the prevailing trend direction.
* Bar colors automatically adjust to reflect bullish or bearish bias, making it easy to identify trend shifts without relying solely on crossovers.
* Optional triangle markers appear below or above bars to signal potential buy or sell opportunities based on crossover logic.
**Signals and Alerts**
The indicator provides real-time crossover detection:
* **Buy Signal:** Triggered when the closing price moves above the SuperTrend line, confirming potential bullish continuation or reversal.
* **Sell Signal:** Triggered when the closing price drops below the SuperTrend line, indicating possible bearish momentum or reversal.
Both conditions have built-in `alertcondition()` functions, allowing users to set automated alerts for trading or monitoring purposes. This enables integration with TradingView’s alert system for push notifications, emails, or webhook connections.
**Usage Guidelines**
* **Trend Identification:** Use the color-coded trend line and bar color as a visual guide to the current directional bias.
* **Entry and Exit Timing:** Consider entering trades when a new crossover alert appears, preferably in the direction of the overall higher-timeframe trend.
* **Parameter Tuning:** Adjust the RMA lengths and ATR parameters based on asset volatility. Shorter RMA and ATR settings provide faster reactions, suitable for intraday or high-frequency trading, while longer configurations better fit swing or position strategies.
* **Risk Management:** Because the SuperTrend inherently acts as a dynamic stop level, traders can use the opposite band or SuperTrend line as a trailing stop or exit signal.
**Practical Applications**
* Trend confirmation in multi-timeframe strategies.
* Adaptive trailing stop placement using the lower or upper band.
* Visual comparison of volume-weighted price movement against volatility envelopes.
* Integration into algorithmic trading systems as a signal filter or trend bias component.
* Identification of overextended conditions when price significantly diverges from the SuperTrend basis.
**Originality and Advantages**
The SuperTrend Dual RMA differentiates itself from conventional SuperTrend scripts through three innovative design choices:
1. **Dual Volume-Weighted RMAs:** By incorporating two RMAs weighted by trading volume, the indicator accounts for liquidity dynamics, producing smoother and more reliable averages compared to price-only calculations.
2. **Anchored SuperTrend Framework:** The SuperTrend bands are not derived from a fixed source (such as a single close or median price) but from a blended RMA basis, making them more adaptable to varying market behaviors.
3. **Integrated Multi-Layer Visualization:** The inclusion of filled regions between RMAs, dynamic band coloring, and bar tinting enhances readability and analytical depth without overwhelming the chart.
These improvements collectively create a more balanced and data-rich representation of market structure, offering a higher degree of analytical precision. It’s suitable for traders seeking both discretionary and systematic use, as the indicator’s logic is transparent and compatible with alert-based or automated workflows.
**Summary**
The SuperTrend Dual RMA is a refined evolution of the classic SuperTrend, optimized for traders who value smoother directional tracking and more intelligent volatility adaptation. It blends two time-sensitive, volume-aware moving averages with an ATR-derived volatility system to deliver reliable, actionable trend information. Its visual design, adaptive responsiveness, and integrated alert functionality make it a complete solution for identifying and managing trends across multiple asset classes and timeframes.
Earnings Lines Vertical – All Grey This provides a vertical grey line for prior earnings dates and also for any confirmed (not estimated) future earnings date
ICT Killzones & FVG// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © Mutharasan12
//@version=5
indicator("ICT Killzones & FVG", "ICT Killzones & FVG", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500)
// ---------------------------------------- Constant Functions --------------------------------------------------
get_line_type(_style) =>
result = switch _style
'Solid' => line.style_solid
'Dotted' => line.style_dotted
'Dashed' => line.style_dashed
result
get_size(x) =>
result = switch x
'Auto' => size.auto
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
'Large' => size.large
'Huge' => size.huge
get_table_pos(pos) =>
result = switch pos
"Bottom Center" => position.bottom_center
"Bottom Left" => position.bottom_left
"Bottom Right" => position.bottom_right
"Middle Center" => position.middle_center
"Middle Left" => position.middle_left
"Middle Right" => position.middle_right
"Top Center" => position.top_center
"Top Left" => position.top_left
"Top Right" => position.top_right
get_font_style(s) =>
result = switch s
'Monospace' => font.family_monospace
'Default' => font.family_default
// ---------------------------------------- Constant Functions --------------------------------------------------
// ---------------------------------------- Inputs --------------------------------------------------
gmt_tz = input.string('America/New_York', "Timezone", options = , tooltip = "Note GMT is not adjusted to reflect Daylight Saving Time changes", group = 'Time Zone')
DWM_profile = input.bool(true,"Show All Profile",inline="Show",group = 'Profile')
D_profile = input.bool(true,"Show Daily",inline = "Show",group = 'Profile')
hide_lines_DO = input.timeframe("60","Daily:",inline = "Hide",group = 'Hide Above')
W_profile = input.bool(true,"Weekly",inline="Show",group = 'Profile')
hide_lines_WO = input.timeframe("240","Weekly:",inline="Hide",group = 'Hide Above')
M_profile = input.bool(true,"Monthly",inline="Show",group = 'Profile')
hide_lines_MO = input.timeframe("1D","Monthly:",inline="Hide",group = 'Hide Above')
show_kz = input.bool(false, "Show Killzone Boxes", inline = "skz", group = 'Hide KillZone')
var g_SETTINGS = "Settings"
max_days = input.int(60, "Drawing Limit", 1, inline = 'dl', tooltip = "Only this many drawings will be kept on the chart, for each selected drawing type (killzone boxes, pivot lines, open lines, etc.)", group = g_SETTINGS)
tf_limit = input.timeframe("30", "Timeframe Limit", inline = 'dl', tooltip = "Drawings will not appear on timeframes greater than or equal to this", group = g_SETTINGS)
lbl_size = get_size(input.string('Tiny', "Label Size", inline = 'sc', options = , tooltip = "The size of all labels", group = g_SETTINGS))
font_style = get_font_style(input.string('Monospace', "Font Style", inline = 'sc', group = g_SETTINGS, options = ))
txt_color = input.color(#000000, "Text Color", inline = 'sc', tooltip = "The color of all label and table text", group = g_SETTINGS)
use_cutoff = input.bool(true, "Drawing Cutoff Time", inline = "CO", tooltip = "When enabled, all pivots and open price lines will stop extending at this time", group = g_SETTINGS)
cutoff = input.session("1700-1701", "", inline = "CO", group = g_SETTINGS)
var g_KZ = "Killzones"
show_kz_text = input.bool(false, "Display Text", inline = "KZ", group = g_KZ)
box_transparency = input.int(85, "Box Transparency", 0, 100, group = g_KZ)
text_transparency = input.int(50, "Text Transparency", 0, 100, group = g_KZ)
use_asia = input.bool(true, "", inline = "ASIA", group = g_KZ)
as_txt = input.string("ASIA", "", inline = "ASIA", group = g_KZ)
asia = input.session("2000-0000", "", inline = "ASIA", group = g_KZ)
as_color = input.color(#9598a1, "", inline = "ASIA", group = g_KZ)
use_london = input.bool(true, "", inline = "LONDON", group = g_KZ)
lo_txt = input.string("OPEN", "", inline = "LONDON", group = g_KZ)
london = input.session("0200-0500", "", inline = "LONDON", group = g_KZ)
lo_color = input.color(#9598a1, "", inline = "LONDON", group = g_KZ)
use_nyam = input.bool(true, "", inline = "NYAM", group = g_KZ)
na_txt = input.string("NYAM", "", inline = "NYAM", group = g_KZ)
nyam = input.session("0700-1000", "", inline = "NYAM", group = g_KZ)
na_color = input.color(#9598a1, "", inline = "NYAM", group = g_KZ)
use_nylu = input.bool(false, "", inline = "NYLU", group = g_KZ)
nl_txt = input.string("Lunch", "", inline = "NYLU", group = g_KZ)
nylu = input.session("1200-1300", "", inline = "NYLU", group = g_KZ)
nl_color = input.color(#9598a1, "", inline = "NYLU", group = g_KZ)
use_nypm = input.bool(false, "", inline = "NYPM", group = g_KZ)
np_txt = input.string("NYPM", "", inline = "NYPM", group = g_KZ)
nypm = input.session("1300-1600", "", inline = "NYPM", group = g_KZ)
np_color = input.color(#9598a1, "", inline = "NYPM", group = g_KZ)
use_loop = input.bool(true, "", inline = "LOOP", group = g_KZ)
op_txt = input.string("CBDR", "", inline = "LOOP", group = g_KZ)
loop = input.session("1400-2000", "", inline = "LOOP", group = g_KZ)
op_color = input.color(#9598a1, "", inline = "LOOP", group = g_KZ)
use_locl = input.bool(true, "", inline = "LOCL", group = g_KZ)
cl_txt = input.string("CLOSE", "", inline = "LOCL", group = g_KZ)
locl = input.session("1000-1200", "", inline = "LOCL", group = g_KZ)
cl_color = input.color(#9598a1, "", inline = "LOCL", group = g_KZ)
use_sb1 = input.bool(false, "", inline = "SB1", group = g_KZ)
m1_txt = input.string("London SB", "", inline = "SB1", group = g_KZ)
sb1 = input.session("0300-0400", "", inline = "SB1", group = g_KZ)
m1_color = input.color(#9598a1, "", inline = "SB1", group = g_KZ)
use_sb2 = input.bool(false, "", inline = "SB2", group = g_KZ)
m2_txt = input.string("NewYork AM SB", "", inline = "SB2", group = g_KZ)
sb2 = input.session("1000-1100", "", inline = "SB2", group = g_KZ)
m2_color = input.color(#9598a1, "", inline = "SB2", group = g_KZ)
use_sb3 = input.bool(false, "", inline = "SB3", group = g_KZ)
m3_txt = input.string("NewYork PM SB", "", inline = "SB3", group = g_KZ)
sb3 = input.session("1400-1500", "", inline = "SB3", group = g_KZ)
m3_color = input.color(#9598a1, "", inline = "SB3", group = g_KZ)
var g_LABELS = "Killzone Pivots"
use_alerts = input.bool(false, "Alert Broken Pivots", inline = "PV", group = g_LABELS)
show_pivots = input.bool(false, "Show Pivots", inline = "SV", group = g_LABELS)
show_labels = input.bool(false, "Pivots Labels", inline = "SV", group = g_LABELS)
show_midpoints = input.bool(false, "Pivots Midpoints",inline = "SV", group = g_LABELS)
ext_pivots = input.string("Until Mitigated", "Extend Pivots...", options = , group = g_LABELS)
ext_which = input.string("Most Recent", "...From Which Sessions", options = , group = g_LABELS)
ash_str = input.string("AS.H", "Killzone 01 Labels", inline = "L_AS", group = g_LABELS)
asl_str = input.string("AS.L", "", inline = "L_AS", group = g_LABELS)
loh_str = input.string("LO.H", "Killzone 02 Labels", inline = "L_LO", group = g_LABELS)
lol_str = input.string("LO.L", "", inline = "L_LO", group = g_LABELS)
nah_str = input.string("NYAM.H", "Killzone 03 Labels", inline = "L_NA", group = g_LABELS)
nal_str = input.string("NYAM.L", "", inline = "L_NA", group = g_LABELS)
nlh_str = input.string("NYL.H", "Killzone 04 Labels", inline = "L_NL", group = g_LABELS)
nll_str = input.string("NYL.L", "", inline = "L_NL", group = g_LABELS)
nph_str = input.string("NYPM.H", "Killzone 05 Labels", inline = "L_NP", group = g_LABELS)
npl_str = input.string("NYPM.L", "", inline = "L_NP", group = g_LABELS)
oph_str = input.string("LOOP.H", "Killzone 06 Labels", inline = "L_OP", group = g_LABELS)
opl_str = input.string("LOOP.L", "", inline = "L_OP", group = g_LABELS)
clh_str = input.string("LOCL.H", "Killzone 07 Labels", inline = "L_CL", group = g_LABELS)
cll_str = input.string("LOCL.L", "", inline = "L_CL", group = g_LABELS)
m1h_str = input.string("SB1.H", "Killzone 08 Labels", inline = "L_M1", group = g_LABELS)
m1l_str = input.string("SB1.L", "", inline = "L_M1", group = g_LABELS)
m2h_str = input.string("SB2.H", "Killzone 09 Labels", inline = "L_M2", group = g_LABELS)
m2l_str = input.string("SB2.L", "", inline = "L_M2", group = g_LABELS)
m3h_str = input.string("SB3.H", "Killzone 10 Labels", inline = "L_M3", group = g_LABELS)
m3l_str = input.string("SB3.L", "", inline = "L_M3", group = g_LABELS)
kzp_style = get_line_type(input.string(defval = 'Solid', title = "Pivot Style", options = , inline = "KZP", group = g_LABELS))
kzp_width = input.int(1, "", inline = "KZP", group = g_LABELS)
kzm_style = get_line_type(input.string(defval = 'Dotted', title = "Midpoint Style", options = , inline = "KZM", group = g_LABELS))
kzm_width = input.int(1, "", inline = "KZM", group = g_LABELS)
var g_RNG = "Killzone Range"
show_range = input.bool(false, "Show Killzone Range", tooltip = "Show the most recent ranges of each selected killzone, from high to low", group = g_RNG)
show_range_avg = input.bool(true, "Show Average", tooltip = "Show the average range of each selected killzone", group = g_RNG)
range_avg = input.int(5, "Average Length", 0, tooltip = "This many previous sessions will be used to calculate the average. If there isn't enough data on the current chart, it will use as many sessions as possible", group = g_RNG)
range_pos = get_table_pos(input.string('Top Right', "Table Position", options = , group = g_RNG))
range_size = get_size(input.string('Normal', "Table Size", options = , group = g_RNG))
var g_DWM = "Day - Week - Month"
dow_labels = input.bool(false, "Day of Week Labels", inline = "DOW", group = g_DWM)
dow_yloc = input.string('Bottom', "", options = , inline = "DOW", group = g_DWM)
dow_xloc = input.string('Midnight', "", options = , inline = "DOW", group = g_DWM)
sep_unlimited = input.bool(true, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_DWM)
show_d_open = input.bool(true, "D Open", inline = "DO", group = g_DWM)
dhl = input.bool(true, "High/Low", inline = "DO", tooltip = "", group = g_DWM)
ds = input.bool(true, "Separators", inline = "DO", tooltip = "Mark where a new day begins", group = g_DWM)
d_color = input.color(color.blue, "", inline = "DO", group = g_DWM)
show_w_open = input.bool(true, "W Open", inline = "WO", group = g_DWM)
whl = input.bool(true, "High/Low", inline = "WO", tooltip = "", group = g_DWM)
ws = input.bool(true, "Separators", inline = "WO", tooltip = "Mark where a new week begins", group = g_DWM)
w_color = input.color(#089981, "", inline = "WO", group = g_DWM)
show_m_open = input.bool(true, "M Open", inline = "MO", group = g_DWM)
mhl = input.bool(true, "High/Low", inline = "MO", tooltip = "", group = g_DWM)
ms = input.bool(true, "Separators", inline = "MO", tooltip = "Mark where a new month begins", group = g_DWM)
m_color = input.color(color.red, "", inline = "MO", group = g_DWM)
htf_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "D0", group = g_DWM))
htf_width = input.int(1, "", inline = "D0", group = g_DWM)
var g_OPEN = "Opening Prices"
open_unlimited = input.bool(true, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_OPEN)
hide_hline = input.bool(true,"Show Opening Price",group = g_OPEN)
hide_lines_h = input.timeframe("60","Hide Above Time Frame",group = g_OPEN)
use_h1 = input.bool(true, "", inline = "H1", group = g_OPEN)
h1_text = input.string("00:00", "", inline = "H1", group = g_OPEN)
h1 = input.session("0000-0001", "", inline = "H1", group = g_OPEN)
h1_color = input.color(#000000, "", inline = "H1", group = g_OPEN)
use_h2 = input.bool(true, "", inline = "H2", group = g_OPEN)
h2_text = input.string("08:30", "", inline = "H2", group = g_OPEN)
h2 = input.session("0830-0831", "", inline = "H2", group = g_OPEN)
h2_color = input.color(#000000, "", inline = "H2", group = g_OPEN)
use_h3 = input.bool(false, "", inline = "H3", group = g_OPEN)
h3_text = input.string("10:00", "", inline = "H3", group = g_OPEN)
h3 = input.session("1000-1001", "", inline = "H3", group = g_OPEN)
h3_color = input.color(#000000, "", inline = "H3", group = g_OPEN)
use_h4 = input.bool(false, "", inline = "H4", group = g_OPEN)
h4_text = input.string("14:00", "", inline = "H4", group = g_OPEN)
h4 = input.session("1400-1401", "", inline = "H4", group = g_OPEN)
h4_color = input.color(#000000, "", inline = "H4", group = g_OPEN)
hz_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "H0", group = g_OPEN))
hz_width = input.int(1, "", inline = "H0", group = g_OPEN)
var g_VERTICAL = "Timestamps"
hide_vline = input.bool(true,"Show Timestamp",group = g_VERTICAL)
hide_lines_v = input.timeframe("60","Hide Above Time Frame",group = g_VERTICAL)
use_v1 = input.bool(true, "", inline = "V1", group = g_VERTICAL)
v1 = input.session("0000-0001", "", inline = "V1", group = g_VERTICAL)
v1_color = input.color(#000000, "", inline = "V1", group = g_VERTICAL)
use_v2 = input.bool(false, "", inline = "V2", group = g_VERTICAL)
v2 = input.session("0800-0801", "", inline = "V2", group = g_VERTICAL)
v2_color = input.color(#000000, "", inline = "V2", group = g_VERTICAL)
use_v3 = input.bool(false, "", inline = "V3", group = g_VERTICAL)
v3 = input.session("1000-1001", "", inline = "V3", group = g_VERTICAL)
v3_color = input.color(#000000, "", inline = "V3", group = g_VERTICAL)
use_v4 = input.bool(false, "", inline = "V4", group = g_VERTICAL)
v4 = input.session("1200-1201", "", inline = "V4", group = g_VERTICAL)
v4_color = input.color(#000000, "", inline = "V4", group = g_VERTICAL)
vl_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "V0", group = g_VERTICAL))
vl_width = input.int(1, "", inline = "V0", group = g_VERTICAL)
// ---------------------------------------- Inputs --------------------------------------------------
// ---------------------------------------- Variables & Constants --------------------------------------------------
type kz
string _title
box _box
line _hi_line
line _md_line
line _lo_line
label _hi_label
label _lo_label
bool _hi_valid
bool _md_valid
bool _lo_valid
float _range_store
float _range_current
type hz
line LN
label LB
bool CO
type dwm_hl
line hi_line
line lo_line
label hi_label
label lo_label
type dwm_info
string tf
float o = na
float h = na
float l = na
float ph = na
float pl = na
var as_kz = kz.new(as_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var lo_kz = kz.new(lo_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var na_kz = kz.new(na_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var nl_kz = kz.new(nl_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var np_kz = kz.new(np_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var op_kz = kz.new(op_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var cl_kz = kz.new(cl_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var m1_kz = kz.new(m1_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var m2_kz = kz.new(m2_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var m3_kz = kz.new(m3_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float())
var hz_1 = hz.new(array.new_line(), array.new_label(), array.new_bool())
var hz_2 = hz.new(array.new_line(), array.new_label(), array.new_bool())
var hz_3 = hz.new(array.new_line(), array.new_label(), array.new_bool())
var hz_4 = hz.new(array.new_line(), array.new_label(), array.new_bool())
var d_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var w_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var m_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var d_info = dwm_info.new("D")
var w_info = dwm_info.new("W")
var m_info = dwm_info.new("M")
t_as = not na(time("", asia, gmt_tz))
t_lo = not na(time("", london, gmt_tz))
t_na = not na(time("", nyam, gmt_tz))
t_nl = not na(time("", nylu, gmt_tz))
t_np = not na(time("", nypm, gmt_tz))
t_op = not na(time("", loop, gmt_tz))
t_cl = not na(time("", locl, gmt_tz))
t_m1 = not na(time("", sb1, gmt_tz))
t_m2 = not na(time("", sb2, gmt_tz))
t_m3 = not na(time("", sb3, gmt_tz))
t_co = not na(time("", cutoff, gmt_tz))
t_h1 = not na(time("", h1, gmt_tz))
t_h2 = not na(time("", h2, gmt_tz))
t_h3 = not na(time("", h3, gmt_tz))
t_h4 = not na(time("", h4, gmt_tz))
t_v1 = not na(time("", v1, gmt_tz))
t_v2 = not na(time("", v2, gmt_tz))
t_v3 = not na(time("", v3, gmt_tz))
t_v4 = not na(time("", v4, gmt_tz))
var d_sep_line = array.new_line()
var w_sep_line = array.new_line()
var m_sep_line = array.new_line()
var d_line = array.new_line()
var w_line = array.new_line()
var m_line = array.new_line()
var d_label = array.new_label()
var w_label = array.new_label()
var m_label = array.new_label()
var v1_line = array.new_line()
var v2_line = array.new_line()
var v3_line = array.new_line()
var v4_line = array.new_line()
var transparent = #ffffff00
var ext_current = ext_which == 'Most Recent'
var ext_past = ext_pivots == 'Past Mitigation'
update_dwm_info(dwm_info n) =>
if timeframe.change(n.tf)
n.ph := n.h
n.pl := n.l
n.o := open
n.h := high
n.l := low
else
n.h := math.max(high, n.h)
n.l := math.min(low, n.l)
if dhl or show_d_open
update_dwm_info(d_info)
if whl or show_w_open
update_dwm_info(w_info)
if mhl or show_m_open
update_dwm_info(m_info)
// ---------------------------------------- Variables & Constants --------------------------------------------------
// ---------------------------------------- Functions --------------------------------------------------
get_box_color(color c) =>
result = color.new(c, box_transparency)
get_text_color(color c) =>
result = color.new(c, text_transparency)
// ---------------------------------------- Functions --------------------------------------------------
// ---------------------------------------- Core Logic --------------------------------------------------
dwm_sep(string tf, bool use, line arr, color col) =>
if use
if timeframe.change(tf)
arr.unshift(line.new(bar_index, high*1.0001, bar_index, low, style = htf_style, width = htf_width, extend = extend.both, color = col))
if not sep_unlimited and arr.size() > max_days
arr.pop().delete()
dwm_open(string tf, bool use, line lns, label lbls, dwm_info n, color col) =>
if use
if timeframe.change(tf)
lns.unshift(line.new(time, n.o, time, n.o, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
lbls.unshift(label.new(time, n.o, tf + " OPEN", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size, text_font_family = font_style))
if not sep_unlimited and lns.size() > max_days
lns.pop().delete()
lbls.pop().delete()
else if lns.size() > 0
lns.get(0).set_x2(time)
lbls.get(0).set_x(time)
dwm_hl(string tf, bool use, dwm_hl hl, dwm_info n, color col) =>
if use
if timeframe.change(tf)
hl.hi_line.unshift(line.new(time, n.ph, time, n.ph, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.lo_line.unshift(line.new(time, n.pl, time, n.pl, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.hi_label.unshift(label.new(time, n.ph, "P"+tf+"H", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size, text_font_family = font_style))
hl.lo_label.unshift(label.new(time, n.pl, "P"+tf+"L", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size, text_font_family = font_style))
if not sep_unlimited and hl.hi_line.size() > max_days
hl.hi_line.pop().delete()
hl.lo_line.pop().delete()
hl.hi_label.pop().delete()
hl.lo_label.pop().delete()
else if hl.hi_line.size() > 0
hl.hi_line.get(0).set_x2(time)
hl.lo_line.get(0).set_x2(time)
hl.hi_label.get(0).set_x(time)
hl.lo_label.get(0).set_x(time)
dwm() =>
//if timeframe.in_seconds() <= hide_lines_sessions *60
if DWM_profile
if D_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_DO)
// Draw Daily separators, open lines, and high/low lines
dwm_sep("D", ds, d_sep_line, d_color)
dwm_open("D", show_d_open, d_line, d_label, d_info, d_color)
dwm_hl("D", dhl, d_hl, d_info, d_color)
// Draw Weekly and Monthly only if Daily profile allows it
if W_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_WO)
dwm_sep("W", ws, w_sep_line, w_color)
dwm_open("W", show_w_open, w_line, w_label, w_info, w_color)
dwm_hl("W", whl, w_hl, w_info, w_color)
if M_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_MO)
dwm_sep("M", ms, m_sep_line, m_color)
dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)
dwm_hl("M", mhl, m_hl, m_info, m_color)
else if W_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_WO)
// Draw Weekly separators, open lines, and high/low lines
dwm_sep("W", ws, w_sep_line, w_color)
dwm_open("W", show_w_open, w_line, w_label, w_info, w_color)
dwm_hl("W", whl, w_hl, w_info, w_color)
// Draw Monthly only if Weekly profile allows it
if M_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_MO)
dwm_sep("M", ms, m_sep_line, m_color)
dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)
dwm_hl("M", mhl, m_hl, m_info, m_color)
else if M_profile and timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_MO)
// Draw Monthly separators, open lines, and high/low lines
dwm_sep("M", ms, m_sep_line, m_color)
dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)
dwm_hl("M", mhl, m_hl, m_info, m_color)
vline(bool use, bool t, line arr, color col) =>
if use
if t and not t
arr.unshift(line.new(bar_index, high*1.0001, bar_index, low, style = vl_style, width = vl_width, extend = extend.both, color = col))
vlines() =>
if hide_vline
if timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_v)
vline(use_v1, t_v1, v1_line, v1_color)
vline(use_v2, t_v2, v2_line, v2_color)
vline(use_v3, t_v3, v3_line, v3_color)
vline(use_v4, t_v4, v4_line, v4_color)
hz_line(bool use, bool t, hz hz, string txt, color col) =>
if use
if t and not t
hz.LN.unshift(line.new(bar_index, open, bar_index, open, style = hz_style, width = hz_width, color = col))
hz.LB.unshift(label.new(bar_index, open, txt, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size, text_font_family = font_style))
array.unshift(hz.CO, false)
if not open_unlimited and hz.LN.size() > max_days
hz.LN.pop().delete()
hz.LB.pop().delete()
hz.CO.pop()
if not t and hz.CO.size() > 0
if not hz.CO.get(0)
hz.LN.get(0).set_x2(bar_index)
hz.LB.get(0).set_x(bar_index)
if (use_cutoff ? t_co : false)
hz.CO.set(0, true)
hz_lines() =>
if hide_hline
if timeframe.in_seconds("") <= timeframe.in_seconds(hide_lines_h)
hz_line(use_h1, t_h1, hz_1, h1_text, h1_color)
hz_line(use_h2, t_h2, hz_2, h2_text, h2_color)
hz_line(use_h3, t_h3, hz_3, h3_text, h3_color)
hz_line(use_h4, t_h4, hz_4, h4_text, h4_color)
del_kz(kz k) =>
if k._box.size() > max_days
k._box.pop().delete()
if k._hi_line.size() > max_days
k._hi_line.pop().delete()
k._lo_line.pop().delete()
k._hi_valid.pop()
k._lo_valid.pop()
if show_midpoints
k._md_line.pop().delete()
k._md_valid.pop()
if k._hi_label.size() > max_days
k._hi_label.pop().delete()
k._lo_label.pop().delete()
adjust_in_kz(kz kz, bool t) =>
if t
kz._box.get(0).set_right(time)
kz._box.get(0).set_top(math.max(kz._box.get(0).get_top(), high))
kz._box.get(0).set_bottom(math.min(kz._box.get(0).get_bottom(), low))
kz._range_current := kz._box.get(0).get_top() - kz._box.get(0).get_bottom()
if show_pivots and kz._hi_line.size() > 0
if high > kz._hi_line.get(0).get_y1()
kz._hi_line.get(0).set_xy1(time, high)
kz._hi_line.get(0).set_xy2(time, high)
if low < kz._lo_line.get(0).get_y1()
kz._lo_line.get(0).set_xy1(time, low)
kz._lo_line.get(0).set_xy2(time, low)
if show_midpoints
kz._md_line.get(0).set_xy1(time, math.avg(kz._hi_line.get(0).get_y2(), kz._lo_line.get(0).get_y2()))
kz._md_line.get(0).set_xy2(time, math.avg(kz._hi_line.get(0).get_y2(), kz._lo_line.get(0).get_y2()))
if show_labels and kz._hi_label.size() > 0
if high > kz._hi_label.get(0).get_y()
kz._hi_label.get(0).set_xy(time, high)
if low < kz._lo_label.get(0).get_y()
kz._lo_label.get(0).set_xy(time, low)
adjust_out_kz(kz kz, bool t) =>
if not t and kz._box.size() > 0
if t
array.unshift(kz._range_store, kz._range_current)
if kz._range_store.size() > range_avg
kz._range_store.pop()
if kz._box.size() > 0 and show_pivots
for i = 0 to kz._box.size() - 1
if not ext_current or (ext_current and i == 0)
if ext_past ? true : (kz._hi_valid.get(i) == true)
kz._hi_line.get(i).set_x2(time)
if high > kz._hi_line.get(i).get_y1() and kz._hi_valid.get(i) == true
if use_alerts and i == 0
alert("Broke "+kz._title+" High", alert.freq_once_per_bar)
kz._hi_valid.set(i, false)
else if (use_cutoff ? t_co : false)
kz._hi_valid.set(i, false)
if ext_past ? true : (kz._lo_valid.get(i) == true)
kz._lo_line.get(i).set_x2(time)
if low < kz._lo_line.get(i).get_y1() and kz._lo_valid.get(i) == true
if use_alerts and i == 0
alert("Broke "+kz._title+" Low", alert.freq_once_per_bar)
kz._lo_valid.set(i, false)
else if (use_cutoff ? t_co : false)
kz._lo_valid.set(i, false)
if show_midpoints
kz._md_line.get(i).set_x2(time)
else
break
manage_kz(kz kz, bool use, bool t, color c, string box_txt, string hi_txt, string lo_txt) =>
if timeframe.in_seconds("") <= timeframe.in_seconds(tf_limit) and use
if t and not t
_c = get_box_color(c)
_t = get_text_color(c)
kz._box.unshift(box.new(time, high, time, low, xloc = xloc.bar_time, border_color = show_kz ? _c : na, bgcolor = show_kz ? _c : na, text = (show_kz and show_kz_text) ? box_txt : na, text_color = _t))
if show_pivots
kz._hi_line.unshift(line.new(time, high, time, high, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
kz._lo_line.unshift(line.new(time, low, time, low, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
if show_midpoints
kz._md_line.unshift(line.new(time, math.avg(high, low), time, math.avg(high, low), xloc = xloc.bar_time, style = kzm_style, color = c, width = kzm_width))
array.unshift(kz._md_valid, true)
array.unshift(kz._hi_valid, true)
array.unshift(kz._lo_valid, true)
if show_labels
kz._hi_label.unshift(label.new(time, high, hi_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_down, size = lbl_size))
kz._lo_label.unshift(label.new(time, low, lo_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_up, size = lbl_size))
del_kz(kz)
adjust_in_kz(kz, t)
adjust_out_kz(kz, t)
manage_kz(as_kz, use_asia, t_as, as_color, as_txt, ash_str, asl_str)
manage_kz(lo_kz, use_london, t_lo, lo_color, lo_txt, loh_str, lol_str)
manage_kz(na_kz, use_nyam, t_na, na_color, na_txt, nah_str, nal_str)
manage_kz(nl_kz, use_nylu, t_nl, nl_color, nl_txt, nlh_str, nll_str)
manage_kz(np_kz, use_nypm, t_np, np_color, np_txt, nph_str, npl_str)
manage_kz(op_kz, use_loop, t_op, op_color, op_txt, oph_str, opl_str)
manage_kz(cl_kz, use_locl, t_cl, cl_color, cl_txt, clh_str, cll_str)
manage_kz(m1_kz, use_sb1, t_m1, m1_color, m1_txt, m1h_str, m1l_str)
manage_kz(m2_kz, use_sb2, t_m2, m2_color, m2_txt, m2h_str, m2l_str)
manage_kz(m3_kz, use_sb3, t_m3, m3_color, m3_txt, m3h_str, m3l_str)
dwm()
vlines()
hz_lines()
new_dow_time = dow_xloc == 'Midday' ? time - timeframe.in_seconds("D") / 2 * 1000 : time
new_day = dayofweek(new_dow_time, gmt_tz) != dayofweek(new_dow_time, gmt_tz)
var dow_top = dow_yloc == 'Top'
var sunday = "SUNDAY"
var monday = "MONDAY"
var tuesday = "TUESDAY"
var wednesday = "WEDNESDAY"
var thursday = "THURSDAY"
var friday = "FRIDAY"
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 1 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = sunday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 2 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = monday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 3 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = tuesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 4 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = wednesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 5 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = thursday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 6 and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor = txt_color, text = friday)
get_min_days_stored() =>
store = array.new_int()
if as_kz._range_store.size() > 0
store.push(as_kz._range_store.size())
if lo_kz._range_store.size() > 0
store.push(lo_kz._range_store.size())
if na_kz._range_store.size() > 0
store.push(na_kz._range_store.size())
if nl_kz._range_store.size() > 0
store.push(nl_kz._range_store.size())
if np_kz._range_store.size() > 0
store.push(np_kz._range_store.size())
if op_kz._range_store.size() > 0
store.push(op_kz._range_store.size())
if cl_kz._range_store.size() > 0
store.push(cl_kz._range_store.size())
if m1_kz._range_store.size() > 0
store.push(m1_kz._range_store.size())
if m2_kz._range_store.size() > 0
store.push(m2_kz._range_store.size())
if m3_kz._range_store.size() > 0
store.push(m3_kz._range_store.size())
result = store.min()
set_table(table tbl, kz kz, int row, string txt, bool use, bool t, color col) =>
if use
table.cell(tbl, 0, row, txt, text_size = range_size, bgcolor = get_box_color(col), text_color = txt_color)
table.cell(tbl, 1, row, str.tostring(kz._range_current), text_size = range_size, bgcolor = t ? get_box_color(col) : na, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, row, str.tostring(kz._range_store.avg()), text_size = range_size, text_color = txt_color)
if show_range and barstate.islast
var tbl = table.new(range_pos, 10, 10, chart.bg_color, chart.fg_color, 2, chart.fg_color, 1)
table.cell(tbl, 0, 0, "Killzone", text_size = range_size, text_color = txt_color)
table.cell(tbl, 1, 0, "Range", text_size = range_size, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, 0, "Avg ("+str.tostring(get_min_days_stored())+")", text_size = range_size, text_color = txt_color)
set_table(tbl, as_kz, 1, as_txt, use_asia, t_as, as_color)
set_table(tbl, lo_kz, 2, lo_txt, use_london, t_lo, lo_color)
set_table(tbl, na_kz, 3, na_txt, use_nyam, t_na, na_color)
set_table(tbl, nl_kz, 4, nl_txt, use_nylu, t_nl, nl_color)
set_table(tbl, np_kz, 5, np_txt, use_nypm, t_np, np_color)
set_table(tbl, op_kz, 6, op_txt, use_loop, t_op, op_color)
set_table(tbl, cl_kz, 7, cl_txt, use_locl, t_cl, cl_color)
set_table(tbl, m1_kz, 8, m1_txt, use_sb1, t_m1, m1_color)
set_table(tbl, m2_kz, 9, m2_txt, use_sb2, t_m2, m2_color)
set_table(tbl, m3_kz, 10, m3_txt, use_sb3, t_m3, m3_color)
// ---------------------------------------- Core Logic --------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------//
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// ©Mutharasan2
// Prev Published: 608
// Curr Published: 907
//@version=5
//2nd indicator("ICT HTF Candles (fadi)", overlay=true, max_boxes_count = 500, max_lines_count = 500, max_bars_back = 5000)
type Candle
float o
float c
float h
float l
int o_idx
int c_idx
int h_idx
int l_idx
box body
line wick_up
line wick_down
type Trace
line o
line c
line h
line l
label o_l
label c_l
label h_l
label l_l
type Imbalance
box b
int idx
type CandleSettings
bool show
string htf
int max_display
type Settings
int max_sets
color bull_body
color bull_border
color bull_wick
color bear_body
color bear_border
color bear_wick
int offset
int buffer
int htf_buffer
int width
bool trace_show
color trace_o_color
string trace_o_style
int trace_o_size
color trace_c_color
string trace_c_style
int trace_c_size
color trace_h_color
string trace_h_style
int trace_h_size
color trace_l_color
string trace_l_style
int trace_l_size
string trace_anchor
bool label_show
color label_color
string label_size
bool fvg_show
color fvg_color
bool vi_show
color vi_color
bool htf_label_show
color htf_label_color
string htf_label_size
bool htf_timer_show
color htf_timer_color
string htf_timer_size
string level
string liquidity_open_style
string liquidity_claimed_style
color liquidity_open_color
color liquidity_claimed_color
int liquidity_open_size
int liquidity_claimed_size
int max_lines
int extend
type CandleSet
Candle candles
Imbalance imbalances
CandleSettings settings
label tfName
label tfTimer
type Helper
string name = "Helper"
Settings settings = Settings.new()
var CandleSettings SettingsHTF1 = CandleSettings.new()
var CandleSettings SettingsHTF2 = CandleSettings.new()
var CandleSettings SettingsHTF3 = CandleSettings.new()
var CandleSettings SettingsHTF4 = CandleSettings.new()
var CandleSettings SettingsHTF5 = CandleSettings.new()
var CandleSettings SettingsHTF6 = CandleSettings.new()
var Candle candles_1 = array.new(0)
var Candle candles_2 = array.new(0)
var Candle candles_3 = array.new(0)
var Candle candles_4 = array.new(0)
var Candle candles_5 = array.new(0)
var Candle candles_6 = array.new(0)
var Imbalance imbalances_1 = array.new()
var Imbalance imbalances_2 = array.new()
var Imbalance imbalances_3 = array.new()
var Imbalance imbalances_4 = array.new()
var Imbalance imbalances_5 = array.new()
var Imbalance imbalances_6 = array.new()
var CandleSet htf1 = CandleSet.new()
htf1.settings := SettingsHTF1
htf1.candles := candles_1
htf1.imbalances := imbalances_1
var CandleSet htf2 = CandleSet.new()
htf2.settings := SettingsHTF2
htf2.candles := candles_2
htf2.imbalances := imbalances_2
var CandleSet htf3 = CandleSet.new()
htf3.settings := SettingsHTF3
htf3.candles := candles_3
htf3.imbalances := imbalances_3
var CandleSet htf4 = CandleSet.new()
htf4.settings := SettingsHTF4
htf4.candles := candles_4
htf4.imbalances := imbalances_4
var CandleSet htf5 = CandleSet.new()
htf5.settings := SettingsHTF5
htf5.candles := candles_5
htf5.imbalances := imbalances_5
var CandleSet htf6 = CandleSet.new()
htf6.settings := SettingsHTF6
htf6.candles := candles_6
htf6.imbalances := imbalances_6
//+------------------------------------------------------------------------------------------------------------+//
//+--- Settings ---+//
//+------------------------------------------------------------------------------------------------------------+//
htf1.settings.show := input.bool(false, "HTF 1 ", inline="htf1")
htf_1 = input.timeframe("60", "", inline="htf1")
htf1.settings.htf := htf_1
htf1.settings.max_display := input.int(1, "", inline="htf1")
htf2.settings.show := input.bool(false, "HTF 2 ", inline="htf2")
htf_2 = input.timeframe("240", "", inline="htf2")
htf2.settings.htf := htf_2
htf2.settings.max_display := input.int(1, "", inline="htf2")
htf3.settings.show := input.bool(true, "HTF 3 ", inline="htf3")
htf_3 = input.timeframe("1D", "", inline="htf3")
htf3.settings.htf := htf_3
htf3.settings.max_display := input.int(1, "", inline="htf3")
htf4.settings.show := input.bool(true, "HTF 4 ", inline="htf4")
htf_4 = input.timeframe("1W", "", inline="htf4")
htf4.settings.htf := htf_4
htf4.settings.max_display := input.int(1, "", inline="htf4")
htf5.settings.show := input.bool(true, "HTF 5 ", inline="htf5")
htf_5 = input.timeframe("1M", "", inline="htf5")
htf5.settings.htf := htf_5
htf5.settings.max_display := input.int(1, "", inline="htf5")
htf6.settings.show := input.bool(false, "HTF 6 ", inline="htf6")
htf_6 = input.timeframe("3M", "", inline="htf6")
htf6.settings.htf := htf_6
htf6.settings.max_display := input.int(1, "", inline="htf6")
settings.max_sets := input.int(6, "Limit to next HTFs only", minval=1, maxval=6)
settings.bull_body := input.color(color.rgb(76, 175, 80), "Body ", inline="body")
settings.bear_body := input.color(color.rgb(0, 0, 0), "", inline="body")
settings.bull_border := input.color(color.rgb(93, 96, 107), "Borders", inline="borders")
settings.bear_border := input.color(color.rgb(0, 0, 0), "", inline="borders")
settings.bull_wick := input.color(color.rgb(93, 96, 107), "Wick ", inline="wick")
settings.bear_wick := input.color(color.rgb(93, 96, 107), "", inline="wick")
settings.offset := input.int(10, "padding from current candles", minval = 1)
settings.buffer := input.int(1, "space between candles", minval = 1, maxval = 4)
settings.htf_buffer := input.int(10, "space between Higher Timeframes", minval = 1, maxval = 10)
settings.width := input.int(4, "Candle Width", minval = 1, maxval = 10)*2
settings.htf_label_show := input.bool(false, "HTF Label ", inline="HTFlabel")
settings.htf_label_color := input.color(color.rgb(0, 0, 0), "", inline='HTFlabel')
settings.htf_label_size := input.string(size.tiny, "", , inline="HTFlabel")
settings.htf_timer_show := input.bool(false, "Remaining time ", inline="timer")
settings.htf_timer_color := input.color(color.rgb(0, 0, 0), "", inline='timer')
settings.htf_timer_size := input.string(size.tiny, "", , inline="timer")
settings.fvg_show := input.bool(true, "Fair Value Gap ", group="Imbalance", inline="fvg")
settings.fvg_color := input.color(color.new(color.gray, 80), "", inline='fvg', group="Imbalance")
settings.vi_show := input.bool(true, "Volume Imbalance", group="Imbalance", inline="vi")
settings.vi_color := input.color(color.new(color.red, 50), "", inline='vi', group="Imbalance")
settings.trace_show := input.bool(false, "Trace lines", group="trace")
settings.trace_o_color := input.color(color.rgb(0, 0, 0), "Open ", inline='1', group="trace")
settings.trace_o_style := input.string('····', '', options = , inline='1', group="trace")
settings.trace_o_size := input.int(1, '', options = , inline='1', group="trace")
settings.trace_c_color := input.color(color.rgb(0, 0, 0), "Close ", inline='2', group="trace")
settings.trace_c_style := input.string('····', '', options = , inline='2', group="trace")
settings.trace_c_size := input.int(1, '', options = , inline='2', group="trace")
settings.trace_h_color := input.color(color.rgb(0, 0, 0), "High ", inline='3', group="trace")
settings.trace_h_style := input.string('····', '', options = , inline='3', group="trace")
settings.trace_h_size := input.int(1, '', options = , inline='3', group="trace")
settings.trace_l_color := input.color(color.rgb(0, 0, 0), "Low ", inline='4', group="trace")
settings.trace_l_style := input.string('····', '', options = , inline='4', group="trace")
settings.trace_l_size := input.int(1, '', options = , inline='4', group="trace")
settings.trace_anchor := input.string("First Timeframe", "Anchor to", options= , group="trace")
settings.label_show := input.bool(false, "Price Label ", inline="label")
settings.label_color := input.color(color.rgb(0, 0, 0), "", inline='label')
settings.label_size := input.string(size.small, "", , inline="label")
//+------------------------------------------------------------------------------------------------------------+//
//+--- Variables ---+//
//+------------------------------------------------------------------------------------------------------------+//
Helper helper = Helper.new()
var Trace trace = Trace.new()
color color_transparent = #ffffff00
//+------------------------------------------------------------------------------------------------------------+//
//+--- Internal Functions ---+//
//+------------------------------------------------------------------------------------------------------------+//
method LineStyle(Helper helper, string style) =>
helper.name := style
out = switch style
'----' => line.style_dashed
'····' => line.style_dotted
=> line.style_solid
method ValidTimeframe(Helper helper, string HTF) =>
helper.name := HTF
if timeframe.in_seconds(HTF) >= timeframe.in_seconds("D") and timeframe.in_seconds(HTF) > timeframe.in_seconds()
true
else
n1 = timeframe.in_seconds()
n2 = timeframe.in_seconds(HTF)
n3 = n1 % n2
(n1 < n2 and math.round(n2/n1) == n2/n1)
method RemainingTime(Helper helper, string HTF) =>
helper.name := HTF
if barstate.isrealtime
timeRemaining = (time_close(HTF) - timenow)/1000
days = math.floor(timeRemaining / 86400)
hours = math.floor((timeRemaining - (days*86400)) / 3600)
minutes = math.floor((timeRemaining - (days*86400) - (hours*3600))/ 60)
seconds = math.floor(timeRemaining - (days*86400) - (hours*3600) - (minutes*60))
r = str.tostring(seconds, "00")
if minutes > 0 or hours > 0 or days > 0
r := str.tostring(minutes, "00") + ":" + r
if hours > 0 or days > 0
r := str.tostring(hours, "00") + ":" + r
if days > 0
r := str.tostring(days) + "D " + r
r
else
"n/a"
method HTFName(Helper helper, string HTF) =>
helper.name := "HTFName"
formatted = HTF
seconds = timeframe.in_seconds(HTF)
if seconds < 60
formatted := str.tostring(seconds) + "s"
else if (seconds / 60) < 60
formatted := str.tostring((seconds/60)) + "m"
else if (seconds/60/60) < 24
formatted := str.tostring((seconds/60/60)) + "H"
formatted
method HTFEnabled(Helper helper) =>
helper.name := "HTFEnabled"
int enabled =0
enabled += htf1.settings.show ? 1 : 0
enabled += htf2.settings.show ? 1 : 0
enabled += htf3.settings.show ? 1 : 0
enabled += htf4.settings.show ? 1 : 0
enabled += htf5.settings.show ? 1 : 0
enabled += htf6.settings.show ? 1 : 0
int last = math.min(enabled, settings.max_sets)
last
method CandleSetHigh(Helper helper, Candle candles, float h) =>
helper.name := "CandlesSetHigh"
float _h = h
if array.size(candles) > 0
for i = 0 to array.size(candles)-1
Candle c = array.get(candles, i)
if c.h > _h
_h := c.h
_h
method CandlesHigh(Helper helper, Candle candles) =>
helper.name := "CandlesHigh"
h = 0.0
int cnt = 0
int last = helper.HTFEnabled()
if htf1.settings.show and helper.ValidTimeframe(htf1.settings.htf)
h := helper.CandleSetHigh(htf1.candles, h)
cnt += 1
if htf2.settings.show and helper.ValidTimeframe(htf2.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf2.candles, h)
cnt +=1
if htf3.settings.show and helper.ValidTimeframe(htf3.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf3.candles, h)
cnt += 1
if htf4.settings.show and helper.ValidTimeframe(htf4.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf4.candles, h)
cnt += 1
if htf5.settings.show and helper.ValidTimeframe(htf5.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf5.candles, h)
cnt += 1
if htf6.settings.show and helper.ValidTimeframe(htf6.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf6.candles, h)
h
if array.size(candles) > 0
for i = 0 to array.size(candles)-1
Candle c = array.get(candles, i)
if c.h > h
h := c.h
h
method Reorder(CandleSet candleSet, int offset) =>
size = candleSet.candles.size()
if size > 0
for i = size-1 to 0
Candle candle = candleSet.candles.get(i)
t_buffer = offset + ((settings.width+settings.buffer)*(size-i-1))
box.set_left(candle.body, bar_index + t_buffer)
box.set_right(candle.body, bar_index + settings.width + t_buffer)
line.set_x1(candle.wick_up, bar_index+((settings.width)/2) + t_buffer)
line.set_x2(candle.wick_up, bar_index+((settings.width)/2) + t_buffer)
line.set_x1(candle.wick_down, bar_index+((settings.width)/2) + t_buffer)
line.set_x2(candle.wick_down, bar_index+((settings.width)/2) + t_buffer)
candleSet
top = helper.CandlesHigh(candleSet.candles)
left = bar_index + offset + ((settings.width+settings.buffer)*(size-1))/2
if settings.htf_label_show
var label l = candleSet.tfName
string lbl = helper.HTFName(candleSet.settings.htf)
if settings.htf_timer_show
lbl += " "
if not na(l)
label.set_xy(l, left, top)
else
l := label.new(left, top, lbl, color=color_transparent, textcolor = settings.htf_label_color, style=label.style_label_down, size = settings.htf_label_size)
if settings.htf_timer_show
var label t = candleSet.tfTimer
string tmr = "(" + helper.RemainingTime(candleSet.settings.htf) + ")"
if not na(t)
label.set_xy(t, left, top)
else
t := label.new(left, top, tmr, color=color_transparent, textcolor = settings.htf_timer_color, style=label.style_label_down, size = settings.htf_timer_size)
candleSet
method FindImbalance(CandleSet candleSet) =>
if barstate.isrealtime or barstate.islast
if candleSet.imbalances.size() > 0
for i = candleSet.imbalances.size()-1 to 0
Imbalance del = candleSet.imbalances.get(i)
box.delete(del.b)
candleSet.imbalances.pop()
if candleSet.candles.size() > 3 and settings.fvg_show
for i = 1 to candleSet.candles.size() -3
candle1 = candleSet.candles.get(i)
candle2 = candleSet.candles.get(i+2)
candle3 = candleSet.candles.get(i+1)
if (candle1.l > candle2.h and math.min(candle1.o, candle1.c) > math.max(candle2.o, candle2.c))
Imbalance imb = Imbalance.new()
imb.b := box.new(box.get_left(candle2.body), candle2.h, box.get_right(candle1.body), candle1.l, bgcolor=settings.fvg_color, border_color = color_transparent, xloc=xloc.bar_index)
candleSet.imbalances.push(imb)
if (candle1.h < candle2.l and math.max(candle1.o, candle1.c) < math.min(candle2.o, candle2.c))
Imbalance imb = Imbalance.new()
imb.b := box.new(box.get_right(candle1.body), candle1.h, box.get_left(candle2.body), candle2.l, bgcolor=settings.fvg_color, border_color = color_transparent)
candleSet.imbalances.push(imb)
box temp = box.copy(candle3.body)
box.delete(candle3.body)
candle3.body := temp
if candleSet.candles.size() > 2 and settings.vi_show
for i = 1 to candleSet.candles.size() -2
candle1 = candleSet.candles.get(i)
candle2 = candleSet.candles.get(i+1)
if (candle1.l < candle2.h and math.min(candle1.o, candle1.c) > math.max(candle2.o, candle2.c))
Imbalance imb = Imbalance.new()
imb.b := box.new(box.get_left(candle2.body), math.min(candle1.o, candle1.c), box.get_right(candle1.body), math.max(candle2.o, candle2.c), bgcolor=settings.vi_color, border_color = color_transparent)
candleSet.imbalances.push(imb)
if (candle1.h > candle2.l and math.max(candle1.o, candle1.c) < math.min(candle2.o, candle2.c))
Imbalance imb = Imbalance.new()
imb.b := box.new(box.get_right(candle1.body), math.min(candle2.o, candle2.c), box.get_left(candle2.body), math.max(candle1.o, candle1.c), bgcolor=settings.vi_color, border_color = color_transparent)
candleSet.imbalances.push(imb)
candleSet
method Monitor(CandleSet candleSet) =>
HTFBarTime = time(candleSet.settings.htf)
isNewHTFCandle = ta.change(HTFBarTime)
if isNewHTFCandle
Candle candle = Candle.new()
candle.o := open
candle.c := close
candle.h := high
candle.l := low
candle.o_idx := bar_index
candle.c_idx := bar_index
candle.h_idx := bar_index
candle.l_idx := bar_index
bull = candle.c > candle.o
candle.body := box.new(bar_index, math.max(candle.o, candle.c), bar_index+2, math.min(candle.o, candle.c), bull ? settings.bull_border : settings.bear_border, 1, bgcolor = bull ? settings.bull_body : settings.bear_body)
candle.wick_up := line.new(bar_index+1, candle.h, bar_index, math.max(candle.o, candle.c), color=bull ? settings.bull_wick : settings.bear_wick)
candle.wick_down := line.new(bar_index+1, math.min(candle.o, candle.c), bar_index, candle.l, color=bull ? settings.bull_wick : settings.bear_wick)
candleSet.candles.unshift(candle)
if candleSet.candles.size() > candleSet.settings.max_display
Candle delCandle = array.pop(candleSet.candles)
box.delete(delCandle.body)
line.delete(delCandle.wick_up)
line.delete(delCandle.wick_down)
candleSet
method Update(CandleSet candleSet, int offset, bool showTrace) =>
if candleSet.candles.size() > 0
Candle candle = candleSet.candles.first()
candle.h_idx := high > candle.h ? bar_index : candle.h_idx
candle.h := high > candle.h ? high : candle.h
candle.l_idx := low < candle.l ? bar_index : candle.l_idx
candle.l := low < candle.l ? low : candle.l
candle.c := close
candle.c_idx := bar_index
bull = candle.c > candle.o
box.set_top(candle.body, candle.o)
box.set_bottom(candle.body, candle.c)
box.set_bgcolor(candle.body, bull ? settings.bull_body : settings.bear_body)
box.set_border_color(candle.body, bull ? settings.bull_border : settings.bear_border)
line.set_color(candle.wick_up, bull ? settings.bull_wick : settings.bear_wick)
line.set_color(candle.wick_down, bull ? settings.bull_wick : settings.bear_wick)
line.set_y1(candle.wick_up, candle.h)
line.set_y2(candle.wick_up, math.max(candle.o, candle.c))
line.set_y1(candle.wick_down, candle.l)
line.set_y2(candle.wick_down, math.min(candle.o, candle.c))
if barstate.isrealtime or barstate.islast
candleSet.Reorder(offset)
if settings.trace_show and showTrace
if bar_index - candle.o_idx < 5000
if na(trace.o)
trace.o := line.new(candle.o_idx, candle.o, box.get_left(candle.body), candle.o, xloc= xloc.bar_index, color=settings.trace_o_color, style= helper.LineStyle(settings.trace_o_style), width=settings.trace_o_size)
else
line.set_xy1(trace.o, candle.o_idx, candle.o)
line.set_xy2(trace.o, box.get_left(candle.body), candle.o)
if settings.label_show
if na(trace.o_l)
trace.o_l := label.new(box.get_right(candle.body), candle.o, str.tostring(candle.o), textalign = text.align_center, style=label.style_label_left, size=settings.label_size, color=color_transparent, textcolor=settings.label_color)
else
label.set_xy(trace.o_l, box.get_right(candle.body), candle.o)
label.set_text(trace.o_l, str.tostring(candle.o))
if bar_index - candle.c_idx < 5000
if na(trace.c)
trace.c := line.new(candle.c_idx, candle.c, box.get_left(candle.body), candle.c, xloc= xloc.bar_index, color=settings.trace_c_color, style=helper.LineStyle(settings.trace_c_style), width=settings.trace_c_size)
else
line.set_xy1(trace.c, candle.c_idx, candle.c)
line.set_xy2(trace.c, box.get_left(candle.body), candle.c)
if settings.label_show
if na(trace.c_l)
trace.c_l := label.new(box.get_right(candle.body), candle.c, str.tostring(candle.c), textalign = text.align_center, style=label.style_label_left, size=settings.label_size, color=color_transparent, textcolor=settings.label_color)
else
label.set_xy(trace.c_l, box.get_right(candle.body), candle.c)
label.set_text(trace.c_l, str.tostring(candle.c))
if bar_index - candle.h_idx < 5000
if na(trace.h)
trace.h := line.new(candle.h_idx, candle.h, line.get_x1(candle.wick_up), candle.h, xloc= xloc.bar_index, color=settings.trace_h_color, style=helper.LineStyle(settings.trace_h_style), width=settings.trace_h_size)
else
line.set_xy1(trace.h, candle.h_idx, candle.h)
line.set_xy2(trace.h, line.get_x1(candle.wick_up), candle.h)
if settings.label_show
if na(trace.h_l)
trace.h_l := label.new(box.get_right(candle.body), candle.h, str.tostring(candle.h), textalign = text.align_center, style=label.style_label_left, size=settings.label_size, color=color_transparent, textcolor=settings.label_color)
else
label.set_xy(trace.h_l, box.get_right(candle.body), candle.h)
label.set_text(trace.h_l, str.tostring(candle.o))
if bar_index - candle.l_idx < 5000
if na(trace.l)
trace.l := line.new(candle.l_idx, candle.l, line.get_x1(candle.wick_down), candle.l, xloc= xloc.bar_index, color=settings.trace_l_color, style=helper.LineStyle(settings.trace_l_style), width=settings.trace_l_size)
else
line.set_xy1(trace.l, candle.l_idx, candle.l)
line.set_xy2(trace.l, line.get_x1(candle.wick_down), candle.l)
if settings.label_show
if na(trace.l_l)
trace.l_l := label.new(box.get_right(candle.body), candle.l, str.tostring(candle.l), textalign = text.align_center, style=label.style_label_left, size=settings.label_size, color=color_transparent, textcolor=settings.label_color)
else
label.set_xy(trace.l_l, box.get_right(candle.body), candle.l)
label.set_text(trace.l_l, str.tostring(candle.o))
candleSet
int cnt = 0
int last = helper.HTFEnabled()
int offset = settings.offset
if htf1.settings.show and helper.ValidTimeframe(htf1.settings.htf)
bool showTrace = false
if settings.trace_anchor == "First Timeframe"
showTrace := true
if settings.trace_anchor == "Last Timeframe" and settings.max_sets == 1
showTrace := true
htf1.Monitor().Update(offset, showTrace).FindImbalance()
cnt +=1
offset += cnt > 0 ? (htf1.candles.size() * settings.width) + (htf1.candles.size() > 0 ? htf1.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf2.settings.show and helper.ValidTimeframe(htf2.settings.htf) and cnt < last
bool showTrace = false
if settings.trace_anchor == "First Timeframe" and cnt == 0
showTrace := true
if settings.trace_anchor == "Last Timeframe" and cnt == last-1
showTrace := true
htf2.Monitor().Update(offset, showTrace).FindImbalance()
cnt+=1
offset += cnt > 0 ? (htf2.candles.size() * settings.width) + (htf2.candles.size() > 0 ? htf2.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf3.settings.show and helper.ValidTimeframe(htf3.settings.htf) and cnt < last
bool showTrace = false
if settings.trace_anchor == "First Timeframe" and cnt == 0
showTrace := true
if settings.trace_anchor == "Last Timeframe" and cnt == last-1
showTrace := true
htf3.Monitor().Update(offset, showTrace).FindImbalance()
cnt+=1
offset += cnt > 0 ? (htf3.candles.size() * settings.width) + (htf3.candles.size() > 0 ? htf3.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf4.settings.show and helper.ValidTimeframe(htf4.settings.htf) and cnt < last
bool showTrace = false
if settings.trace_anchor == "First Timeframe" and cnt == 0
showTrace := true
if settings.trace_anchor == "Last Timeframe" and cnt == last-1
showTrace := true
htf4.Monitor().Update(offset, showTrace).FindImbalance()
cnt+=1
offset += cnt > 0 ? (htf4.candles.size() * settings.width) + (htf4.candles.size() > 0 ? htf4.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf5.settings.show and helper.ValidTimeframe(htf5.settings.htf) and cnt < last
bool showTrace = false
if settings.trace_anchor == "First Timeframe" and cnt == 0
showTrace := true
if settings.trace_anchor == "Last Timeframe" and cnt == last-1
showTrace := true
htf5.Monitor().Update(offset, showTrace).FindImbalance()
cnt+=1
offset += cnt > 0 ? (htf5.candles.size() * settings.width) + (htf5.candles.size() > 0 ? htf5.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf6.settings.show and helper.ValidTimeframe(htf6.settings.htf) and cnt < last
bool showTrace = false
if settings.trace_anchor == "First Timeframe" and cnt == 0
showTrace := true
if settings.trace_anchor == "Last Timeframe"
showTrace := true
htf6.Monitor().Update(offset, showTrace).FindImbalance()
//------------------------------------------------------------------------------------------------//
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// ©Mutharasan12
//@version=5
//indicator("Notes, Watermark",overlay = true)
// STICKY NOTES #BEGIN --------------------------------------------------------------------------------------------------------------------------------------------------------//
var StickyNote_settings = "STICKY NOTES --------------------------------------------------"
showStickyNotes = input.bool(false, "Show Sticky Notes?", group = StickyNote_settings)
if showStickyNotes
stickynote01 = input.text_area("Your Note Here","NOTES",group = StickyNote_settings)
tl1 = input.string("top", title = "Sticky Note Position (Vertical)", options = , group = StickyNote_settings)
tl2 = input.string("right", title = "Sticky Note Position (Horizontal)", options = , group = StickyNote_settings)
font_size = input.string("Normal", title = "Sticky Note Text Size", options = , group = StickyNote_settings)
font_type = input.string("Default", title = "Font Type", options = , group = StickyNote_settings)
font_color = input.color(color.rgb(0,0,0,0), title = "Note Color", inline = 'nc', group = StickyNote_settings)
note_color = input.color(color (color.rgb(0,0,0,100)), title = "Note Background", inline='nc', group = StickyNote_settings)
selected_font = font_type == "Default" ? font.family_default : font.family_monospace
selected_size = font_size == "Auto" ? size.auto : font_size == "Huge" ? size.huge : font_size == "Large" ? size.large : font_size == "Normal" ? size.normal : font_size == "Small" ? size.small : font_size == "Tiny" ? size.tiny : na
var table t1 = table.new(tl1 + "_" + tl2, 1, 10)
if barstate.islast
if not na(stickynote01) and stickynote01 != ""
table.cell(t1,0,0, text = stickynote01 , bgcolor = note_color, text_color = font_color, text_halign = text.align_left, text_size = selected_size, text_font_family = selected_font)
// STICKY NOTES #END ----------------------------------------------------------------------------------------------------------------------------------------------------------//
// WATERMARK #BEGIN --
ES VIX on MNQ🧭 ES + VIX Overlay on MNQ
This indicator overlays the ES (S&P 500 futures) and VIX (Volatility Index) directly on the MNQ (Micro Nasdaq Futures) chart, allowing traders to visualize in real time the correlation, divergence, and volatility influence between the three instruments.
⸻
⚙️ How It Works
• The VIX is dynamically rescaled to the MNQ’s daily open, so its moves appear on the same price scale.
• The ES line is projected based on its percentage move relative to the session open (18:00 NY).
• Both are plotted in sync with MNQ to expose relative strength and divergence zones that often precede strong directional moves.
⸻
🧩 Inputs
• VIX Symbol: choose between VIX, CBOE:VIX, TVC:VIX
• Invert VIX Correlation: flips the VIX line for inverse-correlation setups
• VIX Step: controls how sensitively the VIX moves on the MNQ scale
• ES Symbol: defines the ES contract (e.g. ES1!)
• Show Signals: toggles on/off buy & sell markers
• Step (points): minimum distance between MNQ and VIX for a valid signal
• Block Signals: disables signals between 16:15 – 03:15 (illiquid hours)
⸻
💡 Signal Logic
The system tracks crossings between MNQ and the projected VIX line:
• Buy signal → when MNQ crosses above the VIX and expands upward by ≥ X points.
• Sell signal → when MNQ crosses below the VIX and expands downward by ≥ X points.
A time filter avoids noise during low-volume sessions.
⸻
📊 Visual Guide
• Cyan line = VIX on MNQ scale
• Orange line = ES on MNQ scale
• Labels on the right = current VIX / ES values
• BUY/SELL markers = potential volatility-based reversals
⸻
🚀 Practical Use
Perfect for traders who monitor:
• VIX–price divergence
• ES vs MNQ momentum confirmation
• Early volatility expansions before trend moves
⸻
💬 Core Idea:
“Volatility leads — price confirms.”
Exhaustion Reversal Signals - ENHANCEDOverview
This is a reversal detection indicator that combines multiple technical analysis components to identify potential market turning points.
Core Components
1. Range Oscillator
Measures price deviation from a moving average (EMA/SMA) normalized by ATR
Values above +100 = bullish exhaustion zone
Values below -100 = bearish exhaustion zone
Detects momentum flattening (slope deceleration)
2. Stochastic Oscillator
Standard %K and %D with customizable parameters
Crossover detection (K crossing above/below D)
Oversold (<20) and Overbought (>80) zones
Momentum calculation (rate of change in K)
3. 🚀 Advanced Features
Early Detection System:
Identifies momentum exhaustion before confirmed crossovers
Detects when oscillator slope flattens (approaching zero)
Provides "advance warning" signals with relaxed thresholds
............................................................................................
Trend Filter:
50-period EMA for trend context
Three strength modes:
Soft: Allow all signals
Medium: Prefer trend-aligned signals
Strict: Only counter-trend reversals
Confidence Scoring (0-100%):
Oscillator extremity (30 pts)
Stochastic position (25 pts)
K-D divergence strength (20 pts)
Momentum alignment (15 pts)
Trend alignment (10 pts)
Minimum confidence threshold filtering
Visual Enhancements:
Dynamic background gradient (red→green based on oscillator)
Momentum bar coloring when slope flattens
Transparency adjustments based on momentum
Trend Strength Benchmark (TSB)This indicator helps you gauge trend strength by combining multi-timeframe EMAs, VWAP, and optional ADX filters. It tracks the EMA high, low, and close from your chosen primary timeframe, and can also pull corresponding levels from higher timeframes for added confirmation.
The shaded EMA band on the chart gives you a quick visual of the trend zone. VWAP from the same timeframe adds an anchor point to judge momentum.
For signals, the script fires a BUY when the candle’s low stays above all selected benchmark lines, and a SELL when the candle’s high stays below them. Only one type of signal is allowed at a time, preventing back-to-back buys or sells and keeping the flow clean. An optional ADX filter lets you allow signals only when the trend has enough strength.
Everything is customizable — EMA length, timeframes, signal direction, and ADX settings — making it a flexible tool for momentum and trend-based strategies.






















