QQQ overlay over NQ/NDXThis enhanced version of the QQQ overlay script builds on the original by © PtGambler, adding smoothing via stepped ratios updated on candle close to eliminate oscillation, optimizing performance by reusing lines/labels, restricting visibility to relevant symbols (NDX, NQ1!, NAS100USD), and improving visuals with rounded levels, adjustable level counts (default 5 total), extended lines, and label styles matching "Key Levels" indicator for better readability (gray text, transparent background). Removed unnecessary table and floating labels for a cleaner chart. Thanks to © PtGambler for the foundational work!
指標和策略
HTF Session Boxes H4 > H2 > H1HTF Session Boxes H4 > H2 > H1
Visualize higher timeframe candle structures on lower timeframe charts with nested, customizable boxes.
Overview
HTF Session Boxes plots 4-hour, 2-hour, and 1-hour candle ranges as nested boxes directly on your lower timeframe charts (15M and below). This provides instant visual context of higher timeframe structure without switching between different chart timeframes.
Key Features
- Three Timeframe Levels: Simultaneously displays 4H, 2H, and 1H candle boxes
- Nested Design: Boxes are layered inside each other for clear hierarchical structure
- Real-Time Updates: Boxes dynamically adjust as higher timeframe candles develop
Fully Customizable:
-Individual colors and transparency for each timeframe
-Custom border colors, widths, and styles (solid, dashed, dotted)
-Toggle each timeframe on/off independently
Best Use Cases
-Scalping & Day Trading: Maintain awareness of higher timeframe structure while trading lower
timeframes
-Session Analysis: Clearly see 4H session boundaries and internal 2H/1H divisions
-Support/Resistance: Identify key levels where higher timeframe candles open, close, or create
highs/lows
-Multi-Timeframe Confluence: Spot when multiple timeframes align at key price levels
EMA21 ATR Extension with MetricsThis will show the EMA21 with 0.5 ATR as support. With overbought area 2ATR-2.5ATR. It also has 1.5X daily point
Sultan_Mstrading Dynamic Levels (Auto-Market Final Version)The Sultan_Mstrading Dynamic Levels indicator automatically generates dynamic support and resistance levels based on the market type or trading symbol (such as Gold, Bitcoin, Indices, Oil, or Forex pairs).
It plots multiple levels above and below the current price with adjustable spacing, and automatically highlights the nearest level to the current price for quick visual reference
BRB Strict Scanner (Break → Retest → Break) - BNRPerfect ✅
Here is a **clean**, final formatted version — **NO development notes**, **NO options**, **NO extra commentary**.
Just **copy + paste** into TradingView’s script description box:
---
## 📌 BRB STRICT Scanner — Break → Retest → Break
**This indicator identifies high-probability breakout continuation setups** using a strict price-action + trend + volume confirmation model.
### ✅ What It Detects
A precise **3-step structure**:
1️⃣ **Break** of key support/resistance
2️⃣ **Retest** of that level (structure validation)
3️⃣ **Break again** with strong conviction + volume
This confirms the level has **flipped** and momentum is continuing.
---
### 🔍 Why “STRICT”?
The scanner applies **multiple filters** to eliminate low-quality signals:
✔ Trend direction & slope confirmed using EMAs
✔ Volume must exceed **Vol SMA × custom multiplier**
✔ Tight consolidation (base) before breakout
✔ Strong “power candle” on 2nd break (close in top/bottom 30%)
✔ ATR threshold to ensure real movement
✔ VWAP alignment (optional)
✔ Optional **avoid lunchtime chop** filter
✔ Cooldown between signals — no spam
**Quality > Quantity** every time.
---
### 🧠 Signal Meaning
| Label on Chart | Signal Type |
| -------------- | -------------------------- |
| **BRB🟢** | Bullish continuation setup |
| **BRB🔻** | Bearish continuation setup |
Signals appear **only on trend continuation**, not reversals.
---
### 🎯 Best Usage
* Intraday trading (**3m–15m**)
* Trending symbols: SPY, QQQ, META, NVDA, TSLA, AMD, ES/NQ futures
* Crypto momentum runs
* Swing: works well on **30m/1H** with confirmation
---
### ⚙️ Suggested Settings (Intraday)
* Volume ≥ **1.5–2.0×** Vol SMA
* ATR minimum: **0.30–0.50%** of price
* Base bars: **8–12**
* Confirm %: **0.7** (top/bottom 30% close)
* **VWAP alignment: ON**
* **Avoid lunchtime: ON**
---
### 📈 Risk Management (Important)
This tool **identifies structure**, not exits.
Common trade plan:
* **Stop**: just below retest low (bull) / above retest high (bear)
* **Target 1**: 1–1.5R
* **Target 2**: trail below structure
Avoid trading right into:
⚠️ Major economic events
⚠️ First few minutes of open if volatility extreme
---
### 🔔 Alerts Included
Add alerts:
* **Bullish BRB STRICT**
* **Bearish BRB STRICT**
Recommended: **Once Per Bar Close**
---
### ✅ Summary
This indicator helps traders:
✔ Stay aligned with the **dominant trend**
✔ Avoid early + fake breakouts
✔ Execute cleaner, more reliable continuation entries
Not meant for:
✘ Bottom/top picking
✘ Low-volume tickers
✘ Choppy range scalping
---
If you find this helpful — please consider:
⭐️ Rating & Adding to Favorites
💬 Commenting your results
🔁 Sharing with other disciplined traders
Trade with structure. Trade with confirmation. ✅📈⚡
---
Would you like me to also create:
✅ A **feature banner thumbnail**
✅ A **version tag** (v1.0 / v1.1 etc)
✅ A short **headline/summary line** for the top?
ICT Reversals identify when the "top is in " or the bottom is in ,
3 factors to detect if top or bottom is in based on ICT principals:
1. daily High and Daily low of the previous day - the market will reach that point and likely to reverse
2.diviation from Volume at top or bottom compared to the last X candles - default is 9.
3. detection of FVG on the last 4 candles to identify imbalance - stretched price aka distribution
after this the market will either consolidate and then reveres or consolidate and retrace before another leg up - remember retracement is 70% min so its enough to use also on retracement not just reversal.
IT ONLY WORKS ON 4 CHART ATM
Remember WAIT for the FVG to be touched on the bounce before entring !!
GL
LAST UPA FOR DA DAYWell been fing around most the day now, TBH this is showing results , Much respect to all along the journey , mess with the setting make them natural colors for you
Zarks 4H Range, 15M Triggers Pt2🕓 4-Hour Structure Dividers ⏰
📈 Vertical lines represent each 4-hour candle broken down into smaller execution timeframes — perfect for aligning entries across 15-minute, 5-minute, and 1-minute charts.
🧭 The lines remain true and synchronized with the 4-hour structure, ensuring timing accuracy:
⏱ 15-Minute: Lines appear at :45 of each corresponding hour
⚙️ 5-Minute: Lines appear at :55 of each corresponding hour
🔹 1-Minute: Lines appear at :59 of each corresponding hour
🎯 Use these precise vertical dividers to visualize higher-timeframe structure while executing on lower-timeframe setups — ideal for confluence traders combining HTF bias with LTF precision.
Opposing Candle V1Opposing Candle Indicator Summary:
This indicator detects engulfing candles (where the current candle's high is above the previous candle's high AND the low is below the previous candle's low) across multiple trading sessions.
Key Features:
Multi-timeframe detection - Works on any timeframe you set (default 15min)
Session filtering - Detects opposing candles during Q1-Q4 of four major sessions: Asia, London, NYAM, and NYPM
Visual representation - Draws colored boxes (green for bullish, red for bearish) with extension lines showing:
High line
Low line
Midline (dotted white)
Open line (black)
Customizable - Adjust box/line extensions, colors, line widths, and max number of candles displayed
Optional labels - Can show session names and timeframe on each detection
Status table - Displays current settings in top-right corner
Alerts - Notifies when new opposing candles are detected
What it does: Helps identify potential support/resistance zones created by strong engulfing price action during key trading hours, with the open price highlighted as an additional reference level.
Displacement + Liquidity Levels//@version=5
indicator("Displacement + Liquidity Levels", overlay=true, max_lines_count=500)
// INPUTS
swingLeft = input.int(5, "Swing Left")
swingRight = input.int(5, "Swing Right")
rangeLen = input.int(10, "Range Lookback")
// SWINGS
relevantHigh = ta.pivothigh(high, swingLeft, swingRight)
relevantLow = ta.pivotlow(low, swingLeft, swingRight)
// ARRAYS
var line highLines = array.new_line()
var line lowLines = array.new_line()
// LIQUIDITY SWEEPS
sweepHigh = not na(relevantHigh) and high > relevantHigh and close < relevantHigh
sweepLow = not na(relevantLow) and low < relevantLow and close > relevantLow
// DISPLACEMENT
bodySize = math.abs(close - open)
candleRange = high - low
avgRange = ta.sma(candleRange, rangeLen)
displacementUp = close > open and bodySize > candleRange*0.6 and candleRange > avgRange
displacementDown = open > close and bodySize > candleRange*0.6 and candleRange > avgRange
// SIGNALS
bullishSignal = sweepLow and displacementUp
bearishSignal = sweepHigh and displacementDown
plotshape(bullishSignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.large, text="LONG")
plotshape(bearishSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.large, text="SHORT")
// NEUE LINIEN
if not na(relevantHigh)
l = line.new(bar_index, relevantHigh, bar_index + 500, relevantHigh, extend=extend.right, color=color.red, width=2)
array.push(highLines, l)
if not na(relevantLow)
l = line.new(bar_index, relevantLow, bar_index + 500, relevantLow, extend=extend.right, color=color.green, width=2)
array.push(lowLines, l)
// LINIEN LÖSCHEN, WENN GETOUCHT
for i = array.size(highLines)-1 to 0 by -1
l = array.get(highLines, i)
if high >= line.get_price(l, bar_index)
line.delete(l)
array.remove(highLines, i)
for i = array.size(lowLines)-1 to 0 by -1
l = array.get(lowLines, i)
if low <= line.get_price(l, bar_index)
line.delete(l)
array.remove(lowLines, i)
// High/Low-Relevanz sofort
liqHigh = ta.highest(high, 3)
liqLow = ta.lowest(low, 3)
if high == liqHigh
line.new(bar_index, high, bar_index + 500, high, extend=extend.right, color=color.red, width=2)
if low == liqLow
line.new(bar_index, low, bar_index + 500, low, extend=extend.right, color=color.green, width=2)
Displacement + Liquidity Levels//@version=5
indicator("Displacement + Liquidity Levels", overlay=true, max_lines_count=500)
// INPUTS
swingLeft = input.int(5, "Swing Left")
swingRight = input.int(5, "Swing Right")
rangeLen = input.int(10, "Range Lookback")
// SWINGS
relevantHigh = ta.pivothigh(high, swingLeft, swingRight)
relevantLow = ta.pivotlow(low, swingLeft, swingRight)
// ARRAYS
var line highLines = array.new_line()
var line lowLines = array.new_line()
// LIQUIDITY SWEEPS
sweepHigh = not na(relevantHigh) and high > relevantHigh and close < relevantHigh
sweepLow = not na(relevantLow) and low < relevantLow and close > relevantLow
// DISPLACEMENT
bodySize = math.abs(close - open)
candleRange = high - low
avgRange = ta.sma(candleRange, rangeLen)
displacementUp = close > open and bodySize > candleRange*0.6 and candleRange > avgRange
displacementDown = open > close and bodySize > candleRange*0.6 and candleRange > avgRange
// SIGNALS
bullishSignal = sweepLow and displacementUp
bearishSignal = sweepHigh and displacementDown
plotshape(bullishSignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.large, text="LONG")
plotshape(bearishSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.large, text="SHORT")
// NEUE LINIEN
if not na(relevantHigh)
l = line.new(bar_index, relevantHigh, bar_index + 500, relevantHigh, extend=extend.right, color=color.red, width=2)
array.push(highLines, l)
if not na(relevantLow)
l = line.new(bar_index, relevantLow, bar_index + 500, relevantLow, extend=extend.right, color=color.green, width=2)
array.push(lowLines, l)
// LINIEN LÖSCHEN, WENN GETOUCHT
for i = array.size(highLines)-1 to 0 by -1
l = array.get(highLines, i)
if high >= line.get_price(l, bar_index)
line.delete(l)
array.remove(highLines, i)
for i = array.size(lowLines)-1 to 0 by -1
l = array.get(lowLines, i)
if low <= line.get_price(l, bar_index)
line.delete(l)
array.remove(lowLines, i)
Liquidity & SMT Detector//@version=5
indicator("Liquidity & SMT Detector", overlay=true, max_lines_count=500, max_labels_count=500)
// ============================================
// INPUT SETTINGS
// ============================================
// Group 1: Liquidity Detection
swing_length = input.int(10, "Swing Length", minval=3, maxval=50, group="Liquidity Detection")
line_color_high = input.color(color.red, "High Line Color", group="Liquidity Detection")
line_color_low = input.color(color.green, "Low Line Color", group="Liquidity Detection")
line_width = input.int(2, "Line Width", minval=1, maxval=5, group="Liquidity Detection")
show_labels = input.bool(true, "Show H/L Labels", group="Liquidity Detection")
// Group 2: Displacement Detection
enable_displacement = input.bool(true, "Enable Displacement Detection", group="Displacement")
displacement_multiplier = input.float(2.0, "Size Multiplier", minval=1.5, maxval=5.0, step=0.1, group="Displacement")
displacement_period = input.int(20, "Average Period", minval=10, maxval=50, group="Displacement")
displacement_color_bull = input.color(color.new(color.aqua, 70), "Bullish Color", group="Displacement")
displacement_color_bear = input.color(color.new(color.orange, 70), "Bearish Color", group="Displacement")
show_displacement_label = input.bool(true, "Show Labels", group="Displacement")
// Group 3: SMT Detection
enable_smt = input.bool(true, "Enable SMT Detection", group="SMT Divergence")
nq_symbol = input.string("NQ1!", "Nasdaq Symbol", group="SMT Divergence")
es_symbol = input.string("ES1!", "S&P500 Symbol", group="SMT Divergence")
smt_lookback = input.int(20, "Lookback Period", minval=5, maxval=100, group="SMT Divergence")
smt_line_color = input.color(color.yellow, "SMT Line Color", group="SMT Divergence")
smt_text_color = input.color(color.yellow, "SMT Text Color", group="SMT Divergence")
// ============================================
// ARRAYS FOR LINE/LABEL MANAGEMENT
// ============================================
var line high_lines = array.new_line()
var line low_lines = array.new_line()
var label high_labels = array.new_label()
var label low_labels = array.new_label()
var float high_levels = array.new_float()
var float low_levels = array.new_float()
// ============================================
// FUNCTION: DETECT SWING HIGHS
// ============================================
isSwingHigh(len) =>
highestBar = ta.highestbars(high, len * 2 + 1)
highestBar == -len
// ============================================
// FUNCTION: DETECT SWING LOWS
// ============================================
isSwingLow(len) =>
lowestBar = ta.lowestbars(low, len * 2 + 1)
lowestBar == -len
// ============================================
// SWING HIGH DETECTION & LINE DRAWING
// ============================================
if isSwingHigh(swing_length)
swing_high = high
new_line = line.new(bar_index - swing_length, swing_high, bar_index, swing_high, color=line_color_high, width=line_width, style=line.style_dashed)
array.push(high_lines, new_line)
array.push(high_levels, swing_high)
if show_labels
new_label = label.new(bar_index - swing_length, swing_high, "H", color=color.new(line_color_high, 80), textcolor=line_color_high, style=label.style_label_down, size=size.small)
array.push(high_labels, new_label)
// ============================================
// SWING LOW DETECTION & LINE DRAWING
// ============================================
if isSwingLow(swing_length)
swing_low = low
new_line = line.new(bar_index - swing_length, swing_low, bar_index, swing_low, color=line_color_low, width=line_width, style=line.style_dashed)
array.push(low_lines, new_line)
array.push(low_levels, swing_low)
if show_labels
new_label = label.new(bar_index - swing_length, swing_low, "L", color=color.new(line_color_low, 80), textcolor=line_color_low, style=label.style_label_up, size=size.small)
array.push(low_labels, new_label)
// ============================================
// UPDATE EXISTING LINES & CHECK FOR SWEEPS
// ============================================
if array.size(high_lines) > 0
for i = array.size(high_lines) - 1 to 0
current_line = array.get(high_lines, i)
current_level = array.get(high_levels, i)
if close > current_level
line.delete(current_line)
array.remove(high_lines, i)
array.remove(high_levels, i)
if show_labels and i < array.size(high_labels)
label.delete(array.get(high_labels, i))
array.remove(high_labels, i)
else
line.set_x2(current_line, bar_index)
if array.size(low_lines) > 0
for i = array.size(low_lines) - 1 to 0
current_line = array.get(low_lines, i)
current_level = array.get(low_levels, i)
if close < current_level
line.delete(current_line)
array.remove(low_lines, i)
array.remove(low_levels, i)
if show_labels and i < array.size(low_labels)
label.delete(array.get(low_labels, i))
array.remove(low_labels, i)
else
line.set_x2(current_line, bar_index)
// ============================================
// DISPLACEMENT CANDLE DETECTION
// ============================================
body_size = math.abs(close - open)
avg_body = ta.sma(math.abs(close - open), displacement_period)
is_displacement = enable_displacement and body_size > (avg_body * displacement_multiplier)
is_bullish = close > open
bgcolor(is_displacement ? (is_bullish ? displacement_color_bull : displacement_color_bear) : na)
if is_displacement and show_displacement_label
label.new(bar_index, is_bullish ? high : low, "D", color=color.new(is_bullish ? color.aqua : color.orange, 50), textcolor=is_bullish ? color.aqua : color.orange, style=is_bullish ? label.style_label_up : label.style_label_down, size=size.tiny)
// ============================================
// SMT DIVERGENCE DETECTION
// ============================================
current_symbol = syminfo.ticker
comparison_symbol = str.contains(current_symbol, "NQ") ? es_symbol : nq_symbol
comparison_high = request.security(comparison_symbol, timeframe.period, high, lookahead=barmerge.lookahead_off)
comparison_low = request.security(comparison_symbol, timeframe.period, low, lookahead=barmerge.lookahead_off)
var float prev_current_low = na
var float prev_comparison_low = na
var int prev_swing_bar = na
current_is_swing_low = isSwingLow(swing_length)
comparison_is_swing_low = ta.lowestbars(comparison_low, swing_length * 2 + 1) == -swing_length
if enable_smt and current_is_swing_low
current_swing_low = low
comparison_swing_low = comparison_low
if not na(prev_current_low) and not na(prev_comparison_low)
current_lower = current_swing_low < prev_current_low
comparison_lower = comparison_swing_low < prev_comparison_low
is_smt = (current_lower and not comparison_lower) or (not current_lower and comparison_lower)
if is_smt
smt_line = line.new(prev_swing_bar, prev_current_low, bar_index - swing_length, current_swing_low, color=smt_line_color, width=2, style=line.style_solid)
mid_bar = math.round((prev_swing_bar + bar_index - swing_length) / 2)
mid_price = (prev_current_low + current_swing_low) / 2
label.new(mid_bar, mid_price, "SMT", color=color.new(smt_line_color, 80), textcolor=smt_text_color, style=label.style_label_center, size=size.normal)
prev_current_low := current_swing_low
prev_comparison_low := comparison_swing_low
prev_swing_bar := bar_index - swing_length
// ============================================
// ALERTS
// ============================================
alertcondition(array.size(high_lines) < array.size(high_lines) , title="Liquidity Sweep High", message="High liquidity swept at {{close}}")
alertcondition(array.size(low_lines) < array.size(low_lines) , title="Liquidity Sweep Low", message="Low liquidity swept at {{close}}")
alertcondition(is_displacement, title="Displacement Candle", message="Displacement candle detected at {{close}}")
McRoulio (Monthly Anchored VWAPs)The McRoulio indicator is designed to provide a clear view of market value relative to the current and previous month's starting points. It must be used on intraday timeframes (like 1H, 4H, 15m) to function correctly.
All VWAP calculations use (O+H+L+C)/4 as the price source.
Here is what the indicator does:
⚪ Current Month VWAP (Thick White Line)
Anchored to the 1st (00:00) of the current month.
Includes 1.0 Standard Deviation bands.
Displays a "Mcwrap" label. 🔴 Last Month VWAP (Orange Line)
Anchored to the 1st (00:00) of the previous month.
This line is only visible for the duration of that previous month, allowing for historical reference. ⏳ Previous VWAP Level (Horizontal Orange Line)
This line shows the final, settled price of the previous month's VWAP.
It is only visible between the 27th of the month and the 3rd of the next month, highlighting a potential support/resistance zone during the "turn of the month."
Displays a "Mcwrap Mois dernier" label. Trolled par le gap & le mcwrap 😘
Renko ATR Trend + SMA Indicator by YCGH Capital🧭 Overview
The Renko ATR Trend + SMA Indicator is a trend-following tool designed for chart trading.
It combines Renko-style price movement logic (based on ATR) with a Simple Moving Average (SMA) filter to identify sustained bullish or bearish phases on any timeframe.
It plots a color-coded trend line directly on the price chart — green for bullish trends, red for bearish — and maintains a single active state (no repeated buy/sell signals) until the opposite condition appears.
⚙️ How It Works
1️⃣ Renko ATR Engine
Instead of using fixed box sizes like classic Renko charts, this indicator builds synthetic Renko movement based on ATR (Average True Range) of a chosen timeframe.
It pulls OHLC data from your selected Renko Source Timeframe (for example, 60-minute candles).
It calculates an ATR brick size — representing the minimum price move needed for a new Renko brick.
When price moves by at least one ATR in the opposite direction, it flips the trend.
This filters out small fluctuations and captures the underlying directional bias.
2️⃣ SMA Filter
A Simple Moving Average (SMA) acts as a trend confirmation filter.
Only when Renko direction aligns with the price relative to the SMA, a trend signal activates.
BUY → Renko uptrend + price above SMA
SELL → Renko downtrend + price below SMA
3️⃣ Stateful Signal Logic
Unlike typical indicators that spam multiple buy/sell shapes:
This version holds one persistent signal (Buy or Sell)
The state continues until an opposite signal is confirmed
No “continuation” arrows — clean and minimal trend visualization
🎨 Visuals
Element Meaning
🟩 Green Renko Line Active Bullish Trend
🟥 Red Renko Line Active Bearish Trend
⚪ Gray Line Neutral / Waiting phase
🟡 Yellow Line SMA (trend filter)
📍 Label (Buy Active / Sell Active) Displays the current market bias
🔧 Inputs
Input Description
Renko Source Timeframe The timeframe from which Renko data is calculated (e.g., 60 = 1h candles).
ATR Period Determines brick size sensitivity (lower = more responsive, higher = smoother).
SMA Length Moving Average length used as a directional filter.
💡 How Traders Use It
Trend Confirmation:
Use green/red Renko line to stay aligned with the dominant market move.
Entry Timing:
Enter trades when a new Renko direction is confirmed along with SMA alignment.
Exit or Reverse:
Exit long when a red line (Sell Active) appears, and vice versa.
Combine with Price Action:
Add support/resistance or volume analysis for confirmation.
ATR Money Line Bands V2The "ATR Money Line Bands V2" is a clever TradingView overlay designed for trend identification with volatility-aware bands, evolving from basic ATR envelopes.
Reasoning Behind Construction: The core idea is to blend a smoothed trend line with dynamic volatility bands for reliable signals in varying markets. The "Money Line" uses linear regression (ta.linreg) on closes over a length (default 16) instead of a moving average, as it fits data via least-squares for a cleaner, forward-projected trend without lag artifacts. ATR (default 12-period) powers the bands because it measures true range volatility better than std dev in gappy assets like crypto/stocks—bands offset from the Money Line by ATR * multiplier (default 1.5). A dynamic multiplier (boosts by ~33% on spikes > prior ATR * 1.3) prevents tight bands from false breakouts during surges. Trend detection checks slope against an ATR-scaled tolerance (default 0.15) to ignore noise, labeling bull/bear/neutral—avoiding whipsaws in flats.
Properties: It's an overlay with a colored Money Line (green bull, red bear, yellow neutral) and invisible bands (toggle to show gray lines) filled semi-transparently matching trend for visual pop. Dynamic adaptation makes bands widen/contract intelligently. An info table (positionable, e.g., top_right) displays real-time values: Money Line, bands, ATR, trend—great for quick scans. Limits history (2000 bars) and labels (500) for efficiency.
Tips for Usage: Apply to any timeframe/asset; defaults suit medium-term (e.g., daily stocks). Watch color flips: green for longs (enter on pullbacks to lower band), red for shorts (vice versa), yellow to sit out. Use bands as S/R—breakouts signal momentum, squeezes impending vol. Tweak length for sensitivity (shorter for intraday), multiplier for width (higher for trends), tolerance for fewer neutrals. Pair with volume/RSI for confirmation; backtest to optimize. In choppy markets, disable dynamic mult to avoid over-expansion. Overall, it's adaptive and visual—helps trend-follow without overcomplicating.
FVG SizeFVG Size Indicator – Description
Overview
This Pine Script v5 indicator detects and visualizes Fair Value Gaps (FVGs) on the chart. It draws colored boxes for FVGs, center lines (CE), and displays the size of each FVG as a label. The indicator is designed for manual analysis, helping traders identify potential price imbalances.
Key Features
FVG Detection:
Identifies bullish and bearish FVGs based on price structure.
Draws colored boxes for FVGs and dotted center lines (CE).
FVG Size Display:
Shows the size of each FVG as a label inside the box.
Customizable minimum size threshold to filter out smaller FVGs.
Dynamic Adjustments:
Extends FVG boxes to the right as new bars form.
Removes FVGs that are filled (mitigated) by price action.
Customizable Settings:
Adjustable colors, text size, and display options.
Settings and Translations
Here are the German settings with their English translations:
FVG Settings
Long FVG Farbe → Long FVG Color (Color for bullish FVG boxes)
Short FVG Farbe → Short FVG Color (Color for bearish FVG boxes)
CE Farbe → CE Color (Color for the center line)
Tage Rückblick → Lookback Days (Number of days to look back for FVGs)
Lösche gefüllte Boxen & Linien → Delete Filled Boxes & Lines (Removes FVGs that have been filled by price)
FVG Display
FVG Größe anzeigen → Show FVG Size (Displays the size of each FVG as a label)
Text → Text Size (Size of the FVG size label text)
Mindestgröße → Minimum Size (Minimum FVG size to display, filtering out smaller FVGs)
How It Works
FVG Detection Logic:
A bullish FVG is detected if the high of the 3rd bar is lower than the low of the 1st bar.
A bearish FVG is detected if the low of the 3rd bar is higher than the high of the 1st bar.
Drawing FVGs:
The indicator draws a box between the high/low of the 1st and 3rd bars.
A center line (CE) is drawn at the midpoint of the FVG.
The size of the FVG is displayed as a label inside the box.
Dynamic Adjustments:
FVG boxes are extended to the right as new bars form.
If the price fills the FVG, the box and line are removed (depending on settings).
Mitigation Logic:
If the price closes beyond the FVG boundaries, the FVG is considered "filled" and removed.
ASTER Key Levels & Alerts (Improved)TradingView Script Description
Title: ASTER Key Levels & Alerts (Improved)
Description:
Enhance your trading strategy with the "ASTER Key Levels & Alerts" indicator, designed for precision and decision-making on the Aster chart (e.g., ASTS). This Pine Script v6 tool overlays customizable key levels and zones to identify optimal entry, exit, and stop-loss points, complete with real-time alerts.Key Features:
Customizable Levels: Adjust add zones (Light & Main), breakout, stop, and take-profit (TP1-TP3
OG Signal Indicator - Single Line Plotshapethis signal help to identify strong buy and sell signal as price over bought and over sold. by sigma s lohar
Relative Volume (Multi-TF, D, W, M)Relative Volume (Multi-TF, Candle-Matched Colors)
This indicator measures Relative Volume (RVOL) — the ratio of current volume to average historical volume — across any higher timeframe (Daily, Weekly, or Monthly) and displays it as color-coded columns that match the candle colors of the chart you’re viewing.
RVOL reveals how active today’s market participation is compared to its typical rhythm.
RVOL = 1.0 → normal volume
>1.5 → rising interest
>2.0–3.0 → strong institutional participation
>5.0 → climax or exhaustion levels
Features
Works on any chart timeframe while computing RVOL from your chosen higher timeframe (e.g., show Daily RVOL while trading on a 5-minute chart).
Column colors automatically match your chart’s candle colors (green/red/neutral).
Adjustable lookback period (len) and selectable source timeframe (D, W, or M).
Pre-drawn horizontal guide levels at 1.0, 1.2, 1.5, 2, 3, and 5 for quick interpretation.
Compatible with all chart types, including Heikin Ashi or custom color schemes.
Typical Use
Swing trading:
Look for quiet bases where RVOL stays 0.4–0.9, then expansion ≥2 on breakout days.
Confirm follow-through when green days keep RVOL ≥1.2–1.5 and red pullbacks stay below 1.0.
Day trading:
Watch intraday RVOL (on 1–5m charts) for bursts ≥2 that sustain for several bars — this signals crowd engagement and valid momentum.
Interpretation Summary
RVOL Value Meaning Typical Action
0.4–0.9 Quiet base / low interest Watch for setup
1.0 Normal activity Neutral
1.2–1.5 Valid participation Early confirmation
2–3 Strong expansion Momentum / breakout
≥5 Climax / exhaustion Take profits or avoid new entries
Author’s note:
RVOL isn’t directional; it tells how many players are active, not who’s winning. Combine it with structure (levels, VWAP, or trend) to see when the market crowd truly commits.
나의 strategy//@version=6
strategy("Jimb0ws Strategy + All Bubble Zones + Golden Candles + Limited Signals", overlay=true, calc_on_every_tick=true, max_bars_back=5000)
// ─── INPUTS ─────────────────────────────────────────────────────────────────
pipBodyTol = input.float(0, title="Pip Tolerance for Body Touch", step=0.0001)
pipWickTol = input.float(0.002, title="Pip Tolerance for Wick Touch", step=0.0001)
maxBodyDrive = input.float(0, title="Max Drive from EMA for Body", step=0.0001)
maxWickDrive = input.float(0.002, title="Max Drive from EMA for Wick", step=0.0001)
fractalSizeOpt = input.string("small", title="Fractal Size", options= )
minBodySize = input.float(0, title="Min Body Size for Golden Candle", step=0.0001)
longOffsetPips = input.int(25, title="Long Label Offset (pips)", minval=0)
shortOffsetPips = input.int(25, title="Short Label Offset (pips)", minval=0)
consolOffsetPips = input.int(25, title="Consolidation Label Offset (pips)", minval=0)
longSignType = input.string("Label Down", title="Long Bubble Sign Type", options= )
shortSignType = input.string("Label Up", title="Short Bubble Sign Type", options= )
consolSignType = input.string("Label Down", title="Consolidation Bubble Sign Type", options= )
enable1hEmaFilter = input.bool(true, title="Disable Signals beyond 1H EMA50")
showZones = input.bool(true, title="Show Bubble Zones")
showSigns = input.bool(true, title="Show Bubble Signs")
maxSignalsPerBubble = input.int(3, title="Max Signals Per Bubble", minval=1)
// Toggle for session filter
enableSessionFilter = input.bool(true, title="Enable Active Trading Session Filter")
sessionInput = input.session("0100-1900", title="Active Trading Session")
tzInput = input.string("Europe/London", title="Session Timezone",
options= )
actualTZ = tzInput == "Exchange" ? syminfo.timezone : tzInput
infoOffsetPips = input.int(5, title="Info Line Offset Above Price (pips)", minval=0)
warnOffsetPips = input.int(10, title="Warning Label Offset Above Infobar (pips)", minval=0)
show1HInfo = input.bool(true, title="Show 1H Bubble Info")
bufferLimit = 5000 - 1
enableProxFilter = input.bool(true, title="Disable Signals Near 1H EMA50")
proxRangePips = input.int(10, title="Proximity Range (pips)", minval=0)
enableWickFilter = input.bool(true, title="Filter Golden-Candle Wick Overdrive")
wickOverdrivePips = input.int(0, title="Wick Overdrive Range (pips)", minval=0)
// turn Robin candles on/off
enableRobin = input.bool(true, title="Enable Robin Candles")
// ATR panel attached to 4H info
showPrevDayATR = input.bool(true, title="Show Previous Day ATR Panel")
atrLenPrevDay = input.int(14, title="ATR Length (Daily)", minval=1)
atrPanelOffsetPips = input.int(3, title="ATR Panel Offset Above 4H Info (pips)", minval=0)
// ─── STRATEGY TRADES (EMA200 SL, RR=2 TP) ───────────────────────────────────
enableAutoTrades = input.bool(true, title="Enable Strategy Entries/Exits")
takeProfitRR = input.float(2.0, title="TP Risk:Reward (x)", step=0.1, minval=0.1)
// ─── SL/TP info label on signals ─────────────────────────────────────────────
showSLTPPanel = input.bool(true, title="Show SL/TP Info Above Signals")
sltpOffsetPips = input.int(4, title="SL/TP Label Offset (pips)", minval=0)
// Previous Day ATR (D1, lookahead OFF) -> lock to yesterday with
dailyATR = request.security(syminfo.tickerid, "D", ta.atr(atrLenPrevDay),
lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off)
prevDayATR = dailyATR
// Convert to pips (FX: pip ≈ mintick*10)
pipValueFX = syminfo.mintick * 10.0
prevATR_pips_1d = na(prevDayATR) ? na : math.round((prevDayATR / pipValueFX) * 10.0) / 10.0
// Create table once
var table atrPanel = na
if barstate.isfirst and na(atrPanel)
// columns=1, rows=2 (title row + value row)
atrPanel := table.new(position.top_right, 1, 2, border_width=1,
frame_color=color.new(color.gray, 0), border_color=color.new(color.gray, 0))
// Update cells each last bar
if barstate.islast and not na(atrPanel)
if showPrevDayATR
titleTxt = "Prev Day ATR (" + str.tostring(atrLenPrevDay) + ")"
valTxt = na(prevDayATR) ? "n/a"
: str.tostring(prevATR_pips_1d) + " pips (" + str.tostring(prevDayATR, format.mintick) + ")"
table.cell(atrPanel, 0, 0, titleTxt, text_color=color.white, bgcolor=color.new(color.blue, 25))
table.cell(atrPanel, 0, 1, valTxt, text_color=color.white, bgcolor=color.new(color.black, 0))
else
// Hide panel by writing empty strings
table.cell(atrPanel, 0, 0, "")
table.cell(atrPanel, 0, 1, "")
// Visuals for orders
showSLTP = input.bool(true, title="Show SL/TP Lines & Labels")
// ─── EMA CALCULATIONS & PLOTTING ──────────────────────────────────────────────
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)
ema50_1h = request.security(syminfo.tickerid, "60", ta.ema(close, 50), lookahead=barmerge.lookahead_on)
plot(ema20, color=color.white, linewidth=4, title="EMA20")
plot(ema50, color=color.yellow, linewidth=4, title="EMA50")
plot(ema100, color=color.blue, linewidth=4, title="EMA100")
plot(ema200, color=color.purple, linewidth=6, title="EMA200") // ← and this
plot(ema50_1h, title="EMA50 (1H)", color=color.yellow, linewidth=2)
// pip-unit helper
pipUnit1h = syminfo.mintick * proxRangePips * 10
upperBand1h = ema50_1h + pipUnit1h
lowerBand1h = ema50_1h - pipUnit1h
// draw top/bottom lines in one-liner plots, then fill the gap
p_top = plot(enableProxFilter ? upperBand1h : na, title="Prox Zone Top", color=color.new(color.yellow,90), linewidth=1)
p_bottom = plot(enableProxFilter ? lowerBand1h : na, title="Prox Zone Bottom", color=color.new(color.yellow,90), linewidth=1)
fill(p_top, p_bottom, color.new(color.yellow,90))
// ─── BUBBLE CONDITIONS & ZONES ───────────────────────────────────────────────
longBub = ema20 > ema50 and ema50 > ema100
shortBub = ema20 < ema50 and ema50 < ema100
consolOn = not longBub and not shortBub
longCol = color.new(color.green, 85)
shortCol = color.new(color.red, 85)
consCol = color.new(color.orange, 85)
bgcolor(showZones ? (longBub ? longCol : shortBub ? shortCol : consCol) : na)
// convert pips to price‐units
wickOverUnit = syminfo.mintick * wickOverdrivePips * 10
// detect when the wick “pierces” EMA50 by more than that amount
overdriveLong = low < ema50 - wickOverUnit // long bubble: wick dipped below EMA50
overdriveShort = high > ema50 + wickOverUnit // short bubble: wick rose above EMA50
// ─── GOLDEN-CANDLE LOGIC & COLORING ──────────────────────────────────────────
trendLong = longBub
trendShort = shortBub
bodySize = math.abs(close - open)
hasBigBody = bodySize >= minBodySize
bodyLow = math.min(open, close)
bodyHigh = math.max(open, close)
wickLow = low
wickHigh = high
bOK20_L = bodyLow <= ema20 + pipBodyTol and bodyLow >= ema20 - maxBodyDrive and close > ema20
bOK50_L = bodyLow <= ema50 + pipBodyTol and bodyLow >= ema50 - maxBodyDrive and close > ema50
wOK20_L = wickLow <= ema20 + pipWickTol and wickLow >= ema20 - maxWickDrive and close > ema20
wOK50_L = wickLow <= ema50 + pipWickTol and wickLow >= ema50 - maxWickDrive and close > ema50
isGoldenLong = trendLong and hasBigBody and (bOK20_L or bOK50_L or wOK20_L or wOK50_L)
bOK20_S = bodyHigh >= ema20 - pipBodyTol and bodyHigh <= ema20 + maxBodyDrive and close < ema20
bOK50_S = bodyHigh >= ema50 - pipBodyTol and bodyHigh <= ema50 + maxBodyDrive and close < ema50
wOK20_S = wickHigh >= ema20 - pipWickTol and wickHigh <= ema20 + maxWickDrive and close < ema20
wOK50_S = wickHigh >= ema50 - pipWickTol and wickHigh <= ema50 + maxWickDrive and close < ema50
isGoldenShort= trendShort and hasBigBody and (bOK20_S or bOK50_S or wOK20_S or wOK50_S)
// ─── WICK-OVERDRIVE VETO ────────────────────────────────────────────────────
if enableWickFilter
// veto any golden on which the wick over-drove the EMA50
isGoldenLong := isGoldenLong and not overdriveLong
isGoldenShort := isGoldenShort and not overdriveShort
barcolor((isGoldenLong or isGoldenShort) ? color.new(#FFD700, 0) : na)
// ─── ROBIN CANDLES ──────────────────────────────────────────────────────────
goldShort1 = isGoldenShort
goldLong1 = isGoldenLong
goldLow1 = math.min(open , close )
goldHigh1 = math.max(open , close )
robinShort = shortBub and goldShort1 and math.min(open, close) < goldLow1
robinLong = longBub and goldLong1 and math.max(open, close) > goldHigh1
barcolor(enableRobin and (robinShort or robinLong) ? color.purple : na)
// ─── FRACTALS ─────────────────────────────────────────────────────────────────
pL = ta.pivotlow(low, 2, 2)
pH = ta.pivothigh(high, 2, 2)
plotshape(not shortBub and not consolOn and not na(pL) and fractalSizeOpt == "tiny",
style=shape.triangleup, location=location.belowbar, offset=-2, color=color.green, size=size.tiny)
plotshape(not shortBub and not consolOn and not na(pL) and fractalSizeOpt == "small",
style=shape.triangleup, location=location.belowbar, offset=-2, color=color.green, size=size.small)
plotshape(not shortBub and not consolOn and not na(pL) and fractalSizeOpt == "normal",
style=shape.triangleup, location=location.belowbar, offset=-2, color=color.green, size=size.normal)
plotshape(not shortBub and not consolOn and not na(pL) and fractalSizeOpt == "large",
style=shape.triangleup, location=location.belowbar, offset=-2, color=color.green, size=size.large)
plotshape(not longBub and not consolOn and not na(pH) and fractalSizeOpt == "tiny",
style=shape.triangledown, location=location.abovebar, offset=-2, color=color.red, size=size.tiny)
plotshape(not longBub and not consolOn and not na(pH) and fractalSizeOpt == "small",
style=shape.triangledown, location=location.abovebar, offset=-2, color=color.red, size=size.small)
plotshape(not longBub and not consolOn and not na(pH) and fractalSizeOpt == "normal",
style=shape.triangledown, location=location.abovebar, offset=-2, color=color.red, size=size.normal)
plotshape(not longBub and not consolOn and not na(pH) and fractalSizeOpt == "large",
style=shape.triangledown, location=location.abovebar, offset=-2, color=color.red, size=size.large)
// ─── BUY/SELL SIGNALS & LIMIT ─────────────────────────────────────────────────
var int buyCount = 0
var int sellCount = 0
if longBub and not longBub
buyCount := 0
if shortBub and not shortBub
sellCount := 0
goldLong2 = isGoldenLong
goldShort2 = isGoldenShort
roofCheck = math.max(open , close ) >= math.max(open , close )
floorCheck = math.min(open , close ) <= math.min(open , close )
buySignal = goldLong2 and not na(pL) and roofCheck
sellSignal = goldShort2 and not na(pH) and floorCheck
// Original: inSession = not na(time(timeframe.period, sessionInput, actualTZ))
inSessionRaw = not na(time(timeframe.period, sessionInput, actualTZ))
sessionOK = enableSessionFilter ? inSessionRaw : true
// Apply 1H EMA50 filter
disableBy1h = enable1hEmaFilter and ((request.security(syminfo.tickerid, "60", ema20 ema50_1h) or (request.security(syminfo.tickerid, "60", ema20>ema50 and ema50>ema100) and close < ema50_1h))
// ─── PROXIMITY VETO ────────────────────────────────────────────────
near1hZone = enableProxFilter and close >= lowerBand1h and close <= upperBand1h
validBuy = buySignal and sessionOK and buyCount < maxSignalsPerBubble and not disableBy1h and not near1hZone
validSell = sellSignal and sessionOK and sellCount < maxSignalsPerBubble and not disableBy1h and not near1hZone
plotshape(validBuy, title="BUY", style=shape.labelup, location=location.belowbar,
color=color.green, text="BUY $", textcolor=color.white, size=size.large)
plotshape(validSell, title="SELL", style=shape.labeldown, location=location.abovebar,
color=color.red, text="SELL $", textcolor=color.white, size=size.large)
if validBuy
buyCount += 1
if validSell
sellCount += 1
// ─── 4H BUBBLE INFO LINE ──────────────────────────────────────────────────────
var line infoLine4h = na
var label infoLbl4h = na
var label atrPrevLbl = na // ATR label handle
var string bubble4hType = na
var int bubble4hStartTime = na
var int bubble4hStartIdx = na
time4h = request.security(syminfo.tickerid, "240", time, lookahead=barmerge.lookahead_on)
ema20_4h = request.security(syminfo.tickerid, "240", ta.ema(close, 20), lookahead=barmerge.lookahead_on)
ema50_4h = request.security(syminfo.tickerid, "240", ta.ema(close, 50), lookahead=barmerge.lookahead_on)
ema100_4h = request.security(syminfo.tickerid, "240", ta.ema(close,100), lookahead=barmerge.lookahead_on)
long4h = ema20_4h > ema50_4h and ema50_4h > ema100_4h
short4h = ema20_4h < ema50_4h and ema50_4h < ema100_4h
cons4h = not long4h and not short4h
if long4h and not long4h
bubble4hType := "LONG"
bubble4hStartTime := time4h
bubble4hStartIdx := bar_index
else if short4h and not short4h
bubble4hType := "SHORT"
bubble4hStartTime := time4h
bubble4hStartIdx := bar_index
else if cons4h and not cons4h
bubble4hType := "CONS"
bubble4hStartTime := time4h
bubble4hStartIdx := bar_index
active4h = ((bubble4hType=="LONG" and long4h) or (bubble4hType=="SHORT" and short4h) or (bubble4hType=="CONS" and cons4h)) and not na(bubble4hStartTime)
if active4h
durH4 = math.floor((time - bubble4hStartTime) / 3600000)
ts4 = str.format("{0,date,yyyy-MM-dd} {0,time,HH:mm}", bubble4hStartTime)
txt4 = "4H " + bubble4hType + " Bubble since " + ts4 + " Dur: " + str.tostring(durH4) + "h"
col4 = bubble4hType=="LONG" ? color.green : bubble4hType=="SHORT" ? color.red : color.orange
pipUnit4 = syminfo.mintick * 10
infoPrice4 = high + (infoOffsetPips + warnOffsetPips + 5) * pipUnit4
xStart4 = math.max(bubble4hStartIdx, bar_index - bufferLimit)
if na(infoLine4h)
infoLine4h := line.new(xStart4, infoPrice4, bar_index, infoPrice4, extend=extend.none, color=col4, width=2)
else
line.set_xy1(infoLine4h, xStart4, infoPrice4)
line.set_xy2(infoLine4h, bar_index, infoPrice4)
line.set_color(infoLine4h, col4)
if na(infoLbl4h)
infoLbl4h := label.new(bar_index, infoPrice4, txt4, xloc.bar_index, yloc.price, col4, label.style_label_left, color.white, size.small)
else
label.set_xy(infoLbl4h, bar_index, infoPrice4)
label.set_text(infoLbl4h, txt4)
label.set_color(infoLbl4h, col4)
// Prev Day ATR label just above the 4H info panel
if showPrevDayATR
atrValTxt = na(prevDayATR) ? "n/a" : str.tostring(prevATR_pips_1d) + " pips (" + str.tostring(prevDayATR, format.mintick) + ")"
atrTxt = "Prev Day ATR (" + str.tostring(atrLenPrevDay) + ") " + atrValTxt
atrY = infoPrice4 + pipUnit4 * atrPanelOffsetPips
if na(atrPrevLbl)
atrPrevLbl := label.new(bar_index, atrY, atrTxt, xloc.bar_index, yloc.price, color.new(color.blue, 25), label.style_label_left, color.white, size.small)
else
label.set_xy(atrPrevLbl, bar_index, atrY)
label.set_text(atrPrevLbl, atrTxt)
label.set_color(atrPrevLbl, color.new(color.blue, 25))
else
if not na(atrPrevLbl)
label.delete(atrPrevLbl)
atrPrevLbl := na
else
// Cleanup when 4H panel is not active
if not na(infoLine4h)
line.delete(infoLine4h)
infoLine4h := na
if not na(infoLbl4h)
label.delete(infoLbl4h)
infoLbl4h := na
bubble4hType := na
if not na(atrPrevLbl)
label.delete(atrPrevLbl)
atrPrevLbl := na
// ─── 1H BUBBLE INFO & WARNING PANEL ─────────────────────────────────────────
var line infoLine1h = na
var label infoLbl1h = na
var label warnLbl1h = na
var string bubble1hType = na
var int bubble1hStartTime = na
var int bubble1hStartIdx = na
var float pipUnit = na
var color col = na
var int xStart = na
var float infoPrice = na
var string txt = ""
// 1H trend state (kept same logic as your original)
long1h = request.security(syminfo.tickerid, "60", ema20>ema50 and ema50>ema100, lookahead=barmerge.lookahead_on)
short1h = request.security(syminfo.tickerid, "60", ema20 ema50_1h
warnY = infoPrice1h + warnOffsetPips * pipUnit1h
if na(warnLbl1h)
warnLbl1h := label.new(bar_index, warnY, "Potential Consolidation Warning",
xloc.bar_index, yloc.price, color.new(color.yellow,0),
label.style_label_up, color.black, size.small)
else
label.set_xy(warnLbl1h, bar_index, warnY)
label.set_text(warnLbl1h, "Potential Consolidation Warning")
else
if not na(warnLbl1h)
label.delete(warnLbl1h)
warnLbl1h := na
else
if not na(infoLine1h)
line.delete(infoLine1h)
infoLine1h := na
if not na(infoLbl1h)
label.delete(infoLbl1h)
infoLbl1h := na
if not na(warnLbl1h)
label.delete(warnLbl1h)
warnLbl1h := na
bubble1hType := na
// ─── ALERTS ─────────────────────────────────────────────────────────────────
alertcondition(validBuy, title="Jimb0ws Strategy – BUY", message="🔥 BUY signal on {{ticker}} at {{close}}")
alertcondition(validSell, title="Jimb0ws Strategy – SELL", message="🔻 SELL signal on {{ticker}} at {{close}}")
if validBuy
alert("🔥 BUY signal on " + syminfo.ticker + " at " + str.tostring(close), alert.freq_once_per_bar_close)
if validSell
alert("🔻 SELL signal on " + syminfo.ticker + " at " + str.tostring(close), alert.freq_once_per_bar_close)
// ─── SL/TP drawing handles (globals) ────────────────────────────────────────
var line slLine = na
var line tpLine = na
var label slLabel = na
var label tpLabel = na
var float slPrice = na
var float tpPrice = na
// Working vars so they exist on all bars
var float longEntry = na
var float longSL = na
var float longTP = na
var float riskL = na
var float shortEntry = na
var float shortSL = na
var float shortTP = na
var float riskS = na
// last SL/TP info label so we can replace it each time
var label sltpInfoLbl = na
// ─── Draw SL/TP info label exactly when a signal fires ──────────────────────
if showSLTPPanel and (validBuy or validSell)
// delete prior info label
if not na(sltpInfoLbl)
label.delete(sltpInfoLbl)
float pipUnit = syminfo.mintick * 10.0
float yAbove = high + sltpOffsetPips * pipUnit
// Entry is the close of the signal bar
float entry = close
// Choose SL by your rule:
// - LONG: if ema200 > ema100 -> SL = ema100, else SL = ema200
// - SHORT: if ema200 < ema100 -> SL = ema100, else SL = ema200
bool isLong = validBuy
float sl = isLong ? (ema200 > ema100 ? ema100 : ema200)
: (ema200 < ema100 ? ema100 : ema200)
// Compute TP using RR; guard for bad risk
float rr = takeProfitRR // your RR input (e.g., 2.0)
float risk = isLong ? (entry - sl) : (sl - entry)
float tp = na
if risk > syminfo.mintick
tp := isLong ? (entry + rr * risk) : (entry - rr * risk)
// Build label text (mintick formatting)
string slTxt = "SL " + str.tostring(sl, format.mintick)
string tpTxt = na(tp) ? "TP n/a" : "TP " + str.tostring(tp, format.mintick)
string txt = slTxt + " " + tpTxt
// Color by side and draw
color bgCol = isLong ? color.new(color.green, 10) : color.new(color.red, 10)
sltpInfoLbl := label.new(bar_index, yAbove, txt,
xloc.bar_index, yloc.price,
bgCol, label.style_label_left, color.white, size.small)
// ─── ORDERS: dynamic SL (EMA100 vs EMA200), TP = RR * risk + draw SL/TP ─────
if enableAutoTrades and barstate.isconfirmed and not na(ema100) and not na(ema200)
// LONGS — if EMA200 > EMA100 ⇒ SL = EMA100; else ⇒ SL = EMA200
if validBuy and strategy.position_size <= 0
longEntry := close
longSL := ema200 > ema100 ? ema100 : ema200
if longSL < longEntry - syminfo.mintick
riskL := longEntry - longSL
longTP := longEntry + takeProfitRR * riskL
if strategy.position_size < 0
strategy.close("Short", comment="Flip→Long")
strategy.entry("Long", strategy.long)
strategy.exit("Long-EXIT", from_entry="Long", stop=longSL, limit=longTP)
// store & draw
slPrice := longSL
tpPrice := longTP
if showSLTP
if not na(slLine)
line.delete(slLine)
if not na(tpLine)
line.delete(tpLine)
if not na(slLabel)
label.delete(slLabel)
if not na(tpLabel)
label.delete(tpLabel)
// lines
slLine := line.new(bar_index, slPrice, bar_index + 1, slPrice, extend=extend.right, color=color.red, width=2)
tpLine := line.new(bar_index, tpPrice, bar_index + 1, tpPrice, extend=extend.right, color=color.green, width=2)
// labels with exact prices
slLabel := label.new(bar_index + 1, slPrice, "SL " + str.tostring(slPrice, format.mintick), xloc.bar_index, yloc.price, color.new(color.red, 10), label.style_label_right, color.white, size.small)
tpLabel := label.new(bar_index + 1, tpPrice, "TP " + str.tostring(tpPrice, format.mintick), xloc.bar_index, yloc.price, color.new(color.green, 10), label.style_label_right, color.white, size.small)
// SHORTS — if EMA200 < EMA100 ⇒ SL = EMA100; else ⇒ SL = EMA200
if validSell and strategy.position_size >= 0
shortEntry := close
shortSL := ema200 < ema100 ? ema100 : ema200
if shortSL > shortEntry + syminfo.mintick
riskS := shortSL - shortEntry
shortTP := shortEntry - takeProfitRR * riskS
if strategy.position_size > 0
strategy.close("Long", comment="Flip→Short")
strategy.entry("Short", strategy.short)
strategy.exit("Short-EXIT", from_entry="Short", stop=shortSL, limit=shortTP)
// store & draw
slPrice := shortSL
tpPrice := shortTP
if showSLTP
if not na(slLine)
line.delete(slLine)
if not na(tpLine)
line.delete(tpLine)
if not na(slLabel)
label.delete(slLabel)
if not na(tpLabel)
label.delete(tpLabel)
slLine := line.new(bar_index, slPrice, bar_index + 1, slPrice, extend=extend.right, color=color.red, width=2)
tpLine := line.new(bar_index, tpPrice, bar_index + 1, tpPrice, extend=extend.right, color=color.green, width=2)
slLabel := label.new(bar_index + 1, slPrice, "SL " + str.tostring(slPrice, format.mintick), xloc.bar_index, yloc.price, color.new(color.red, 10), label.style_label_right, color.white, size.small)
tpLabel := label.new(bar_index + 1, tpPrice, "TP " + str.tostring(tpPrice, format.mintick), xloc.bar_index, yloc.price, color.new(color.green, 10), label.style_label_right, color.white, size.small)
// Keep labels pinned to the right of current bar while trade is open
if showSLTP and strategy.position_size != 0 and not na(slPrice) and not na(tpPrice)
label.set_xy(slLabel, bar_index + 1, slPrice)
label.set_text(slLabel, "SL " + str.tostring(slPrice, format.mintick))
label.set_xy(tpLabel, bar_index + 1, tpPrice)
label.set_text(tpLabel, "TP " + str.tostring(tpPrice, format.mintick))
// Clean up drawings when flat
if strategy.position_size == 0
slPrice := na
tpPrice := na
if not na(slLine)
line.delete(slLine)
slLine := na
if not na(tpLine)
line.delete(tpLine)
tpLine := na
if not na(slLabel)
label.delete(slLabel)
slLabel := na
if not na(tpLabel)
label.delete(tpLabel)
tpLabel := na






















