HEIKIN ASHI - MyOkaneAquiDemonstrates hekin ashi to smooth the chart, removing market noise and showing trend line.
אינדיקטורים ואסטרטגיות
Varma Fractal TEMA + Strong Move Candle DetectorIts a combined Indicator built on the concepts of Fractals, EMAs, RSI, ATR and Awesome Oscillators. A fractal is a small, repeating price pattern composed of five price bars or candlesticks that helps identify potential turning points in a market trend. It acts as a technical indicator to highlight support and resistance levels, signifying potential reversals. Specifically, a bullish fractal has the middle bar as the lowest low (a "V" shape), signaling a possible uptrend reversal, while a bearish fractal has the middle bar as the highest high (an inverted "V"), indicating a potential downtrend reversal. EMA tracks an asset's price over a specific period by placing greater weight on recent data points, making it more responsive to current market changes than a Simple Moving Average (SMA). Traders use EMAs to identify bullish and bearish trends, spot potential entry and exit points, and capture market momentum and price shifts quickly, especially in shorter time frames. RSI (Relative Strength Index) is a momentum oscillator used in trading to measure the speed and change of price movements, indicating whether a security is overbought (likely to fall) or oversold (likely to rise). Developed by J. Welles Wilder Jr., the RSI oscillates between 0 and 100, with values above 70 generally signaling an overbought condition and values below 30 indicating an oversold condition. Traders use these signals to identify potential trend reversals and time their entry and exit points more effectively.
VXN Range FilterThis indicator is based on other open source scripts. It's designed for Nasdaq futures (NQ and MNQ), combining a range filter with CBOE VXN Index (Nasdaq-100 volatility) signals to identify buy and sell opportunities.
It overlays on the price chart, using a smoothed price filter to reduce noise and dynamic bands for target zones. The VXN's EMA and SMA determine bullish (EMA < SMA, green background)
or bearish (EMA > SMA, red background) market conditions to confirm signals. Buy/sell signals are generated when the price breaks out of the filter in the trend direction, confirmed by the VXN state and a change in prior condition to avoid redundant signals.
The indicator is suitable for swing or trend-following strategies, with adjustable parameters
for customization. Visuals include colored bars (white: bullish, blue: bearish, light blue: neutral), target bands, and labeled signals. Alerts are provided for buy, sell, or both.
TCLC - Multi TimeFrame VWAPVWAP :
VWAP, or Volume Weighted Average Price, is a trading indicator that represents the average price of a security over a specific period, weighted by the volume of trades at each price level. It is calculated by taking the sum of the product of price and volume and dividing it by the total volume for the period. Essentially, VWAP shows the average price at which most trades occurred, giving more weight to prices with higher trading volumes.
The Indicator Plots the VWAP in Daily, WEEKLY , MONTHLY , YEARLY which helps to gauage the trend where the Volume vs Price exists....
Optimized Trend-Momentum SignalsThis indicator combines trend, momentum, and volume-strength factors into a single buy/sell signal system. It integrates:
SMA 200 → Identifies the long-term trend (price above = bullish bias, below = bearish bias).
MACD (12,26,9) → Confirms momentum direction with line crossovers.
RSI (7) → Filters strength (above 50 = bullish, below 50 = bearish).
ROC (45) → Validates positive or negative rate of change.
Signal Logic:
Buy Signal → Price above SMA 200, MACD bullish, RSI > 50, and ROC > 0.
Sell Signal → Price below SMA 200, MACD bearish, RSI < 50, and ROC < 0.
Features:
Clear arrows for BUY and SELL signals.
Long-term SMA plotted for trend visualization.
Alerts built-in for real-time notifications.
This tool helps traders filter out noise and act only when all major confirmation factors align, reducing false signals and improving decision-making.
SOM RRMA (Revolution & Reverse Magic Average)## SOM RRMA (Revolution & Reverse Magic Average)
**Description:**
The SOM RRMA (Revolution & Reverse Magic Average) indicator overlays two distinct moving average lines on any TradingView chart, providing traders with enhanced trend and reversal insights.
- The “Revolution Magic Line RMA” plots the classic Welles Wilder’s Running Moving Average (RMA) using default settings: length = 21, source = close, and timeframe = chart. This line is displayed in **green** for clear visibility.
- The “Reverse Magic Line RMA” plots an innovative reverse RMA, based on a reversed price calculation, also using default settings: length = 21, source = close, and timeframe = chart. This line appears in **red** for direct distinction.
- Both lines offer independent customization of length, source, and timeframe, enabling traders to tailor the indicator to their strategy and instrument.
**How to Use:**
- Add SOM RRMA to any TradingView instrument and timeframe.
- By default, both lines use length = 21 and source = close with the current chart’s timeframe.
- The green line tracks the standard RMA trend; the red line follows the Reverse RMA, often moving contrary to price action.
- Observe interactions and divergence between the two lines to detect trend changes, momentum shifts, or potential reversal setups.
**Features:**
- Customizable length, source, and timeframe parameters for both lines.
- Default colors: green for standard RMA, red for Reverse RMA.
- Trend-following, divergence detection, and reversal strategy support.
**Notes:**
This indicator is intended for educational and research purposes only. Please test it using demo charts before applying to live trading.
Feedback and suggestions are welcome—share your experience or questions on the script page.
Volume Cluster AlertThis script is designed to highlight unusual trading volume activity that may be relevant for users analyzing potential shifts in market behavior. It detects significant deviations in volume compared to historical averages and identifies recurring volume patterns within a user-defined timeframe.
When such activity is detected, the indicator displays visual labels above or below the price chart. Labels appearing above the chart (red by default) correspond to specific volume patterns during upward price movement. Labels below the chart (green by default) reflect similar volume behavior during downward movement.
Clusters of labels — especially when multiple of the same color appear within a short period — can be visually useful for observing potential changes in price dynamics. These groupings are meant to support the user’s own analysis and decision-making process.
Users can customize the color of the labels and adjust the sensitivity of the detection parameters to better align with their trading style or chart settings.
Please note: This indicator does not predict market direction or generate trading signals. It is a visual tool that highlights specific volume conditions, which may be interpreted by the user in combination with other technical or analytical methods.
Trade with Shyam - SimpleStrategy Overview
This is a trend-following strategy that uses two Exponential Moving Averages (EMAs) to identify trading opportunities in the market. The strategy generates buy and sell signals based on the relationship between price and the EMA lines.
How It Works
Entry Signals
ENTRY CALL (Green): Generated when the complete candle closes above the EMA 9 (candle low > EMA 9)
ENTRY PUT (Red): Generated when the complete candle closes below the EMA 9 (candle high < EMA 9)
Exit Signals
EXIT CALL (Gray): Triggered when price closes below the EMA 21 (candle high < EMA 21)
EXIT PUT (Gray): Triggered when price closes above the EMA 21 (candle low > EMA 21)
Visual Components
Red Line (Thickness 3): EMA 9 - Short-term trend indicator
Green Line (Thickness 3): EMA 21 - Medium-term trend indicator
Green Triangles: Buy entry signals
Red Triangles: Sell entry signals
Gray X Marks: Exit signals
Background Coloring:
Light green: Currently in a long position
Light red: Currently in a short position
Strategy Logic
Buy Signal: When price shows strength by closing completely above the EMA 9
Sell Signal: When price shows weakness by closing completely below the EMA 9
Exit Long: When price weakness pulls back below EMA 21
Exit Short: When price strength pushes back above EMA 21
Key Features
Trend Following: Captures momentum in the direction of the trend
Dual EMA System: Uses faster EMA (9) for entries and slower EMA (21) for exits
Complete Candle Confirmation: Only triggers signals after full candle confirmation
Position Management: Maintains only one position at a time (no simultaneous long/short)
Visual Clarity: Clear labels and color coding for easy interpretation
Best Usage Conditions
Trending Markets: Works best in markets with clear directional bias
Moderate to High Volatility: Provides better signal quality in active markets
Multiple Timeframes: Can be used on any timeframe (15min, 1H, 4H, Daily recommended)
Risk Management Notes
The strategy uses the EMA 21 as a dynamic stop-loss level
Position sizing and additional risk management should be implemented separately
Past performance does not guarantee future results
Customization
You can adjust the EMA periods in the indicator settings to suit your trading style:
Shorter periods: More sensitive, more signals (higher frequency)
Longer periods: Less sensitive, fewer but potentially higher quality signals
P/L Panel + Multi Targets (4 Entries) – HUD near Price + Avg R:R//@version=6
indicator("P/L Panel + Multi Targets (4 Entries) – HUD near Price + Avg R:R", overlay=true, max_lines_count=500, max_labels_count=500)
// ====== General =====
side = input.string("Long", "Position Side", options= )
usd_dp = input.int(2, "USD decimals", minval=0, maxval=6)
// ====== HUD Settings ======
hud_font = input.string("large", "HUD font size", options= )
hud_bg = input.color(color.new(color.black, 0), "HUD background color")
hud_txtc = input.color(color.white, "HUD text color")
hud_side = input.string("Right of price", "HUD side", options= )
hud_off_bars = input.int(3, "Horizontal offset (bars)", minval=0, maxval=50)
hud_off_atr = input.float(0.2, "Vertical offset from price (ATR)", step=0.1)
atr_len = input.int(14, "ATR length for vertical offset", minval=1)
lock_to_last_bar = input.bool(true, "Lock HUD to the last bar")
// Show HUD even when there are no entries (test text)
force_show_hud = input.bool(true, "🔍 Show HUD even with no entries")
// ====== Shared SL & Targets ======
stop_inp = input.float(0.0, "Stop Loss (shared, optional)", step=0.0001)
use_tp1 = input.bool(false, "Enable Target 1")
tp1 = input.float(0.0, "Target 1 price", step=0.0001)
use_tp2 = input.bool(false, "Enable Target 2")
tp2 = input.float(0.0, "Target 2 price", step=0.0001)
use_tp3 = input.bool(false, "Enable Target 3")
tp3 = input.float(0.0, "Target 3 price", step=0.0001)
use_tp4 = input.bool(false, "Enable Target 4")
tp4 = input.float(0.0, "Target 4 price", step=0.0001)
use_tp5 = input.bool(false, "Enable Target 5")
tp5 = input.float(0.0, "Target 5 price", step=0.0001)
// ====== Four Independent Entries ======
group1 = "Entry 1"
en1 = input.bool(true, "Enable Entry 1", inline=group1)
lev1 = input.int(10, "Leverage", minval=1, maxval=200, inline=group1)
entry1 = input.float(0.0, "Entry 1 price", step=0.0001)
set_now1 = input.bool(false, "⚡ Set Entry1 = Current Price")
mode1 = input.string("USD (USDT)", "Size unit 1", options= )
sem1 = input.string("Margin (apply leverage)", "Size meaning 1", options= )
size1 = input.float(0.0, "Position size 1", step=0.0001)
baseLev1 = input.bool(false, "Apply leverage to 'Coin Quantity' (1)")
group2 = "Entry 2"
en2 = input.bool(false, "Enable Entry 2", inline=group2)
lev2 = input.int(10, "Leverage", minval=1, maxval=200, inline=group2)
entry2 = input.float(0.0, "Entry 2 price", step=0.0001)
set_now2 = input.bool(false, "⚡ Set Entry2 = Current Price")
mode2 = input.string("USD (USDT)", "Size unit 2", options= )
sem2 = input.string("Margin (apply leverage)", "Size meaning 2", options= )
size2 = input.float(0.0, "Position size 2", step=0.0001)
baseLev2 = input.bool(false, "Apply leverage to 'Coin Quantity' (2)")
group3 = "Entry 3"
en3 = input.bool(false, "Enable Entry 3", inline=group3)
lev3 = input.int(10, "Leverage", minval=1, maxval=200, inline=group3)
entry3 = input.float(0.0, "Entry 3 price", step=0.0001)
set_now3 = input.bool(false, "⚡ Set Entry3 = Current Price")
mode3 = input.string("USD (USDT)", "Size unit 3", options= )
sem3 = input.string("Margin (apply leverage)", "Size meaning 3", options= )
size3 = input.float(0.0, "Position size 3", step=0.0001)
baseLev3 = input.bool(false, "Apply leverage to 'Coin Quantity' (3)")
group4 = "Entry 4"
en4 = input.bool(false, "Enable Entry 4", inline=group4)
lev4 = input.int(10, "Leverage", minval=1, maxval=200, inline=group4)
entry4 = input.float(0.0, "Entry 4 price", step=0.0001)
set_now4 = input.bool(false, "⚡ Set Entry4 = Current Price")
mode4 = input.string("USD (USDT)", "Size unit 4", options= )
sem4 = input.string("Margin (apply leverage)", "Size meaning 4", options= )
size4 = input.float(0.0, "Position size 4", step=0.0001)
baseLev4 = input.bool(false, "Apply leverage to 'Coin Quantity' (4)")
// Quick set entries = current price
entry1 := (en1 and set_now1) ? close : entry1
entry2 := (en2 and set_now2) ? close : entry2
entry3 := (en3 and set_now3) ? close : entry3
entry4 := (en4 and set_now4) ? close : entry4
// ====== Helpers ======
to_size(s) =>
s == "tiny" ? size.tiny : s == "small" ? size.small : s == "normal" ? size.normal : s == "large" ? size.large : size.huge
f_usd_str(_val, _decimals) =>
na(_val) ? "—" : str.tostring(math.round(_val * math.pow(10, _decimals)) / math.pow(10, _decimals))
f_qty_base(mode, sem, size, entry, baseLev, lev) =>
float _qty = na
if mode == "USD (USDT)"
_qty := (size > 0 and entry > 0) ? ((sem == "Margin (apply leverage)" ? size * lev : size) / entry) : na
else
_qty := size > 0 ? (baseLev ? size * lev : size) : na
_qty
f_notional_quote(mode, sem, size, entry, lev, baseLev) =>
if mode == "USD (USDT)"
sem == "Margin (apply leverage)" ? size * lev : size
else
(baseLev ? size * lev : size) * entry
f_pnl_quote(side, entry, qty) =>
na(qty) or na(entry) ? na : (side=="Long" ? (close - entry) : (entry - close)) * qty
f_pct(side, entry) =>
na(entry) ? na : ((close - entry) / entry * 100.0) * (side=="Long" ? 1 : -1)
f_roi_pct(side, entry, lev) =>
na(entry) ? na : f_pct(side, entry) * lev
// NOTE: _lineIn must be a line, not a float
f_stickyHLine(_price, _lineIn, _color, _width) =>
var line _out = na
_out := _lineIn
if na(_out)
_out := line.new(bar_index-1, _price, bar_index+1, _price, xloc=xloc.bar_index, extend=extend.both, width=_width, style=line.style_dashed, color=_color)
else
line.set_xy1(_out, bar_index-1, _price)
line.set_xy2(_out, bar_index+1, _price)
line.set_color(_out, _color)
line.set_width(_out, _width)
_out
// ====== 4 Entries Calculations ======
var color entryCols = array.from(color.new(color.yellow, 0), color.new(color.orange, 0), color.new(color.teal, 0), color.new(color.fuchsia, 0))
bool ens = array.from(en1, en2, en3, en4)
float entries = array.from(entry1, entry2, entry3, entry4)
int levs = array.from(lev1, lev2, lev3, lev4)
string modes = array.from(mode1, mode2, mode3, mode4)
string sems = array.from(sem1, sem2, sem3, sem4)
float sizes = array.from(size1, size2, size3, size4)
bool baseLevs = array.from(baseLev1, baseLev2, baseLev3, baseLev4)
float qtys = array.new_float(4, na)
float pnls = array.new_float(4, na)
float pcts = array.new_float(4, na)
float rois = array.new_float(4, na)
float notionals = array.new_float(4, na)
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
ent = array.get(entries, i)
levX = array.get(levs, i)
modeX= array.get(modes, i)
semX = array.get(sems, i)
sizeX= array.get(sizes, i)
bLev = array.get(baseLevs, i)
qty = f_qty_base(modeX, semX, sizeX, ent, bLev, levX)
array.set(qtys, i, qty)
pnlq = f_pnl_quote(side, ent, qty)
array.set(pnls, i, pnlq)
pct = f_pct(side, ent)
array.set(pcts, i, pct)
roi = f_roi_pct(side, ent, levX)
array.set(rois, i, roi)
notq = f_notional_quote(modeX, semX, sizeX, ent, levX, bLev)
array.set(notionals, i, notq)
// ====== Totals & Weighted Avg Entry ======
float totalPnlUSD = 0.0
float totalNotional = 0.0
float totalQty = 0.0
float wAvgEntry = na
for i = 0 to 3
if not na(array.get(pnls, i))
totalPnlUSD += array.get(pnls, i)
if not na(array.get(notionals, i))
totalNotional += array.get(notionals, i)
if not na(array.get(qtys, i)) and array.get(entries, i) > 0
totalQty += array.get(qtys, i)
if totalQty > 0
num = 0.0
for i = 0 to 3
qi = array.get(qtys, i)
ei = array.get(entries, i)
if not na(qi) and ei > 0
num += qi * ei
wAvgEntry := num / totalQty
totalROIweighted = totalNotional > 0 ? (totalPnlUSD / totalNotional) * 100.0 : na
// ====== Nearest TP & R:R ======
float nearestTP = na
float nearestDistPrice = na
float nearestDistPct = na
float risk_pct = na
float reward_pct = na
float rr = na
var float tps = array.new_float()
array.clear(tps)
if use_tp1 and tp1 > 0
array.push(tps, tp1)
if use_tp2 and tp2 > 0
array.push(tps, tp2)
if use_tp3 and tp3 > 0
array.push(tps, tp3)
if use_tp4 and tp4 > 0
array.push(tps, tp4)
if use_tp5 and tp5 > 0
array.push(tps, tp5)
// nearest target in the trade direction (from current price)
if array.size(tps) > 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
cond = side=="Long" ? (_tp > close) : (_tp < close)
if cond
distP = math.abs(_tp - close)
if na(nearestDistPrice) or distP < nearestDistPrice
nearestDistPrice := distP
nearestTP := _tp
if not na(nearestDistPrice) and close != 0
nearestDistPct := (nearestDistPrice / close) * 100.0
float stop = stop_inp > 0 ? stop_inp : na
if not na(wAvgEntry) and not na(stop)
rawRisk = (side=="Long" ? (stop - wAvgEntry) : (wAvgEntry - stop)) / wAvgEntry * 100.0
risk_pct := math.abs(rawRisk)
if not na(wAvgEntry) and not na(nearestTP)
reward_pct := math.abs((side=="Long" ? (nearestTP - wAvgEntry) : (wAvgEntry - nearestTP)) / wAvgEntry * 100.0)
rr := (not na(risk_pct) and not na(reward_pct) and risk_pct != 0) ? reward_pct / risk_pct : na
// ====== Average R:R across all valid targets ======
float rr_avg = na
if not na(wAvgEntry) and not na(stop) and array.size(tps) > 0 and not na(risk_pct) and risk_pct != 0
float sum_rr = 0.0
int cnt_rr = 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
bool validDir = side=="Long" ? (_tp > wAvgEntry) : (_tp < wAvgEntry)
if validDir
_reward = math.abs((side=="Long" ? (_tp - wAvgEntry) : (wAvgEntry - _tp)) / wAvgEntry * 100.0)
_rr = _reward / risk_pct
sum_rr += _rr
cnt_rr += 1
rr_avg := cnt_rr > 0 ? (sum_rr / cnt_rr) : na
// ====== Entry/SL/TP Lines ======
var line entryLines = array.new_line(4, na)
for i = 0 to 3
ln = array.get(entryLines, i)
if array.get(ens, i) and array.get(entries, i) > 0
col = array.get(entryCols, i)
ent = array.get(entries, i)
ln := f_stickyHLine(ent, ln, col, 2)
array.set(entryLines, i, ln)
else
if not na(ln)
line.delete(ln)
array.set(entryLines, i, na)
var line slLine = na
if not na(stop)
slLine := f_stickyHLine(stop, slLine, color.new(color.red, 0), 1)
else
if not na(slLine)
line.delete(slLine)
slLine := na
var line tpLine1 = na
var line tpLine2 = na
var line tpLine3 = na
var line tpLine4 = na
var line tpLine5 = na
if use_tp1 and tp1 > 0
tpLine1 := f_stickyHLine(tp1, tpLine1, color.new(color.teal, 0), 1)
else
if not na(tpLine1)
line.delete(tpLine1)
tpLine1 := na
if use_tp2 and tp2 > 0
tpLine2 := f_stickyHLine(tp2, tpLine2, color.new(color.teal, 0), 1)
else
if not na(tpLine2)
line.delete(tpLine2)
tpLine2 := na
if use_tp3 and tp3 > 0
tpLine3 := f_stickyHLine(tp3, tpLine3, color.new(color.teal, 0), 1)
else
if not na(tpLine3)
line.delete(tpLine3)
tpLine3 := na
if use_tp4 and tp4 > 0
tpLine4 := f_stickyHLine(tp4, tpLine4, color.new(color.teal, 0), 1)
else
if not na(tpLine4)
line.delete(tpLine4)
tpLine4 := na
if use_tp5 and tp5 > 0
tpLine5 := f_stickyHLine(tp5, tpLine5, color.new(color.teal, 0), 1)
else
if not na(tpLine5)
line.delete(tpLine5)
tpLine5 := na
// ====== Build HUD Text ======
string txt = ""
// Per-entry rows
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
idx = i + 1
ent = array.get(entries, i)
pct = array.get(pcts, i)
pnlq = array.get(pnls, i)
roi = array.get(rois, i)
levX = array.get(levs, i)
txt += (txt=="" ? "" : " ") + "📌 Entry " + str.tostring(idx) + ": " + str.tostring(ent, format.mintick)
txt += " 📊 Live: " + (na(pct) ? "—" : str.tostring(pct, format.mintick) + "%") + " | 💵 " + (na(pnlq) ? "—" : "$" + f_usd_str(pnlq, usd_dp))
txt += " 🧮 ROI(x" + str.tostring(levX) + "): " + (na(roi) ? "—" : str.tostring(roi, format.mintick) + "%")
// Summary or test HUD
if txt != ""
if totalQty > 0
txt += " — — —"
txt += " ⚖️ Weighted Avg Entry: " + str.tostring(wAvgEntry, format.mintick)
if not na(stop)
txt += " ❌ SL: " + str.tostring(stop, format.mintick)
// Nearest target (from current price)
string tpInfo = "—"
if not na(nearestTP)
tpInfo := str.tostring(nearestTP, format.mintick) + (na(nearestDistPct) ? "" : " (Δ " + str.tostring(nearestDistPct, format.mintick) + "%)")
txt += " 🎯 Nearest: " + tpInfo
// R:R (nearest)
if not na(rr)
txt += " 📐 R:R (nearest): " + str.tostring(rr, format.mintick)
// Avg R:R across all valid TPs (by direction from weighted entry)
if not na(rr_avg)
txt += " 📐 Avg R:R (all valid TPs): " + str.tostring(rr_avg, format.mintick)
// Totals
txt += " 🧾 Total P/L: " + "$" + f_usd_str(totalPnlUSD, usd_dp)
txt += " 🧮 Weighted ROI (by Notional): " + (na(totalROIweighted) ? "—" : str.tostring(totalROIweighted, format.mintick) + "%")
else if force_show_hud
txt := "🧪 HUD is active. Fill Entry prices or tick ⚡. Enable TP/SL to see lines."
// ====== HUD Placement (near live price) ======
var label hud = na
atr_val = nz(ta.atr(atr_len), 0.0)
anchor_price = close
y_pos = na(anchor_price) ? na : anchor_price + (atr_val * hud_off_atr)
x_pos_base = bar_index
off = hud_side == "Right of price" ? hud_off_bars : -hud_off_bars
x_pos = lock_to_last_bar ? (barstate.islast ? (x_pos_base + off) : x_pos_base) : (x_pos_base + off)
// Pick label style by side:
// - Right of price → pointer on LEFT edge → style_label_left
// - Left of price → pointer on RIGHT edge → style_label_right
label_style = hud_side == "Right of price" ? label.style_label_left : label.style_label_right
if not na(y_pos) and txt != ""
if na(hud)
hud := label.new(x_pos, y_pos, txt, xloc=xloc.bar_index, style=label_style, textcolor=hud_txtc, color=hud_bg, size=to_size(hud_font))
else
label.set_x(hud, x_pos)
label.set_y(hud, y_pos)
label.set_text(hud, txt)
label.set_textcolor(hud, hud_txtc)
label.set_color(hud, hud_bg)
label.set_style(hud, label_style)
label.set_size(hud, to_size(hud_font))
else
if not na(hud)
label.delete(hud)
hud := na
P/L Panel + Multi Targets (4 Entries) – HUD near Price + Avg R:R//@version=6
indicator("P/L Panel + Multi Targets (4 Entries) – HUD near Price + Avg R:R", overlay=true, max_lines_count=500, max_labels_count=500)
// ====== General ======
side = input.string("Long", "Position Side", options= )
usd_dp = input.int(2, "USD decimals", minval=0, maxval=6)
// ====== HUD Settings ======
hud_font = input.string("large", "HUD font size", options= )
hud_bg = input.color(color.new(color.black, 0), "HUD background color")
hud_txtc = input.color(color.white, "HUD text color")
hud_side = input.string("Right of price", "HUD side", options= )
hud_off_bars = input.int(3, "Horizontal offset (bars)", minval=0, maxval=50)
hud_off_atr = input.float(0.2, "Vertical offset from price (ATR)", step=0.1)
atr_len = input.int(14, "ATR length for vertical offset", minval=1)
lock_to_last_bar = input.bool(true, "Lock HUD to the last bar")
// Show HUD even when there are no entries (test text)
force_show_hud = input.bool(true, "🔍 Show HUD even with no entries")
// ====== Shared SL & Targets ======
stop_inp = input.float(0.0, "Stop Loss (shared, optional)", step=0.0001)
use_tp1 = input.bool(false, "Enable Target 1")
tp1 = input.float(0.0, "Target 1 price", step=0.0001)
use_tp2 = input.bool(false, "Enable Target 2")
tp2 = input.float(0.0, "Target 2 price", step=0.0001)
use_tp3 = input.bool(false, "Enable Target 3")
tp3 = input.float(0.0, "Target 3 price", step=0.0001)
use_tp4 = input.bool(false, "Enable Target 4")
tp4 = input.float(0.0, "Target 4 price", step=0.0001)
use_tp5 = input.bool(false, "Enable Target 5")
tp5 = input.float(0.0, "Target 5 price", step=0.0001)
// ====== Four Independent Entries ======
group1 = "Entry 1"
en1 = input.bool(true, "Enable Entry 1", inline=group1)
lev1 = input.int(10, "Leverage", minval=1, maxval=200, inline=group1)
entry1 = input.float(0.0, "Entry 1 price", step=0.0001)
set_now1 = input.bool(false, "⚡ Set Entry1 = Current Price")
mode1 = input.string("USD (USDT)", "Size unit 1", options= )
sem1 = input.string("Margin (apply leverage)", "Size meaning 1", options= )
size1 = input.float(0.0, "Position size 1", step=0.0001)
baseLev1 = input.bool(false, "Apply leverage to 'Coin Quantity' (1)")
group2 = "Entry 2"
en2 = input.bool(false, "Enable Entry 2", inline=group2)
lev2 = input.int(10, "Leverage", minval=1, maxval=200, inline=group2)
entry2 = input.float(0.0, "Entry 2 price", step=0.0001)
set_now2 = input.bool(false, "⚡ Set Entry2 = Current Price")
mode2 = input.string("USD (USDT)", "Size unit 2", options= )
sem2 = input.string("Margin (apply leverage)", "Size meaning 2", options= )
size2 = input.float(0.0, "Position size 2", step=0.0001)
baseLev2 = input.bool(false, "Apply leverage to 'Coin Quantity' (2)")
group3 = "Entry 3"
en3 = input.bool(false, "Enable Entry 3", inline=group3)
lev3 = input.int(10, "Leverage", minval=1, maxval=200, inline=group3)
entry3 = input.float(0.0, "Entry 3 price", step=0.0001)
set_now3 = input.bool(false, "⚡ Set Entry3 = Current Price")
mode3 = input.string("USD (USDT)", "Size unit 3", options= )
sem3 = input.string("Margin (apply leverage)", "Size meaning 3", options= )
size3 = input.float(0.0, "Position size 3", step=0.0001)
baseLev3 = input.bool(false, "Apply leverage to 'Coin Quantity' (3)")
group4 = "Entry 4"
en4 = input.bool(false, "Enable Entry 4", inline=group4)
lev4 = input.int(10, "Leverage", minval=1, maxval=200, inline=group4)
entry4 = input.float(0.0, "Entry 4 price", step=0.0001)
set_now4 = input.bool(false, "⚡ Set Entry4 = Current Price")
mode4 = input.string("USD (USDT)", "Size unit 4", options= )
sem4 = input.string("Margin (apply leverage)", "Size meaning 4", options= )
size4 = input.float(0.0, "Position size 4", step=0.0001)
baseLev4 = input.bool(false, "Apply leverage to 'Coin Quantity' (4)")
// Quick set entries = current price
entry1 := (en1 and set_now1) ? close : entry1
entry2 := (en2 and set_now2) ? close : entry2
entry3 := (en3 and set_now3) ? close : entry3
entry4 := (en4 and set_now4) ? close : entry4
// ====== Helpers ======
to_size(s) =>
s == "tiny" ? size.tiny : s == "small" ? size.small : s == "normal" ? size.normal : s == "large" ? size.large : size.huge
f_usd_str(_val, _decimals) =>
na(_val) ? "—" : str.tostring(math.round(_val * math.pow(10, _decimals)) / math.pow(10, _decimals))
f_qty_base(mode, sem, size, entry, baseLev, lev) =>
float _qty = na
if mode == "USD (USDT)"
_qty := (size > 0 and entry > 0) ? ((sem == "Margin (apply leverage)" ? size * lev : size) / entry) : na
else
_qty := size > 0 ? (baseLev ? size * lev : size) : na
_qty
f_notional_quote(mode, sem, size, entry, lev, baseLev) =>
if mode == "USD (USDT)"
sem == "Margin (apply leverage)" ? size * lev : size
else
(baseLev ? size * lev : size) * entry
f_pnl_quote(side, entry, qty) =>
na(qty) or na(entry) ? na : (side=="Long" ? (close - entry) : (entry - close)) * qty
f_pct(side, entry) =>
na(entry) ? na : ((close - entry) / entry * 100.0) * (side=="Long" ? 1 : -1)
f_roi_pct(side, entry, lev) =>
na(entry) ? na : f_pct(side, entry) * lev
// NOTE: _lineIn must be a line, not a float
f_stickyHLine(_price, _lineIn, _color, _width) =>
var line _out = na
_out := _lineIn
if na(_out)
_out := line.new(bar_index-1, _price, bar_index+1, _price, xloc=xloc.bar_index, extend=extend.both, width=_width, style=line.style_dashed, color=_color)
else
line.set_xy1(_out, bar_index-1, _price)
line.set_xy2(_out, bar_index+1, _price)
line.set_color(_out, _color)
line.set_width(_out, _width)
_out
// ====== 4 Entries Calculations ======
var color entryCols = array.from(color.new(color.yellow, 0), color.new(color.orange, 0), color.new(color.teal, 0), color.new(color.fuchsia, 0))
bool ens = array.from(en1, en2, en3, en4)
float entries = array.from(entry1, entry2, entry3, entry4)
int levs = array.from(lev1, lev2, lev3, lev4)
string modes = array.from(mode1, mode2, mode3, mode4)
string sems = array.from(sem1, sem2, sem3, sem4)
float sizes = array.from(size1, size2, size3, size4)
bool baseLevs = array.from(baseLev1, baseLev2, baseLev3, baseLev4)
float qtys = array.new_float(4, na)
float pnls = array.new_float(4, na)
float pcts = array.new_float(4, na)
float rois = array.new_float(4, na)
float notionals = array.new_float(4, na)
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
ent = array.get(entries, i)
levX = array.get(levs, i)
modeX= array.get(modes, i)
semX = array.get(sems, i)
sizeX= array.get(sizes, i)
bLev = array.get(baseLevs, i)
qty = f_qty_base(modeX, semX, sizeX, ent, bLev, levX)
array.set(qtys, i, qty)
pnlq = f_pnl_quote(side, ent, qty)
array.set(pnls, i, pnlq)
pct = f_pct(side, ent)
array.set(pcts, i, pct)
roi = f_roi_pct(side, ent, levX)
array.set(rois, i, roi)
notq = f_notional_quote(modeX, semX, sizeX, ent, levX, bLev)
array.set(notionals, i, notq)
// ====== Totals & Weighted Avg Entry ======
float totalPnlUSD = 0.0
float totalNotional = 0.0
float totalQty = 0.0
float wAvgEntry = na
for i = 0 to 3
if not na(array.get(pnls, i))
totalPnlUSD += array.get(pnls, i)
if not na(array.get(notionals, i))
totalNotional += array.get(notionals, i)
if not na(array.get(qtys, i)) and array.get(entries, i) > 0
totalQty += array.get(qtys, i)
if totalQty > 0
num = 0.0
for i = 0 to 3
qi = array.get(qtys, i)
ei = array.get(entries, i)
if not na(qi) and ei > 0
num += qi * ei
wAvgEntry := num / totalQty
totalROIweighted = totalNotional > 0 ? (totalPnlUSD / totalNotional) * 100.0 : na
// ====== Nearest TP & R:R ======
float nearestTP = na
float nearestDistPrice = na
float nearestDistPct = na
float risk_pct = na
float reward_pct = na
float rr = na
var float tps = array.new_float()
array.clear(tps)
if use_tp1 and tp1 > 0
array.push(tps, tp1)
if use_tp2 and tp2 > 0
array.push(tps, tp2)
if use_tp3 and tp3 > 0
array.push(tps, tp3)
if use_tp4 and tp4 > 0
array.push(tps, tp4)
if use_tp5 and tp5 > 0
array.push(tps, tp5)
// nearest target in the trade direction (from current price)
if array.size(tps) > 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
cond = side=="Long" ? (_tp > close) : (_tp < close)
if cond
distP = math.abs(_tp - close)
if na(nearestDistPrice) or distP < nearestDistPrice
nearestDistPrice := distP
nearestTP := _tp
if not na(nearestDistPrice) and close != 0
nearestDistPct := (nearestDistPrice / close) * 100.0
float stop = stop_inp > 0 ? stop_inp : na
if not na(wAvgEntry) and not na(stop)
rawRisk = (side=="Long" ? (stop - wAvgEntry) : (wAvgEntry - stop)) / wAvgEntry * 100.0
risk_pct := math.abs(rawRisk)
if not na(wAvgEntry) and not na(nearestTP)
reward_pct := math.abs((side=="Long" ? (nearestTP - wAvgEntry) : (wAvgEntry - nearestTP)) / wAvgEntry * 100.0)
rr := (not na(risk_pct) and not na(reward_pct) and risk_pct != 0) ? reward_pct / risk_pct : na
// ====== Average R:R across all valid targets ======
float rr_avg = na
if not na(wAvgEntry) and not na(stop) and array.size(tps) > 0 and not na(risk_pct) and risk_pct != 0
float sum_rr = 0.0
int cnt_rr = 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
bool validDir = side=="Long" ? (_tp > wAvgEntry) : (_tp < wAvgEntry)
if validDir
_reward = math.abs((side=="Long" ? (_tp - wAvgEntry) : (wAvgEntry - _tp)) / wAvgEntry * 100.0)
_rr = _reward / risk_pct
sum_rr += _rr
cnt_rr += 1
rr_avg := cnt_rr > 0 ? (sum_rr / cnt_rr) : na
// ====== Entry/SL/TP Lines ======
var line entryLines = array.new_line(4, na)
for i = 0 to 3
ln = array.get(entryLines, i)
if array.get(ens, i) and array.get(entries, i) > 0
col = array.get(entryCols, i)
ent = array.get(entries, i)
ln := f_stickyHLine(ent, ln, col, 2)
array.set(entryLines, i, ln)
else
if not na(ln)
line.delete(ln)
array.set(entryLines, i, na)
var line slLine = na
if not na(stop)
slLine := f_stickyHLine(stop, slLine, color.new(color.red, 0), 1)
else
if not na(slLine)
line.delete(slLine)
slLine := na
var line tpLine1 = na
var line tpLine2 = na
var line tpLine3 = na
var line tpLine4 = na
var line tpLine5 = na
if use_tp1 and tp1 > 0
tpLine1 := f_stickyHLine(tp1, tpLine1, color.new(color.teal, 0), 1)
else
if not na(tpLine1)
line.delete(tpLine1)
tpLine1 := na
if use_tp2 and tp2 > 0
tpLine2 := f_stickyHLine(tp2, tpLine2, color.new(color.teal, 0), 1)
else
if not na(tpLine2)
line.delete(tpLine2)
tpLine2 := na
if use_tp3 and tp3 > 0
tpLine3 := f_stickyHLine(tp3, tpLine3, color.new(color.teal, 0), 1)
else
if not na(tpLine3)
line.delete(tpLine3)
tpLine3 := na
if use_tp4 and tp4 > 0
tpLine4 := f_stickyHLine(tp4, tpLine4, color.new(color.teal, 0), 1)
else
if not na(tpLine4)
line.delete(tpLine4)
tpLine4 := na
if use_tp5 and tp5 > 0
tpLine5 := f_stickyHLine(tp5, tpLine5, color.new(color.teal, 0), 1)
else
if not na(tpLine5)
line.delete(tpLine5)
tpLine5 := na
// ====== Build HUD Text ======
string txt = ""
// Per-entry rows
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
idx = i + 1
ent = array.get(entries, i)
pct = array.get(pcts, i)
pnlq = array.get(pnls, i)
roi = array.get(rois, i)
levX = array.get(levs, i)
txt += (txt=="" ? "" : " ") + "📌 Entry " + str.tostring(idx) + ": " + str.tostring(ent, format.mintick)
txt += " 📊 Live: " + (na(pct) ? "—" : str.tostring(pct, format.mintick) + "%") + " | 💵 " + (na(pnlq) ? "—" : "$" + f_usd_str(pnlq, usd_dp))
txt += " 🧮 ROI(x" + str.tostring(levX) + "): " + (na(roi) ? "—" : str.tostring(roi, format.mintick) + "%")
// Summary or test HUD
if txt != ""
if totalQty > 0
txt += " — — —"
txt += " ⚖️ Weighted Avg Entry: " + str.tostring(wAvgEntry, format.mintick)
if not na(stop)
txt += " ❌ SL: " + str.tostring(stop, format.mintick)
// Nearest target (from current price)
string tpInfo = "—"
if not na(nearestTP)
tpInfo := str.tostring(nearestTP, format.mintick) + (na(nearestDistPct) ? "" : " (Δ " + str.tostring(nearestDistPct, format.mintick) + "%)")
txt += " 🎯 Nearest: " + tpInfo
// R:R (nearest)
if not na(rr)
txt += " 📐 R:R (nearest): " + str.tostring(rr, format.mintick)
// Avg R:R across all valid TPs (by direction from weighted entry)
if not na(rr_avg)
txt += " 📐 Avg R:R (all valid TPs): " + str.tostring(rr_avg, format.mintick)
// Totals
txt += " 🧾 Total P/L: " + "$" + f_usd_str(totalPnlUSD, usd_dp)
txt += " 🧮 Weighted ROI (by Notional): " + (na(totalROIweighted) ? "—" : str.tostring(totalROIweighted, format.mintick) + "%")
else if force_show_hud
txt := "🧪 HUD is active. Fill Entry prices or tick ⚡. Enable TP/SL to see lines."
// ====== HUD Placement (near live price) ======
var label hud = na
atr_val = nz(ta.atr(atr_len), 0.0)
anchor_price = close
y_pos = na(anchor_price) ? na : anchor_price + (atr_val * hud_off_atr)
x_pos_base = bar_index
off = hud_side == "Right of price" ? hud_off_bars : -hud_off_bars
x_pos = lock_to_last_bar ? (barstate.islast ? (x_pos_base + off) : x_pos_base) : (x_pos_base + off)
// Pick label style by side:
// - Right of price → pointer on LEFT edge → style_label_left
// - Left of price → pointer on RIGHT edge → style_label_right
label_style = hud_side == "Right of price" ? label.style_label_left : label.style_label_right
if not na(y_pos) and txt != ""
if na(hud)
hud := label.new(x_pos, y_pos, txt, xloc=xloc.bar_index, style=label_style, textcolor=hud_txtc, color=hud_bg, size=to_size(hud_font))
else
label.set_x(hud, x_pos)
label.set_y(hud, y_pos)
label.set_text(hud, txt)
label.set_textcolor(hud, hud_txtc)
label.set_color(hud, hud_bg)
label.set_style(hud, label_style)
label.set_size(hud, to_size(hud_font))
else
if not na(hud)
label.delete(hud)
hud := na
TWS - ATR, VWAP, PDHLC, EMAThis indicator is combination of many indicator. Like ATR, VWAP, Previous day low, high, close & EMA.
Position Size Calculator MKThis indicator uses for automating your trading very good for taking position with tension free
also have touch entry of price or closing basis entry and stop loss and also show live position
پنل سود/زیان + چند تارگت R:R//@version=6
indicator("پنل سود/زیان + چند تارگت (۴ ورود مستقل) - پنل چپ نزدیک قیمت + میانگین R:R", overlay=true, max_lines_count=500, max_labels_count=500)
// ====== تنظیمات عمومی ======
side = input.string("لانگ", "نوع پوزیشن", options= )
usd_dp = input.int(2, "تعداد اعشار نمایش دلار", minval=0, maxval=6)
// ====== تنظیمات پنل ======
hud_font = input.string("large", "اندازۀ فونت پنل", options= )
hud_bg = input.color(color.new(color.black, 0), "رنگ پسزمینه پنل")
hud_txtc = input.color(color.white, "رنگ متن پنل")
// محل پنل: کمی «چپِ» آخرین کندل + کمی فاصله عمودی از قیمت
hud_off_bars = input.int(3, "فاصلۀ افقی از قیمت به سمت چپ (تعداد کندل، فقط روی آخرین کندل)", minval=0, maxval=50)
hud_off_atr = input.float(0.2, "فاصلۀ عمودی از قیمت (ATR)", step=0.1)
atr_len = input.int(14, "طول ATR برای فاصله عمودی", minval=1)
// نمایش اجباری پنل حتی بدون ورود
force_show_hud = input.bool(true, "🔍 نمایش اجباری پنل حتی بدون ورود")
// ====== حد ضرر و تارگتهای مشترک ======
stop_inp = input.float(0.0, "حد ضرر (مشترک، اختیاری)", step=0.0001)
use_tp1 = input.bool(false, "فعالسازی تارگت ۱")
tp1 = input.float(0.0, "قیمت تارگت ۱", step=0.0001)
use_tp2 = input.bool(false, "فعالسازی تارگت ۲")
tp2 = input.float(0.0, "قیمت تارگت ۲", step=0.0001)
use_tp3 = input.bool(false, "فعالسازی تارگت ۳")
tp3 = input.float(0.0, "قیمت تارگت ۳", step=0.0001)
use_tp4 = input.bool(false, "فعالسازی تارگت ۴")
tp4 = input.float(0.0, "قیمت تارگت ۴", step=0.0001)
use_tp5 = input.bool(false, "فعالسازی تارگت ۵")
tp5 = input.float(0.0, "قیمت تارگت ۵", step=0.0001)
// ====== ورودیهای ۴ ورود مستقل ======
group1 = "ورود ۱"
en1 = input.bool(true, "فعالسازی ورود ۱", inline=group1)
lev1 = input.int(10, "لوریج", minval=1, maxval=200, inline=group1)
entry1 = input.float(0.0, "قیمت ورود ۱", step=0.0001)
set_now1 = input.bool(false, "⚡ ثبت ورود۱ = قیمت فعلی")
mode1 = input.string("دلاری (USDT)", "واحد اندازه ۱", options= )
sem1 = input.string("مارجین (اعمال لوریج)", "تعبیر اندازه ۱", options= )
size1 = input.float(0.0, "اندازه پوزیشن ۱", step=0.0001)
baseLev1 = input.bool(false, "اعمال لوریج روی حالت «تعداد کوین» (۱)")
group2 = "ورود ۲"
en2 = input.bool(false, "فعالسازی ورود ۲", inline=group2)
lev2 = input.int(10, "لوریج", minval=1, maxval=200, inline=group2)
entry2 = input.float(0.0, "قیمت ورود ۲", step=0.0001)
set_now2 = input.bool(false, "⚡ ثبت ورود۲ = قیمت فعلی")
mode2 = input.string("دلاری (USDT)", "واحد اندازه ۲", options= )
sem2 = input.string("مارجین (اعمال لوریج)", "تعبیر اندازه ۲", options= )
size2 = input.float(0.0, "اندازه پوزیشن ۲", step=0.0001)
baseLev2 = input.bool(false, "اعمال لوریج روی حالت «تعداد کوین» (۲)")
group3 = "ورود ۳"
en3 = input.bool(false, "فعالسازی ورود ۳", inline=group3)
lev3 = input.int(10, "لوریج", minval=1, maxval=200, inline=group3)
entry3 = input.float(0.0, "قیمت ورود ۳", step=0.0001)
set_now3 = input.bool(false, "⚡ ثبت ورود۳ = قیمت فعلی")
mode3 = input.string("دلاری (USDT)", "واحد اندازه ۳", options= )
sem3 = input.string("مارجین (اعمال لوریج)", "تعبیر اندازه ۳", options= )
size3 = input.float(0.0, "اندازه پوزیشن ۳", step=0.0001)
baseLev3 = input.bool(false, "اعمال لوریج روی حالت «تعداد کوین» (۳)")
group4 = "ورود ۴"
en4 = input.bool(false, "فعالسازی ورود ۴", inline=group4)
lev4 = input.int(10, "لوریج", minval=1, maxval=200, inline=group4)
entry4 = input.float(0.0, "قیمت ورود ۴", step=0.0001)
set_now4 = input.bool(false, "⚡ ثبت ورود۴ = قیمت فعلی")
mode4 = input.string("دلاری (USDT)", "واحد اندازه ۴", options= )
sem4 = input.string("مارجین (اعمال لوریج)", "تعبیر اندازه ۴", options= )
size4 = input.float(0.0, "اندازه پوزیشن ۴", step=0.0001)
baseLev4 = input.bool(false, "اعمال لوریج روی حالت «تعداد کوین» (۴)")
// ثبت سریع ورود = قیمت فعلی
entry1 := (en1 and set_now1) ? close : entry1
entry2 := (en2 and set_now2) ? close : entry2
entry3 := (en3 and set_now3) ? close : entry3
entry4 := (en4 and set_now4) ? close : entry4
// ====== کمکتابعها ======
to_size(s) =>
s == "tiny" ? size.tiny : s == "small" ? size.small : s == "normal" ? size.normal : s == "large" ? size.large : size.huge
f_usd_str(_val, _decimals) =>
na(_val) ? "—" : str.tostring(math.round(_val * math.pow(10, _decimals)) / math.pow(10, _decimals))
f_qty_base(mode, sem, size, entry, baseLev, lev) =>
float _qty = na
if mode == "دلاری (USDT)"
_qty := (size > 0 and entry > 0) ? ((sem == "مارجین (اعمال لوریج)" ? size * lev : size) / entry) : na
else
_qty := size > 0 ? (baseLev ? size * lev : size) : na
_qty
f_notional_quote(mode, sem, size, entry, lev, baseLev) =>
if mode == "دلاری (USDT)"
sem == "مارجین (اعمال لوریج)" ? size * lev : size
else
(baseLev ? size * lev : size) * entry
f_pnl_quote(side, entry, qty) =>
na(qty) or na(entry) ? na : (side=="لانگ" ? (close - entry) : (entry - close)) * qty
f_pct(side, entry) =>
na(entry) ? na : ((close - entry) / entry * 100.0) * (side=="لانگ" ? 1 : -1)
f_roi_pct(side, entry, lev) =>
na(entry) ? na : f_pct(side, entry) * lev
f_stickyHLine(_price, _lineIn, _color, _width) =>
var line _out = na
_out := _lineIn
if na(_out)
_out := line.new(bar_index-1, _price, bar_index+1, _price, xloc=xloc.bar_index, extend=extend.both, width=_width, style=line.style_dashed, color=_color)
else
line.set_xy1(_out, bar_index-1, _price)
line.set_xy2(_out, bar_index+1, _price)
line.set_color(_out, _color)
line.set_width(_out, _width)
_out
// ====== محاسبات ۴ ورود ======
var color entryCols = array.from(color.new(color.yellow, 0), color.new(color.orange, 0), color.new(color.teal, 0), color.new(color.fuchsia, 0))
bool ens = array.from(en1, en2, en3, en4)
float entries = array.from(entry1, entry2, entry3, entry4)
int levs = array.from(lev1, lev2, lev3, lev4)
string modes = array.from(mode1, mode2, mode3, mode4)
string sems = array.from(sem1, sem2, sem3, sem4)
float sizes = array.from(size1, size2, size3, size4)
bool baseLevs = array.from(baseLev1, baseLev2, baseLev3, baseLev4)
float qtys = array.new_float(4, na)
float pnls = array.new_float(4, na)
float pcts = array.new_float(4, na)
float rois = array.new_float(4, na)
float notionals = array.new_float(4, na)
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
ent = array.get(entries, i)
levX = array.get(levs, i)
modeX= array.get(modes, i)
semX = array.get(sems, i)
sizeX= array.get(sizes, i)
bLev = array.get(baseLevs, i)
qty = f_qty_base(modeX, semX, sizeX, ent, bLev, levX)
array.set(qtys, i, qty)
pnlq = f_pnl_quote(side, ent, qty)
array.set(pnls, i, pnlq)
pct = f_pct(side, ent)
array.set(pcts, i, pct)
roi = f_roi_pct(side, ent, levX)
array.set(rois, i, roi)
notq = f_notional_quote(modeX, semX, sizeX, ent, levX, bLev)
array.set(notionals, i, notq)
// ====== مجموع و میانگین ورود وزنی ======
float totalPnlUSD = 0.0
float totalNotional = 0.0
float totalQty = 0.0
float wAvgEntry = na
for i = 0 to 3
if not na(array.get(pnls, i))
totalPnlUSD += array.get(pnls, i)
if not na(array.get(notionals, i))
totalNotional += array.get(notionals, i)
if not na(array.get(qtys, i)) and array.get(entries, i) > 0
totalQty += array.get(qtys, i)
if totalQty > 0
num = 0.0
for i = 0 to 3
qi = array.get(qtys, i)
ei = array.get(entries, i)
if not na(qi) and ei > 0
num += qi * ei
wAvgEntry := num / totalQty
totalROIweighted = totalNotional > 0 ? (totalPnlUSD / totalNotional) * 100.0 : na
// ====== نزدیکترین تارگت و R:R ======
float nearestTP = na
float nearestDistPrice = na
float nearestDistPct = na
float risk_pct = na
float reward_pct = na
float rr = na
var float tps = array.new_float()
array.clear(tps)
if use_tp1 and tp1 > 0
array.push(tps, tp1)
if use_tp2 and tp2 > 0
array.push(tps, tp2)
if use_tp3 and tp3 > 0
array.push(tps, tp3)
if use_tp4 and tp4 > 0
array.push(tps, tp4)
if use_tp5 and tp5 > 0
array.push(tps, tp5)
// نزدیکترین تارگت همسو با جهت
if array.size(tps) > 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
cond = side=="لانگ" ? (_tp > close) : (_tp < close)
if cond
distP = math.abs(_tp - close)
if na(nearestDistPrice) or distP < nearestDistPrice
nearestDistPrice := distP
nearestTP := _tp
if not na(nearestDistPrice) and close != 0
nearestDistPct := (nearestDistPrice / close) * 100.0
float stop = stop_inp > 0 ? stop_inp : na
if not na(wAvgEntry) and not na(stop)
rawRisk = (side=="لانگ" ? (stop - wAvgEntry) : (wAvgEntry - stop)) / wAvgEntry * 100.0
risk_pct := math.abs(rawRisk)
if not na(wAvgEntry) and not na(nearestTP)
reward_pct := math.abs((side=="لانگ" ? (nearestTP - wAvgEntry) : (wAvgEntry - nearestTP)) / wAvgEntry * 100.0)
rr := (not na(risk_pct) and not na(reward_pct) and risk_pct != 0) ? reward_pct / risk_pct : na
// ====== «میانگین R:R» روی همه تارگتهای معتبر ======
float rr_avg = na
if not na(wAvgEntry) and not na(stop) and array.size(tps) > 0 and not na(risk_pct) and risk_pct != 0
float sum_rr = 0.0
int cnt_rr = 0
for i = 0 to array.size(tps) - 1
_tp = array.get(tps, i)
bool validDir = side=="لانگ" ? (_tp > wAvgEntry) : (_tp < wAvgEntry)
if validDir
_reward = math.abs((side=="لانگ" ? (_tp - wAvgEntry) : (wAvgEntry - _tp)) / wAvgEntry * 100.0)
_rr = _reward / risk_pct
sum_rr += _rr
cnt_rr += 1
rr_avg := cnt_rr > 0 ? (sum_rr / cnt_rr) : na
// ====== خطوط ورود/SL/TP ======
var line entryLines = array.new_line(4, na)
for i = 0 to 3
ln = array.get(entryLines, i)
if array.get(ens, i) and array.get(entries, i) > 0
col = array.get(entryCols, i)
ent = array.get(entries, i)
ln := f_stickyHLine(ent, ln, col, 2)
array.set(entryLines, i, ln)
else
if not na(ln)
line.delete(ln)
array.set(entryLines, i, na)
var line slLine = na
if not na(stop)
slLine := f_stickyHLine(stop, slLine, color.new(color.red, 0), 1)
else
if not na(slLine)
line.delete(slLine)
slLine := na
var line tpLine1 = na
var line tpLine2 = na
var line tpLine3 = na
var line tpLine4 = na
var line tpLine5 = na
if use_tp1 and tp1 > 0
tpLine1 := f_stickyHLine(tp1, tpLine1, color.new(color.teal, 0), 1)
else
if not na(tpLine1)
line.delete(tpLine1)
tpLine1 := na
if use_tp2 and tp2 > 0
tpLine2 := f_stickyHLine(tp2, tpLine2, color.new(color.teal, 0), 1)
else
if not na(tpLine2)
line.delete(tpLine2)
tpLine2 := na
if use_tp3 and tp3 > 0
tpLine3 := f_stickyHLine(tp3, tpLine3, color.new(color.teal, 0), 1)
else
if not na(tpLine3)
line.delete(tpLine3)
tpLine3 := na
if use_tp4 and tp4 > 0
tpLine4 := f_stickyHLine(tp4, tpLine4, color.new(color.teal, 0), 1)
else
if not na(tpLine4)
line.delete(tpLine4)
tpLine4 := na
if use_tp5 and tp5 > 0
tpLine5 := f_stickyHLine(tp5, tpLine5, color.new(color.teal, 0), 1)
else
if not na(tpLine5)
line.delete(tpLine5)
tpLine5 := na
// ====== ساخت متن پنل ======
string txt = ""
// ردیفهای هر ورود
for i = 0 to 3
if array.get(ens, i) and array.get(entries, i) > 0
idx = i + 1
ent = array.get(entries, i)
pct = array.get(pcts, i)
pnlq = array.get(pnls, i)
roi = array.get(rois, i)
levX = array.get(levs, i)
txt += (txt=="" ? "" : " ") + "📌 ورود " + str.tostring(idx) + ": " + str.tostring(ent, format.mintick)
txt += " 📊 لحظهای: " + (na(pct) ? "—" : str.tostring(pct, format.mintick) + "%") + " | 💵 " + (na(pnlq) ? "—" : "$" + f_usd_str(pnlq, usd_dp))
txt += " 🧮 ROI(x" + str.tostring(levX) + "): " + (na(roi) ? "—" : str.tostring(roi, format.mintick) + "%")
// خلاصه پایانی یا پنل تست
if txt != ""
if totalQty > 0
txt += " — — —"
txt += " ⚖️ میانگین ورود وزنی: " + str.tostring(wAvgEntry, format.mintick)
if not na(stop)
txt += " ❌ SL: " + str.tostring(stop, format.mintick)
// نزدیکترین تارگت
string tpInfo = "—"
if not na(nearestTP)
tpInfo := str.tostring(nearestTP, format.mintick) + (na(nearestDistPct) ? "" : " (Δ " + str.tostring(nearestDistPct, format.mintick) + "%)")
txt += " 🎯 نزدیکترین: " + tpInfo
// R:R نزدیکترین
if not na(rr)
txt += " 📐 R:R نزدیکترین: " + str.tostring(rr, format.mintick)
// میانگین R:R روی همه تارگتهای معتبر
if not na(rr_avg)
txt += " 📐 میانگین R:R (همۀ تارگتهای معتبر): " + str.tostring(rr_avg, format.mintick)
// مجموعها
txt += " 🧾 مجموع سود/زیان: " + "$" + f_usd_str(totalPnlUSD, usd_dp)
txt += " 🧮 ROĪ وزنی (بر اساس ناتیونال): " + (na(totalROIweighted) ? "—" : str.tostring(totalROIweighted, format.mintick) + "%")
else if force_show_hud
txt := "🧪 پنل فعال است. از فیلدهای «قیمت ورود» استفاده کن یا تیکهای ⚡ را بزن. برای دیدن TP/SL خطوط، تیکهای مربوطه را فعال کن."
// ====== HUD (پنل سمت چپ، نوک اشاره نزدیک قیمت لحظهای) ======
// ====== HUD (پنل سمت راست، نوک اشاره نزدیک قیمت لحظهای) ======
var label hud = na
atr_val = ta.atr(atr_len)
// لنگر عمودی روی قیمت لحظهای با کمی فاصله عمودی
anchor_price = close
y_pos = na(anchor_price) ? na : anchor_price + (atr_val * hud_off_atr)
// فقط روی آخرین کندل، چند بار به «راست» میبریم تا نوک پنل نزدیک کندل باشد
x_pos_base = bar_index
x_pos = barstate.islast ? (x_pos_base + hud_off_bars) : x_pos_base
if not na(y_pos) and txt != ""
if na(hud)
// ⚠️ style_label_left = نوک پنل سمت چپ است ⇒ متن به راست باز میشود ⇒ کل پنل در «راستِ» قیمت قرار میگیرد
hud := label.new(x_pos, y_pos, txt,xloc=xloc.bar_index,style=label.style_label_left, textcolor=hud_txtc, color=hud_bg, size=to_size(hud_font))
else
label.set_x(hud, x_pos)
label.set_y(hud, y_pos)
label.set_text(hud, txt)
label.set_textcolor(hud, hud_txtc)
label.set_color(hud, hud_bg)
label.set_style(hud, label.style_label_left)
label.set_size(hud, to_size(hud_font))
else
if not na(hud)
label.delete(hud)
hud := na
Break Point Record Table — GSK-VIZAG-AP-INDIA "Break Point Record Table — GSK-VIZAG-AP-INDIA" indicator captures key break points during each trading session and presents a clear, color-coded table overlay on the chart for quick visual reference. Specifically, it logs sessions' open price and monitors subsequent price action for notable breaks in the session high or low prices. Each break event is recorded with the time, price, and percentage change from the previous break, helping traders identify significant price movements within the session at a glance.
Key Features:
Records the session start time and opening price for context.
Tracks every intraday break above the previous session high or below the previous session low.
Calculates and displays the percentage change at each break event.
Highlights breaks with descriptive text including break time and values to aid trade decision-making.
Displays a table with columns for Time, Open, High, Low, and a Description of the event.
Uses color-coded cells to differentiate between session start, highs, lows, and break descriptions for better readability.
Maintains performance and readability by limiting the table to the latest 30 break events.
Usage & Benefits:
This indicator is ideal for intraday traders who want reliable visual cues to monitor momentum shifts and breakout/breakdown points during the trading day. By capturing these break points as discrete events and organizing the data into an easily accessible, visually intuitive table, it improves situational awareness and supports timely trading decisions.
Entry + TP + SL Box (dynamic )The purpose of creating this indicator is to quickly draw the entry price range box, price target box, and price loss box.
Dual Channel System [Alpha Extract]A sophisticated trend-following and reversal detection system that constructs dynamic support and resistance channels using volatility-adjusted ATR calculations and EMA smoothing for optimal market structure analysis. Utilizing advanced dual-zone methodology with step-like boundary evolution, this indicator delivers institutional-grade channel analysis that adapts to varying volatility conditions while providing high-probability entry and exit signals through breakthrough and rejection detection with comprehensive visual mapping and alert integration.
🔶 Advanced Channel Construction
Implements dual-zone architecture using recent price extremes as foundation points, applying EMA smoothing to reduce noise and ATR multipliers for volatility-responsive channel widths. The system creates resistance channels from highest highs and support channels from lowest lows with asymmetric multiplier ratios for optimal market reaction zones.
// Core Channel Calculation Framework
ATR = ta.atr(14)
// Resistance Channel Construction
Resistance_Basis = ta.ema(ta.highest(high, lookback), lookback)
Resistance_Upper = Resistance_Basis + (ATR * resistance_mult)
Resistance_Lower = Resistance_Basis - (ATR * resistance_mult * 0.3)
// Support Channel Construction
Support_Basis = ta.ema(ta.lowest(low, lookback), lookback)
Support_Upper = Support_Basis + (ATR * support_mult * 0.4)
Support_Lower = Support_Basis - (ATR * support_mult)
// Smoothing Application
Smoothed_Resistance_Upper = ta.ema(Resistance_Upper, smooth_periods)
Smoothed_Support_Lower = ta.ema(Support_Lower, smooth_periods)
🔶 Volatility-Adaptive Zone Framework
Features dynamic ATR-based width adjustment that expands channels during high-volatility periods and contracts during consolidation phases, preventing false signals while maintaining sensitivity to genuine breakouts. The asymmetric multiplier system optimizes zone boundaries for realistic market behavior patterns.
// Dynamic Volatility Adjustment
Channel_Width_Resistance = ATR * resistance_mult
Channel_Width_Support = ATR * support_mult
// Asymmetric Zone Optimization
Resistance_Zone = Resistance_Basis ± (ATR_Multiplied * )
Support_Zone = Support_Basis ± (ATR_Multiplied * )
🔶 Step-Like Boundary Evolution
Creates horizontal step boundaries that update on smoothed bound changes, providing visual history of evolving support and resistance levels with performance-optimized array management limited to 50 historical levels for clean chart presentation and efficient processing.
🔶 Comprehensive Signal Detection
Generates break and bounce signals through sophisticated crossover analysis, monitoring price interaction with smoothed channel boundaries for high-probability entry and exit identification. The system distinguishes between breakthrough continuation and rejection reversal patterns with precision timing.
🔶 Enhanced Visual Architecture
Provides translucent zone fills with gradient intensity scaling, step-like historical boundaries, and dynamic background highlighting that activates upon zone entry. The visual system uses institutional color coding with red resistance zones and green support zones for intuitive
market structure interpretation.
🔶 Intelligent Zone Management
Implements automatic zone relevance filtering, displaying channels only when price proximity warrants analysis attention. The system maintains optimal performance through smart array management and historical level tracking with configurable lookback periods for various market conditions.
🔶 Multi-Dimensional Analysis Framework
Combines trend continuation analysis through breakthrough patterns with reversal detection via rejection signals, providing comprehensive market structure assessment suitable for both trending and ranging market conditions with volatility-normalized accuracy.
🔶 Advanced Alert Integration
Features comprehensive notification system covering breakouts, breakdowns, rejections, and bounces with customizable alert conditions. The system enables precise position management through real-time notifications of critical channel interaction events and zone boundary violations.
🔶 Performance Optimization
Utilizes efficient EMA smoothing algorithms with configurable periods for noise reduction while maintaining responsiveness to genuine market structure changes. The system includes automatic historical level cleanup and performance-optimized visual rendering for smooth operation across all timeframes.
Why Choose Dual Channel System ?
This indicator delivers sophisticated channel-based market analysis through volatility-adaptive ATR calculations and intelligent zone construction methodology. By combining dynamic support and resistance detection with advanced signal generation and comprehensive visual mapping, it provides institutional-grade channel analysis suitable for cryptocurrency, forex, and equity markets. The system's ability to adapt to varying volatility conditions while maintaining signal accuracy makes it essential for traders seeking systematic approaches to breakout trading, zone reversals, and trend continuation analysis with clearly defined risk parameters and comprehensive alert integration. Also to note, this indicator is best suited for the 1D timeframe.
PDT AI✅ Features
Multi-indicator fusion: RSI + MACD + EMA + higher timeframe RSI
Signal strength (%): Each signal gets a confidence score (0–100)
Dynamic ATR-based targets and stops
Alerts: Buy/Sell triggers for real-time notifications
Fully customizable inputs