CandelaCharts - NWOG & NDOG📝 Overview
In trading, opening gaps aren’t just noise—they’re clues. Two key ones are the New Week Opening Gap (NWOG) and the New Day Opening Gap (NDOG).
The NWOG forms between Friday’s close (5 PM EST) and Sunday’s open (6 PM EST). It often acts as a magnet—price tends to revisit it, sometimes days or even weeks later. The NDOG is the daily version, showing imbalances at the start of each session.
Between two NWOGs, the Event Horizon (EH)—the midpoint—often becomes a pull for price. When the price hits it, there's a good chance it keeps moving toward the next gap.
I also watch the Optimal Trade Entry (OTE) zones, usually around the 0.68–0.79 retracements between NWOGs. These levels often line up with institutional interest and make solid spots for entries.
To simplify all this, I use an indicator that automatically detects NWOGs and NDOGs, then plots the EH and OTE levels in real time. No manual drawing. Just clean, updated levels every week.
These gaps and their derived levels help map where price is likely to go—and when to act.
📦 Features
MTF
Mitigation
Consequent Encroachment
Threshold
Hide Overlap
Advanced Styling
⚙️ Settings
Show: Controls whether NWOG/NDOG gaps are displayed on the chart.
Show Last: Sets the number of NWOG/NDOG you want to display.
Length: Determines the length of each NWOG/NDOG.
Mitigation: Highlights when an NWOG/NDOG has been touched, using a different color without marking it as invalid.
Timeframe: Specifies the timeframe used to detect NWOG/NDOGs.
Threshold: Sets the minimum gap size required for NWOG/NDOG detection on the chart.
Event Horizon: Controls whether EHs are displayed on the chart.
Show Mid-Line: Configures the midpoint line's width and style within the NWOG/NDOG. (Consequent Encroachment - CE)
Show Border: Defines the border width and line style of the NWOG/NDOG.
Hide Overlap: Removes overlapping NWOG/NDOG from view.
Extend: Extends the NWOG/NDOG length to the current candle.
Elongate: Fully extends the NWOG/NDOG length to the right side of the chart.
⚡️ Showcase
Simple
Mitigated
Bordered
Consequent Encroachment
Extended
Event Horizon
🚨 Alerts
This script provides alert options for all signals.
Bearish Signal
A bearish signal is triggered if the price enters a bearish NWOG/NDOG zone.
Bullish Signal
A bullish signal is triggered if the price enters a bullish NWOG/NDOG zone.
⚠️ Disclaimer
Trading involves significant risk, and many participants may incur losses. The content on this site is not intended as financial advice and should not be interpreted as such. Decisions to buy, sell, hold, or trade securities, commodities, or other financial instruments carry inherent risks and are best made with guidance from qualified financial professionals. Past performance is not indicative of future results.
Trend Analizi
Strenth Comparison [joshu]Strenth Comparison visualizes relative performance across a basket of assets by measuring percent change from the chosen anchor timeframe’s open.
Each new anchor period resets the baseline to 0%, making it easy to spot leaders/laggards and momentum shifts over time.
Anchor timeframe (TF, default: 1W): The period used as the performance baseline.
Assets : Currencies or American Indices.
Symbols :
Currencies: CME:6S1!, CME:6E1!, CME:6B1!, CME:6J1!, CME:6A1!, CME:6N1!, TVC:DXY (inverted for comparability).
American Indices: CME_MINI:ES1!, CME_MINI:NQ1!, CBOT_MINI:YM1!, CME_MINI:RTY1!.
Visuals: All lines plotted in percent; DXY is inverted and highlighted; labels show the symbol at the latest bar; zero line for reference; vertical dividers mark new anchor periods.
Use cases: Compare strength/weakness within FX or US index baskets; monitor rotation, divergence, and leadership over weekly (or chosen) cycles.
EMA Trend Regime Filter by JaeheeOverview
This indicator defines bullish/bearish regimes using a five-EMA stack and emits one signal per confirmed regime flip. Optional ATR gap gating and an ADX gate require structure and strength before a switch is confirmed. An optional, subtle center line improves readability. This is not a strategy and it does not execute trades.
Note: This tool is not the ATR-based Supertrend; it uses EMA stacking with ATR/ADX gating.
Why this combination (originality & value)
• EMA stacking provides a clear directional framework.
• ATR gap gating filters compressed/fragile stacks by requiring each adjacent EMA distance to exceed ATR × multiplier.
• A state machine limits signals to one per direction change, reducing alert fatigue.
• Confirm bars + ADX gate elevate the quality of regime recognition under directional pressure.
Together, these components interact to emphasize durable regime shifts while curbing noise typical of sideways phases.
How it works (concept)
EMA stack: Bullish when EMA1 > EMA2 > EMA3 > EMA4 > EMA5; bearish is the reverse.
ATR spacing (optional): When enabled, each EMA gap must exceed ATR × k to qualify for a flip.
Confirmation streak: Conditions must persist for confirmBars before a flip is validated.
Trend-strength gate: A flip is allowed only when ADX ≥ adxMin.
Flip & signal: On validation, a single marker/label is emitted; duplicates are suppressed.
Visual layer (optional): Subtle background/center line for context; visuals do not affect logic.
Why it’s useful
• Regime clarity: A binary bullish/bearish state reduces decision fatigue and aligns your playbook with market context.
• Counter-trend filter: In a bullish regime, counter-trend shorts are discouraged; in a bearish regime, counter-trend longs are discouraged—until the regime flips.
• Signal economy: One signal per confirmed flip helps avoid alert fatigue and over-trading.
• Volatility awareness: ATR gap gating filters compressed EMA stacks that often precede whipsaws.
• Strength confirmation: The ADX gate requires directional pressure before a switch is allowed.
Practical workflows (how it can be used)
• HTF compass (e.g., H4): Use a higher timeframe such as the 4-hour chart to set directional bias; execute on your lower timeframe with your own triggers and risk rules.
• Alignment rule: Trade in the direction of the active regime—prefer long setups during a bullish regime and short setups during a bearish regime—until a confirmed flip occurs.
• Pullback playbook: In a bullish regime, consider pullbacks to structure/MA confluence; in a bearish regime, consider rallies into resistance. Always size risk independently of the indicator.
• Parameter tuning: Adapt confirmBars, ATR × multiplier, and ADX minimum to the instrument’s volatility. Higher thresholds generally reduce noise but may delay flips.
• Alerts/automation: Set alerts on regime flips but confirm on bar close; intrabar values can update.
Context note (BTC, H4)
On higher timeframes such as the 4-hour chart, trends are often more stable. For BTC, the regime can help distinguish whether the broader market is trending up or down: when the H4 regime is bullish, favor long-side opportunities even if lower-timeframe candles retrace; when the regime turns bearish, favor short-side opportunities. This is context, not signals—entries/exits and risk management remain your responsibility.
Key inputs
• EMA lengths (1–5), Confirm Bars, Min Spacing by ATR
• ADX Length, ADX Minimum
• Visualization toggles (background opacity, center line, label/marker colors)
Alerts
• EMA REGIME LONG — fires once on a confirmed bullish regime
• EMA REGIME SHORT — fires once on a confirmed bearish regime
Notes & limitations
• Designed without future-bar references. Values can update intrabar, so confirm on close before acting on signals.
• This is an indicator for study purposes; it does not place trades.
• Parameters may require tuning across symbols/timeframes.
• Publish with a clean chart so the indicator’s output is clearly identifiable.
• Use on standard bar types (e.g., candles). Non-standard chart types can yield unrealistic behavior for signal logic.
Trend and Reverse AI indicator Declaration: NO REPAINTING, NO LAG, NO DISPLACEMENT – SIGNALS NEVER DISAPPEAR!
Indicator Usage Guide (Simple & Effective):
(1) Red Zone + UP Arrow → Go LONG
(2) Green Zone + DOWN Arrow → Go SHORT
(3) Alternating Red/Green Zones → Consolidation Phase (NO TRADING!)
Default parameters are optimized for reliable signals but can be customized as needed.
Instructions:
(1) This indicator is suitable for any trading instrument (stocks, futures, forex, cryptocurrencies, options, etc.) and any timeframe (minutes, hours, days, weeks, months).
(2) The indicator only provides entry signals (buy/sell signals). It does not provide exit signals. Profitability depends entirely on your holding period. This indicator does not guarantee profits.
(3) Arrows come in Red and Blue, representing two different signal types. Red signals may provide more precise reversal points on the candlestick chart compared to Blue signals.
(4) The indicator plots three distinct trend lines: a Red trend line, a Green trend line, and a Yellow trend line.
(5) * When the Red trend line is ABOVE the Yellow trend line, it signifies a Bullish (uptrend) market,consider taking LONG positions based on arrow signals.
* When the Green trend line is BELOW the Yellow trend line, it signifies a Bearish (downtrend) market,consider taking SHORT positions based on arrow signals.
* When the Red and Green trend lines are ALTERNATING (crossing frequently), it signifies a Ranging (sideways/consolidation) market, arrow signals are less reliable during this phase, and trading is NOT recommended.
RCI Signal MapRCIの短期中期長期の方向が一致した時に矢印が出ます。
それだけのツールです。
The arrow signs appear when the short, medium, medium-term and long-term directions of the RCI coincide.
That is all there is to this tool.
Live NY Session Movement (points)//@version=5
indicator("Live NY Session Movement (points)", overlay=true)
// --- Inputs ---
nySession = input.session("0830-1700", "NY Session (local NY time)")
nyTimezone = input.string("America/New_York", "Session Timezone")
showShade = input.bool(true, "Shade NY Session")
// --- In-session detection (per-bar) ---
inNy = not na(time(timeframe.period, nySession, nyTimezone))
// --- Track session H/L and live movement ---
var float sessHigh = na
var float sessLow = na
var label liveLab = na
var bool wasIn = false
// session edge flags
justStarted = inNy and not wasIn
justEnded = not inNy and wasIn
wasIn := inNy
if justStarted
sessHigh := high
sessLow := low
if inNy
sessHigh := na(sessHigh) ? high : math.max(sessHigh, high)
sessLow := na(sessLow) ? low : math.min(sessLow, low)
movePts = sessHigh - sessLow
// create once, then update in place each bar
if na(liveLab)
liveLab := label.new(bar_index, high, "NY Move: " + str.tostring(movePts, format.mintick), style=label.style_label_down, textcolor=color.white, color=color.new(color.blue, 0), size=size.small)
label.set_x(liveLab, bar_index)
label.set_y(liveLab, high)
label.set_text(liveLab, "NY Move: " + str.tostring(movePts, format.mintick))
else
// clean up at end of session
sessHigh := na
sessLow := na
if not na(liveLab)
label.delete(liveLab)
liveLab := na
// Optional: shade the session so you can see it clearly
bgcolor(showShade and inNy ? color.new(color.blue, 92) : na)
Vegas Trend Filter[SpeculationLab]This script combines Vegas Tunnel trend filtering with Engulfing Pattern detection to identify trend-following reversal entries.
It uses multi-timeframe EMA tunnels to determine market direction, and filters signals by combining engulfing patterns with price proximity to the tunnel.
Key Features:
1. Vegas Tunnel Trend Filter
・Short tunnel: 144 EMA & 169 EMA
・Long tunnel: 576 EMA & 676 EMA
・Trend definition: Short tunnel entirely above/below the long tunnel
・ATR gap filter to avoid false signals when tunnels are overlapping
2.Engulfing Pattern Detection
・Mode options:
・Body: Current candle’s body fully engulfs the previous body
・Range (default): Current candle’s wicks fully cover the previous high/low range
・Optional “Require opposite previous candle” filter
3.Touch Filter
・Mode options:
・Body: Candle body touches/approaches the Vegas tunnel
・Wick (default): Candle wick touches/approaches the Vegas tunnel
・Adjustable tolerance for proximity detection
4.Short-Term Trend Filter
・Linear regression slope to identify pullbacks or rebounds
・Avoids entering mid-trend without a retracement
5.Signal Marking
・BUY: Trend up + touch filter + bullish engulfing + EMA data valid
・SELL: Trend down + touch filter + bearish engulfing + EMA data valid
・Signals are confirmed at candle close to avoid intrabar repainting
Originality Statement:
This script is originally developed by SpeculationLab , with all logic independently designed and coded by the author. Do not copy, resell, or publish under another name.
Disclaimer:
This script is for technical research and market analysis purposes only and does not constitute financial advice. Any trading decisions made based on this script are solely at the user’s own risk.
本脚本结合 Vegas 通道趋势过滤 与 吞没形态识别,用于识别顺势反转的交易机会。
通过多周期 EMA 构建的 Vegas 通道判断趋势方向,并结合吞没形态与价格接触通道的条件,过滤掉大部分低质量信号。
主要功能:
1.Vegas Tunnel 趋势过滤
・短周期隧道(144 EMA、169 EMA)与长周期隧道(576 EMA、676 EMA)
・趋势判定:短隧道整体高于/低于长隧道
・ATR 间距过滤,避免通道缠绕产生假信号
2.吞没形态识别(Engulfing Pattern)
・模式选择:
・Body:实体包裹前一根实体
・Range(默认):影线包裹前一根区间
・可选“上一根必须颜色相反”条件
3.接触判定(Touch Filter)
・模式选择:
・Body:实体接触/接近 Vegas 通道
・Wick(默认):影线接触/接近 Vegas 通道
・容差可调(Tolerance)
4.短期趋势过滤
・线性回归斜率判断短期回调或反弹
・避免顺势中途乱入
5.信号标记
・多头信号(BUY):顺势 + 接触通道 + 符合吞没条件 + EMA 数据有效
・空头信号(SELL):顺势 + 接触通道 + 符合吞没条件 + EMA 数据有效
・信号在 K 线收盘确认后生成,避免盘中反复变化
原创声明:
本脚本为 SpeculationLab 原创开发,全部逻辑均由作者独立设计与编写。请勿抄袭、售卖或冒充作者发布。
免责声明:
本脚本仅供技术研究与市场分析参考,不构成投资建议。任何基于本脚本的交易决策及其后果,由使用者自行承担。
21-50 Crossover - Sharad21/50 EMA Crossover Strategy with Alerts
This indicator is designed around the classic 21 EMA and 50 EMA crossover method, a time-tested approach for identifying potential trend shifts.
Bullish Signal: When the 21 EMA crosses above the 50 EMA, a possible long setup is indicated.
Bearish Signal: When the 21 EMA crosses below the 50 EMA, a possible short setup is indicated.
Custom Alerts: You can set alerts for crossover events to plan your entries and exits without constantly watching the charts.
How to Use:
Combine with price action, support/resistance zones, or other technical tools for better accuracy.
Works on multiple timeframes and markets (crypto, forex, stocks, indices).
⚠ Disclaimer:
Trading involves substantial risk and is not suitable for everyone. This tool is provided for educational purposes only and should be used with caution. Past performance does not guarantee future results. You are solely responsible for your trading decisions — trade wisely and manage your risk.
Multi-Timeframe Bias Dashboard + VolatilityWhat it is: A corner table (overlay) that gives a quick higher-timeframe read for Daily / 4H / 1H using EMA alignment, MACD, RSI, plus a volatility gauge.
How it works (per timeframe):
EMA block (50/100/200): “Above/Below/Mixed” based on price vs all three EMAs.
MACD: “Bullish/Bearish/Neutral” from MACD line vs Signal and histogram sign.
RSI: Prints the value and an ↑/↓ based on 50 line.
Volatility: Compares ATR(14) to its SMA over 20 bars → High (>*1.2), Normal, Low (<*0.8).
Bias: Combines three votes (EMA, MACD, RSI):
Bullish if ≥2 bullish, Bearish if ≥2 bearish, else Mixed.
Display:
Rows: D / 4H / 1H.
Columns: Bias, EMA(50/100/200), RSI, MACD, Volatility.
Bias cell is color-coded (green/red/gray).
Position setting lets you park the table in Top Right / Bottom Right / Bottom Left (works on mobile too).
Use it for:
Quickly aligning intraday setups with higher-TF direction.
Skipping low-volatility periods.
Confirming momentum (MACD/RSI) when price returns to your OB/FVG zones.
TP11(TP11FE)//version=6
indicator("อินดี้ tp 11 (TP11FE)", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500)
//================ Inputs ================
group200 = "EMA200 / 5up-5down"
emaLen200 = input.int(200, "EMA length (ฐาน EMA200)", minval=1, group=group200)
show200Mid = input.bool(true, "แสดง EMA200 (midline)", group=group200)
show200_5u = input.bool(true, "แสดง 5up (จาก EMA200)", group=group200)
show200_5d = input.bool(true, "แสดง 5down (จาก EMA200)", group=group200)
group85 = "EMA85 (เฉพาะ 4 up / 4 down)"
emaLen85 = input.int(85, "EMA length สำหรับเส้น 4up/4down", minval=1, group=group85)
show85_4u = input.bool(true, "แสดง EMA85 — 4 up", group=group85)
show85_4d = input.bool(true, "แสดง EMA85 — 4 down", group=group85)
group35 = "EMA35"
emaLen35 = input.int(35, "EMA35 length", minval=1, group=group35)
showEMA35 = input.bool(true, "แสดง EMA35", group=group35)
groupPNR = "PNR (Percentile Nearest Rank)"
pnrLen = input.int(15, "PNR length (จำนวนแท่งในหน้าต่าง)", minval=1, group=groupPNR)
pnrPerc = input.int(50, "PNR Percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "PNR Source", group=groupPNR)
showPNR = input.bool(true, "แสดงเส้น PNR", group=groupPNR)
groupDSI = "Dynamic Structure Indicator (DSI)"
showDSI = input.bool(true, "แสดง DSI (โซน S/R ไดนามิก)", group=groupDSI)
atrMovement = input.float(1.0, "ATR Movement Required", step=0.5, group=groupDSI)
lookback = input.int(25, "High/Low Lookback", step=5, group=groupDSI)
maxZoneSize = input.float(2.5, "Max Zone Size (เทียบกับ ATR)", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "Zone Update Count Before Reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "Draw Previous Structure (RS/SR)", group=groupDSI)
groupFE = "FE Settings"
feLenBars = input.int(35, "FE length (bars) จาก P3", minval=5, group=groupFE)
feLife = input.int(500, "อายุเส้น FE (bars) ก่อนลบ", minval=50, group=groupFE)
showFE = input.bool(true, "แสดงเส้น FE", group=groupFE)
colBand = input.color(color.teal, "สีเส้น 95/105", group=groupFE)
colBandFill = input.color(color.new(color.teal, 85), "สีแถบ 95–105", group=groupFE)
col1618 = input.color(color.orange, "สีเส้น 161.8", group=groupFE)
col2618 = input.color(color.fuchsia, "สีเส้น 261.8", group=groupFE)
groupP1P2P3 = "Options for P1/P2/P3"
p1Lookback = input.int(200, "กรอบย้อนซ้ายสูงสุดสำหรับหา P1", minval=20, group=groupP1P2P3)
useCloseForEMA35 = input.bool(false, "EMA35 ใช้ close (แทน effClose)", group=groupP1P2P3)
groupPerf = "Performance / Safety"
p3MaxWindowBars = input.int(600, "จำกัดจำนวนแท่งสูงสุดที่สแกนหา P3", minval=100, maxval=2000, step=50, group=groupPerf)
//================ Colors ================
colMid200 = color.rgb(100, 50, 0)
col5band = color.rgb(200,170, 0)
col85_4 = color.rgb(90, 140, 230)
col35 = color.new(color.blue, 0)
colPNR = color.rgb(255, 17, 0)
//================ Core helpers ================
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
//================ EMA200 + 5up/5down ================
= f_core(emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="5down (EMA200)", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="EMA200 (midline)", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="5up (EMA200)", color=col5band, linewidth=3)
//================ EMA85 — เฉพาะ 4up/4down ================
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
plot(show85_4u ? up4_85 : na, title="EMA85 — 4 up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="EMA85 — 4 down", color=col85_4, linewidth=2)
//================ EMA35 ========================
float ema35 = useCloseForEMA35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="EMA35", color=col35, linewidth=2)
//================ PNR ==========================
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc)
array.sort(win)
int idx = int(math.round(pnrPerc / 100.0 * pnrLen)) - 1
idx := idx < 0 ? 0 : (idx > pnrLen - 1 ? pnrLen - 1 : idx)
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="PNR", color=colPNR, linewidth=2)
//==================== P1 / P2 / P3 + FE ====================//
// ---------- Utilities ----------
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open, close)
bodyBot_at(i) => f_bodyBot(open, close)
aboveEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bt >= midv) : ((bt - math.max(bb, midv)) / body >= 0.75)
belowEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bb <= midv) : ((math.min(bt, midv) - bb) / body >= 0.75)
// ------- ตรวจ P2 (Long) ที่ offset i -------
isP2Long_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool green = isGreen_at(i)
float fu = fiveUp_200
float bb = bodyBot_at(i)
bool bodyAbove5 = not na(fu) and bb >= fu
float M2 = f_midBody_at(i)
bool leftOK = close <= M2 and close <= M2
bool rightOK = close <= M2 and close <= M2
hasRoom and green and bodyAbove5 and leftOK and rightOK
// ------- ตรวจ P2 (Short) ที่ offset i -------
isP2Short_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool red = isRed_at(i)
float fd = fiveDown_200
float bt = bodyTop_at(i)
bool bodyBelow5 = not na(fd) and bt <= fd
float M2s = f_midBody_at(i)
bool leftOK = close >= M2s and close >= M2s
bool rightOK = close >= M2s and close >= M2s
hasRoom and red and bodyBelow5 and leftOK and rightOK
// ------- หา P1 จากสตรีค (Long) โดยใช้ offset ของ P2 -------
f_findP1_long_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isGreen_at(i) and aboveEMA75_at(i)
foundRight := i
break
if na(foundRight)
int loBar = p2Off
float loVal = bodyBot_at(p2Off)
for i = p2Off to maxOff
float v = bodyBot_at(i)
if v < loVal
loVal := v
loBar := i
[open , loBar]
else
int j = foundRight
while j < 5000 and isGreen_at(j+1) and aboveEMA75_at(j+1)
j += 1
[open , j]
// ------- หา P1 (Short) โดยใช้ offset ของ P2 -------
f_findP1_short_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isRed_at(i) and belowEMA75_at(i)
foundRight := i
break
if na(foundRight)
int hiBar = p2Off
float hiVal = bodyTop_at(p2Off)
for i = p2Off to maxOff
float v = bodyTop_at(i)
if v > hiVal
hiVal := v
hiBar := i
[open , hiBar]
else
int j = foundRight
while j < 5000 and isRed_at(j+1) and belowEMA75_at(j+1)
j += 1
[open , j]
// ------- เลือก P3 ภายในหน้าต่าง (offset ช่วง start..end; step บวกเสมอ) -------
f_bin(v) => math.round(v / syminfo.mintick) * syminfo.mintick
f_pickP3_window(winStartOff, winEndOff, isLong) =>
// --- Normalize window ---
int s0 = math.min(winStartOff, winEndOff)
int e0 = math.max(winStartOff, winEndOff)
// --- Clamp to Pine's history limit (0..10000) และไม่เกินจำนวนแท่งที่มีอยู่ ---
int eCap = math.min(e0, math.min(10000, bar_index))
int sMin = math.max(0, s0)
// --- จำกัดความกว้างหน้าต่างตาม p3MaxWindowBars ---
int sTmp = math.max(eCap - p3MaxWindowBars + 1, sMin)
int s = math.max(0, math.min(sTmp, eCap))
int e = eCap
// ถ้า window กลายเป็นว่าง ให้คืนค่า na
if e < 0 or s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float minOpen = open
int minIdx = s
float maxOpen = open
int maxIdx = s
float prevBin = na
int curRun = 0
for t = s to e
float bin = f_bin(open )
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
if open < minOpen
minOpen := open
minIdx := t
if open > maxOpen
maxOpen := open
maxIdx := t
prevBin := bin
// หา cluster ≥ 3
int best = na
int bestCnt = 0
int bestRun = 0
int bestFirst = na
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= 3
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if not na(best)
int pickOff = array.get(firstI, best)
[open , pickOff]
else
if isLong
[open , minIdx]
else
[open , maxIdx]
// --------- สถานะ / ค่าที่ต้องจำ ---------
var int L_stage = 0
var int L_P2Abs = na
var float L_P2Close = na
var float L_M2 = na
var float L_P1Open = na
var int S_stage = 0
var int S_P2Abs = na
var float S_P2Close = na
var float S_M2 = na
var float S_P1Open = na
// --------- FE storage ---------
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_add_fe_set(p3Abs, y95, y105, y161, y261) =>
int x1 = p3Abs, x2 = p3Abs + feLenBars
line l95 = line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l105 = line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l161 = line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=col1618, width=2)
line l261 = line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=col2618, width=2)
linefill lf = linefill.new(l95, l105, color=colBandFill)
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_fill, lf)
array.push(FE_born, p3Abs)
f_delete_fe_index(idx) =>
linefill.delete(array.get(FE_fill, idx))
line.delete(array.get(FE_l95, idx))
line.delete(array.get(FE_l105, idx))
line.delete(array.get(FE_l161, idx))
line.delete(array.get(FE_l261, idx))
array.remove(FE_l95, idx)
array.remove(FE_l105, idx)
array.remove(FE_l161, idx)
array.remove(FE_l261, idx)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
// ลบตามอายุ (เดินหน้าแล้วอ้างย้อนกลับ เพื่อเลี่ยง step ติดลบ)
if array.size(FE_born) > 0
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
int born = array.get(FE_born, i)
if bar_index >= born + feLife
f_delete_fe_index(i)
// --------- เครื่องจักรสถานะ: Long ---------
int candL = 2
if bar_index >= 4 and L_stage == 0
if isP2Long_at(candL)
L_P2Abs := bar_index - candL
L_P2Close := close
L_M2 := f_midBody_at(candL)
= f_findP1_long_rel(candL)
L_P1Open := __p1OpenTmp
L_stage := 1
if L_stage == 1
int p2Ago = bar_index - L_P2Abs
if p2Ago >= 1 and close <= L_M2
L_stage := 2
if L_stage == 2
if isGreen_at(0) and close >= L_M2
int p2Ago = bar_index - L_P2Abs
int wStart = 0
int wEnd = math.max(p2Ago - 1, 0) // ไม่รวมแท่ง P2 เอง
= f_pickP3_window(wStart, wEnd, true)
int p3Abs = bar_index - p3Off
float wave = L_P2Close - L_P1Open
if showFE and wave > 0 and not na(p3Open)
float y95 = p3Open + 0.95 * wave
float y105 = p3Open + 1.05 * wave
float y1618 = p3Open + 1.618 * wave
float y2618 = p3Open + 2.618 * wave
f_add_fe_set(p3Abs, y95, y105, y1618, y2618)
L_stage := 0
L_P2Abs := na, L_P2Close := na, L_M2 := na, L_P1Open := na
// --------- เครื่องจักรสถานะ: Short ---------
int candS = 2
if bar_index >= 4 and S_stage == 0
if isP2Short_at(candS)
S_P2Abs := bar_index - candS
S_P2Close := close
S_M2 := f_midBody_at(candS)
= f_findP1_short_rel(candS)
S_P1Open := __p1OpenTmpS
S_stage := 1
if S_stage == 1
int p2SAgo = bar_index - S_P2Abs
if p2SAgo >= 1 and close >= S_M2
S_stage := 2
if S_stage == 2
if isRed_at(0) and close <= S_M2
int p2SAgo = bar_index - S_P2Abs
int wStartS = 0
int wEndS = math.max(p2SAgo - 1, 0)
= f_pickP3_window(wStartS, wEndS, false)
int p3AbsS = bar_index - p3OffS
float waveS = S_P1Open - S_P2Close
if showFE and waveS > 0 and not na(p3OpenS)
float y95s = p3OpenS - 0.95 * waveS
float y105s = p3OpenS - 1.05 * waveS
float y1618s = p3OpenS - 1.618 * waveS
float y2618s = p3OpenS - 2.618 * waveS
f_add_fe_set(p3AbsS, y95s, y105s, y1618s, y2618s)
S_stage := 0
S_P2Abs := na, S_P2Close := na, S_M2 := na, S_P1Open := na
//==================== DSI (Dynamic Structure Indicator) ====================
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
// ระบุชนิดชัดเจนเพื่อหลีกเลี่ยง NA-type
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na, dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na, dsi_potS2 := na
// ยืนยัน RS/SR เมื่อราคาวิ่งผ่านระยะ ATR ตามที่กำหนด
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_supCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_supCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_resCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_resCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? color.green : color.new(color.red, 50)) : color.new(color.black, 100), title="DSI Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? color.red : color.new(color.green, 50)) : color.new(color.black, 100), title="DSI Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=color.red, style=plot.style_linebr, title="DSI PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=color.red, style=plot.style_linebr, title="DSI PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(color.red, 10) : color.new(color.black, 100), title="DSI Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=color.green, style=plot.style_linebr, title="DSI PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=color.green, style=plot.style_linebr, title="DSI PR2")
fill(dsi_pr1plot, dsi_pr2plot, color=showDSI and drawPreviousStructure ? color.new(color.green, 10) : color.new(color.black, 100), title="DSI Previous Resistance Zone")
Gann Box LogicGann Box Logic
Overview
The Gann Box Logic indicator is a precision-based trading tool that combines the principles of Gann analysis with retracement logic to highlight high-probability zones of price action. It plots a structured box on the chart based on the previous day's high and low, overlays Fibonacci-derived retracement levels, and visually marks a critical “neutral zone” between 38.2% and 61.8% retracements.
This zone — shaded for emphasis — is a decision filter for traders:
- It warns against initiating trades in this area (low conviction zone).
- It identifies reversal pull targets when extremes are reached.
Core Principles Behind Gann Box Logic
Logic 1 — The Neutral Zone (38.2% ↔ 61.8%)
- The 38.2% and 61.8% retracement levels are key Fibonacci ratios often associated with consolidation or indecision.
- Price action between these two levels is considered a neutral, low-conviction zone.
- Trading Recommendation:
- Avoid initiating new trades while price remains within this shaded band.
- This zone tends to produce whipsaws and false signals.
- Wait for a decisive break above 61.8% or below 38.2% for clearer momentum.
- Why it matters:
- In Gann’s market structure thinking, the middle range of a swing is often a battleground where neither bulls nor bears are in full control.
- This is the zone where market makers often shake out weak hands before committing to a direction.
Logic 2 — Extremes Seek Balance (0% & 100% Reversal Bias)
- The indicator’s 0% and 100% levels represent the previous day’s low and high respectively.
- First Touch Rule:
- When the price touches 0% (previous low) or 100% (previous high) for the first time in the current session, there is a high probability it will attempt to revert toward the center zone (38.2% ↔ 61.8%).
- Trading Implication:
- If price spikes to an extreme, be alert for reversion trades toward the mid-zone rather than expecting a sustained breakout.
- Momentum traders may still pursue breakout trades, but this bias warns of potential pullbacks.
- Why it works:
- Extreme levels often trigger profit-taking by early entrants and counter-trend entries by mean-reversion traders.
- These forces naturally pull the market back toward equilibrium — often near the 50% level or within the shaded zone.
How the Indicator is Plotted
1. Previous Day High/Low Reference — The script locks onto the prior day’s range to establish the vertical bounds of the box.
2. Retracement Levels — Key Fibonacci levels plotted: 0%, 25%, 38.2%, 50%, 61.8%, 75%, 100%.
3. Box Structure — Outer Border marks the full prior day range, Mid Fill Zone is shaded between 38.2% and 61.8%.
4. VWAP (Optional) — Daily VWAP overlay for intraday bias confirmation.
Practical Usage Guide
- Avoid Trades in Neutral Zone — Stay out of the shaded area unless you’re already in a trade from outside this zone.
- Watch for First Touch Extremes — First touch at 0% or 100% → anticipate a pullback toward the shaded zone.
- Breakout Confirmation — Only commit to breakout trades when price leaves the 38.2–61.8% zone with strong volume and momentum.
- VWAP Confluence — VWAP crossing through the shaded zone often signals a balance day — breakout expectations should be tempered.
Strengths of Gann Box Logic
- Removes noise trades during low-conviction periods.
- Encourages patience and discipline.
- Highlights key market turning points.
- Provides clear visual structure for both new and advanced traders.
Limitations & Warnings
- Not a standalone entry system — best used in conjunction with price action and volume analysis.
- Extreme moves can sometimes trend without reversion, especially during news-driven sessions.
- Works best on intraday timeframes when referencing the previous day’s range.
In Summary
The Gann Box Logic indicator’s philosophy can be boiled down to two golden rules:
1. Do nothing in the middle — Avoid trades between 38.2% and 61.8%.
2. Expect balance from extremes — First touches at 0% or 100% often pull back toward the shaded mid-zone.
This dual approach makes the indicator both a trade filter and a targeting guide, allowing traders to navigate markets with a structured, Gann-inspired framework.
DISCLAIMER
The information provided by this indicator is for educational purposes only and should not be considered financial advice. Trading carries risk, including possible loss of capital. Past performance does not guarantee future results. Always conduct your own research and consult with a qualified financial professional before making trading decisions.
tp 11 (TP11FE.)//@version=6
indicator("อินดี้ tp 11 (TP11FE)", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500)
//================ Inputs ================
group200 = "EMA200 / 5up-5down"
emaLen200 = input.int(200, "EMA length (ฐาน EMA200)", minval=1, group=group200)
show200Mid = input.bool(true, "แสดง EMA200 (midline)", group=group200)
show200_5u = input.bool(true, "แสดง 5up (จาก EMA200)", group=group200)
show200_5d = input.bool(true, "แสดง 5down (จาก EMA200)", group=group200)
group85 = "EMA85 (เฉพาะ 4 up / 4 down)"
emaLen85 = input.int(85, "EMA length สำหรับเส้น 4up/4down", minval=1, group=group85)
show85_4u = input.bool(true, "แสดง EMA85 — 4 up", group=group85)
show85_4d = input.bool(true, "แสดง EMA85 — 4 down", group=group85)
group35 = "EMA35"
emaLen35 = input.int(35, "EMA35 length", minval=1, group=group35)
showEMA35 = input.bool(true, "แสดง EMA35", group=group35)
groupPNR = "PNR (Percentile Nearest Rank)"
pnrLen = input.int(15, "PNR length (จำนวนแท่งในหน้าต่าง)", minval=1, group=groupPNR)
pnrPerc = input.int(50, "PNR Percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "PNR Source", group=groupPNR)
showPNR = input.bool(true, "แสดงเส้น PNR", group=groupPNR)
groupDSI = "Dynamic Structure Indicator (DSI)"
showDSI = input.bool(true, "แสดง DSI (โซน S/R ไดนามิก)", group=groupDSI)
atrMovement = input.float(1.0, "ATR Movement Required", step=0.5, group=groupDSI)
lookback = input.int(25, "High/Low Lookback", step=5, group=groupDSI)
maxZoneSize = input.float(2.5, "Max Zone Size (เทียบกับ ATR)", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "Zone Update Count Before Reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "Draw Previous Structure (RS/SR)", group=groupDSI)
groupFE = "FE Settings"
feLenBars = input.int(35, "FE length (bars) จาก P3", minval=5, group=groupFE)
feLife = input.int(500, "อายุเส้น FE (bars) ก่อนลบ", minval=50, group=groupFE)
showFE = input.bool(true, "แสดงเส้น FE", group=groupFE)
colBand = input.color(color.teal, "สีเส้น 95/105", group=groupFE)
colBandFill = input.color(color.new(color.teal, 85), "สีแถบ 95–105", group=groupFE)
col1618 = input.color(color.orange, "สีเส้น 161.8", group=groupFE)
col2618 = input.color(color.fuchsia, "สีเส้น 261.8", group=groupFE)
groupP1P2P3 = "Options for P1/P2/P3"
p1Lookback = input.int(200, "กรอบย้อนซ้ายสูงสุดสำหรับหา P1", minval=20, group=groupP1P2P3)
useCloseForEMA35 = input.bool(false, "EMA35 ใช้ close (แทน effClose)", group=groupP1P2P3)
groupPerf = "Performance / Safety"
p3MaxWindowBars = input.int(600, "จำกัดจำนวนแท่งสูงสุดที่สแกนหา P3", minval=100, maxval=2000, step=50, group=groupPerf)
//================ Colors ================
colMid200 = color.rgb(100, 50, 0)
col5band = color.rgb(200,170, 0)
col85_4 = color.rgb(90, 140, 230)
col35 = color.new(color.blue, 0)
colPNR = color.rgb(255, 17, 0)
//================ Core helpers ================
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
//================ EMA200 + 5up/5down ================
= f_core(emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="5down (EMA200)", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="EMA200 (midline)", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="5up (EMA200)", color=col5band, linewidth=3)
//================ EMA85 — เฉพาะ 4up/4down ================
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
plot(show85_4u ? up4_85 : na, title="EMA85 — 4 up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="EMA85 — 4 down", color=col85_4, linewidth=2)
//================ EMA35 ========================
float ema35 = useCloseForEMA35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="EMA35", color=col35, linewidth=2)
//================ PNR ==========================
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc )
array.sort(win)
int idx = int(math.round(pnrPerc / 100.0 * pnrLen)) - 1
idx := idx < 0 ? 0 : (idx > pnrLen - 1 ? pnrLen - 1 : idx)
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="PNR", color=colPNR, linewidth=2)
//==================== P1 / P2 / P3 + FE ====================//
// ---------- Utilities ----------
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open , close )
bodyBot_at(i) => f_bodyBot(open , close )
aboveEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bt >= midv) : ((bt - math.max(bb, midv)) / body >= 0.75)
belowEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bb <= midv) : ((math.min(bt, midv) - bb) / body >= 0.75)
// ------- ตรวจ P2 (Long) ที่ offset i -------
isP2Long_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool green = isGreen_at(i)
float fu = fiveUp_200
float bb = bodyBot_at(i)
bool bodyAbove5 = not na(fu) and bb >= fu
float M2 = f_midBody_at(i)
bool leftOK = close <= M2 and close <= M2
bool rightOK = close <= M2 and close <= M2
hasRoom and green and bodyAbove5 and leftOK and rightOK
// ------- ตรวจ P2 (Short) ที่ offset i -------
isP2Short_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool red = isRed_at(i)
float fd = fiveDown_200
float bt = bodyTop_at(i)
bool bodyBelow5 = not na(fd) and bt <= fd
float M2s = f_midBody_at(i)
bool leftOK = close >= M2s and close >= M2s
bool rightOK = close >= M2s and close >= M2s
hasRoom and red and bodyBelow5 and leftOK and rightOK
// ------- หา P1 จากสตรีค (Long) โดยใช้ offset ของ P2 -------
f_findP1_long_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isGreen_at(i) and aboveEMA75_at(i)
foundRight := i
break
if na(foundRight)
int loBar = p2Off
float loVal = bodyBot_at(p2Off)
for i = p2Off to maxOff
float v = bodyBot_at(i)
if v < loVal
loVal := v
loBar := i
[open , loBar]
else
int j = foundRight
while j < 5000 and isGreen_at(j+1) and aboveEMA75_at(j+1)
j += 1
[open , j]
// ------- หา P1 (Short) โดยใช้ offset ของ P2 -------
f_findP1_short_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isRed_at(i) and belowEMA75_at(i)
foundRight := i
break
if na(foundRight)
int hiBar = p2Off
float hiVal = bodyTop_at(p2Off)
for i = p2Off to maxOff
float v = bodyTop_at(i)
if v > hiVal
hiVal := v
hiBar := i
[open , hiBar]
else
int j = foundRight
while j < 5000 and isRed_at(j+1) and belowEMA75_at(j+1)
j += 1
[open , j]
// ------- เลือก P3 ภายในหน้าต่าง (offset ช่วง start..end; step บวกเสมอ) -------
f_bin(v) => math.round(v / syminfo.mintick) * syminfo.mintick
f_pickP3_window(winStartOff, winEndOff, isLong) =>
// --- Normalize window ---
int s0 = math.min(winStartOff, winEndOff)
int e0 = math.max(winStartOff, winEndOff)
// --- Clamp to Pine's history limit (0..10000) และไม่เกินจำนวนแท่งที่มีอยู่ ---
int eCap = math.min(e0, math.min(10000, bar_index))
int sMin = math.max(0, s0)
// --- จำกัดความกว้างหน้าต่างตาม p3MaxWindowBars ---
int sTmp = math.max(eCap - p3MaxWindowBars + 1, sMin)
int s = math.max(0, math.min(sTmp, eCap))
int e = eCap
// ถ้า window กลายเป็นว่าง ให้คืนค่า na
if e < 0 or s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float minOpen = open
int minIdx = s
float maxOpen = open
int maxIdx = s
float prevBin = na
int curRun = 0
for t = s to e
float bin = f_bin(open )
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
if open < minOpen
minOpen := open
minIdx := t
if open > maxOpen
maxOpen := open
maxIdx := t
prevBin := bin
// หา cluster ≥ 3
int best = na
int bestCnt = 0
int bestRun = 0
int bestFirst = na
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= 3
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if not na(best)
int pickOff = array.get(firstI, best)
[open , pickOff]
else
if isLong
[open , minIdx]
else
[open , maxIdx]
// --------- สถานะ / ค่าที่ต้องจำ ---------
var int L_stage = 0
var int L_P2Abs = na
var float L_P2Close = na
var float L_M2 = na
var float L_P1Open = na
var int S_stage = 0
var int S_P2Abs = na
var float S_P2Close = na
var float S_M2 = na
var float S_P1Open = na
// --------- FE storage ---------
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_add_fe_set(p3Abs, y95, y105, y161, y261) =>
int x1 = p3Abs, x2 = p3Abs + feLenBars
line l95 = line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l105 = line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l161 = line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=col1618, width=2)
line l261 = line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=col2618, width=2)
linefill lf = linefill.new(l95, l105, color=colBandFill)
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_fill, lf)
array.push(FE_born, p3Abs)
f_delete_fe_index(idx) =>
linefill.delete(array.get(FE_fill, idx))
line.delete(array.get(FE_l95, idx))
line.delete(array.get(FE_l105, idx))
line.delete(array.get(FE_l161, idx))
line.delete(array.get(FE_l261, idx))
array.remove(FE_l95, idx)
array.remove(FE_l105, idx)
array.remove(FE_l161, idx)
array.remove(FE_l261, idx)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
// ลบตามอายุ (เดินหน้าแล้วอ้างย้อนกลับ เพื่อเลี่ยง step ติดลบ)
if array.size(FE_born) > 0
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
int born = array.get(FE_born, i)
if bar_index >= born + feLife
f_delete_fe_index(i)
// --------- เครื่องจักรสถานะ: Long ---------
int candL = 2
if bar_index >= 4 and L_stage == 0
if isP2Long_at(candL)
L_P2Abs := bar_index - candL
L_P2Close := close
L_M2 := f_midBody_at(candL)
= f_findP1_long_rel(candL)
L_P1Open := __p1OpenTmp
L_stage := 1
if L_stage == 1
int p2Ago = bar_index - L_P2Abs
if p2Ago >= 1 and close <= L_M2
L_stage := 2
if L_stage == 2
if isGreen_at(0) and close >= L_M2
int p2Ago = bar_index - L_P2Abs
int wStart = 0
int wEnd = math.max(p2Ago - 1, 0) // ไม่รวมแท่ง P2 เอง
= f_pickP3_window(wStart, wEnd, true)
int p3Abs = bar_index - p3Off
float wave = L_P2Close - L_P1Open
if showFE and wave > 0 and not na(p3Open)
float y95 = p3Open + 0.95 * wave
float y105 = p3Open + 1.05 * wave
float y1618 = p3Open + 1.618 * wave
float y2618 = p3Open + 2.618 * wave
f_add_fe_set(p3Abs, y95, y105, y1618, y2618)
L_stage := 0
L_P2Abs := na, L_P2Close := na, L_M2 := na, L_P1Open := na
// --------- เครื่องจักรสถานะ: Short ---------
int candS = 2
if bar_index >= 4 and S_stage == 0
if isP2Short_at(candS)
S_P2Abs := bar_index - candS
S_P2Close := close
S_M2 := f_midBody_at(candS)
= f_findP1_short_rel(candS)
S_P1Open := __p1OpenTmpS
S_stage := 1
if S_stage == 1
int p2SAgo = bar_index - S_P2Abs
if p2SAgo >= 1 and close >= S_M2
S_stage := 2
if S_stage == 2
if isRed_at(0) and close <= S_M2
int p2SAgo = bar_index - S_P2Abs
int wStartS = 0
int wEndS = math.max(p2SAgo - 1, 0)
= f_pickP3_window(wStartS, wEndS, false)
int p3AbsS = bar_index - p3OffS
float waveS = S_P1Open - S_P2Close
if showFE and waveS > 0 and not na(p3OpenS)
float y95s = p3OpenS - 0.95 * waveS
float y105s = p3OpenS - 1.05 * waveS
float y1618s = p3OpenS - 1.618 * waveS
float y2618s = p3OpenS - 2.618 * waveS
f_add_fe_set(p3AbsS, y95s, y105s, y1618s, y2618s)
S_stage := 0
S_P2Abs := na, S_P2Close := na, S_M2 := na, S_P1Open := na
//==================== DSI (Dynamic Structure Indicator) ====================
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
// ระบุชนิดชัดเจนเพื่อหลีกเลี่ยง NA-type
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na, dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na, dsi_potS2 := na
// ยืนยัน RS/SR เมื่อราคาวิ่งผ่านระยะ ATR ตามที่กำหนด
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_supCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_supCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_resCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_resCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? color.green : color.new(color.red, 50)) : color.new(color.black, 100), title="DSI Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? color.red : color.new(color.green, 50)) : color.new(color.black, 100), title="DSI Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=color.red, style=plot.style_linebr, title="DSI PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=color.red, style=plot.style_linebr, title="DSI PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(color.red, 10) : color.new(color.black, 100), title="DSI Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=color.green, style=plot.style_linebr, title="DSI PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=color.green, style=plot.style_linebr, title="DSI PR2")
fill(dsi_pr1plot, dsi_pr2plot, color=showDSI and drawPreviousStructure ? color.new(color.green, 10) : color.new(color.black, 100), title="DSI Previous Resistance Zone")
Moving Average Ribbon x 8Moving Average Ribbon 8 Lines FH
One indicator shows a moving averages of 8. You can choose different types of moving averages, colours and styles.
tp 11 (TP11FE)//@version=6
indicator("อินดี้ tp 11 (TP11FE)", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500)
//================ Inputs ================
group200 = "EMA200 / 5up-5down"
emaLen200 = input.int(200, "EMA length (ฐาน EMA200)", minval=1, group=group200)
show200Mid = input.bool(true, "แสดง EMA200 (midline)", group=group200)
show200_5u = input.bool(true, "แสดง 5up (จาก EMA200)", group=group200)
show200_5d = input.bool(true, "แสดง 5down (จาก EMA200)", group=group200)
group85 = "EMA85 (เฉพาะ 4 up / 4 down)"
emaLen85 = input.int(85, "EMA length สำหรับเส้น 4up/4down", minval=1, group=group85)
show85_4u = input.bool(true, "แสดง EMA85 — 4 up", group=group85)
show85_4d = input.bool(true, "แสดง EMA85 — 4 down", group=group85)
group35 = "EMA35"
emaLen35 = input.int(35, "EMA35 length", minval=1, group=group35)
showEMA35 = input.bool(true, "แสดง EMA35", group=group35)
groupPNR = "PNR (Percentile Nearest Rank)"
pnrLen = input.int(15, "PNR length (จำนวนแท่งในหน้าต่าง)", minval=1, group=groupPNR)
pnrPerc = input.int(50, "PNR Percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "PNR Source", group=groupPNR)
showPNR = input.bool(true, "แสดงเส้น PNR", group=groupPNR)
groupDSI = "Dynamic Structure Indicator (DSI)"
showDSI = input.bool(true, "แสดง DSI (โซน S/R ไดนามิก)", group=groupDSI)
atrMovement = input.float(1.0, "ATR Movement Required", step=0.5, group=groupDSI)
lookback = input.int(25, "High/Low Lookback", step=5, group=groupDSI)
maxZoneSize = input.float(2.5, "Max Zone Size (เทียบกับ ATR)", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "Zone Update Count Before Reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "Draw Previous Structure (RS/SR)", group=groupDSI)
groupFE = "FE Settings"
feLenBars = input.int(35, "FE length (bars) จาก P3", minval=5, group=groupFE)
feLife = input.int(500, "อายุเส้น FE (bars) ก่อนลบ", minval=50, group=groupFE)
showFE = input.bool(true, "แสดงเส้น FE", group=groupFE)
colBand = input.color(color.teal, "สีเส้น 95/105", group=groupFE)
colBandFill = input.color(color.new(color.teal, 85), "สีแถบ 95–105", group=groupFE)
col1618 = input.color(color.orange, "สีเส้น 161.8", group=groupFE)
col2618 = input.color(color.fuchsia, "สีเส้น 261.8", group=groupFE)
groupP1P2P3 = "Options for P1/P2/P3"
p1Lookback = input.int(200, "กรอบย้อนซ้ายสูงสุดสำหรับหา P1", minval=20, group=groupP1P2P3)
useCloseForEMA35 = input.bool(false, "EMA35 ใช้ close (แทน effClose)", group=groupP1P2P3)
groupPerf = "Performance / Safety"
p3MaxWindowBars = input.int(600, "จำกัดจำนวนแท่งสูงสุดที่สแกนหา P3", minval=100, maxval=2000, step=50, group=groupPerf)
//================ Colors ================
colMid200 = color.rgb(100, 50, 0)
col5band = color.rgb(200,170, 0)
col85_4 = color.rgb(90, 140, 230)
col35 = color.new(color.blue, 0)
colPNR = color.rgb(255, 17, 0)
//================ Core helpers ================
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
//================ EMA200 + 5up/5down ================
= f_core(emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="5down (EMA200)", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="EMA200 (midline)", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="5up (EMA200)", color=col5band, linewidth=3)
//================ EMA85 — เฉพาะ 4up/4down ================
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
plot(show85_4u ? up4_85 : na, title="EMA85 — 4 up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="EMA85 — 4 down", color=col85_4, linewidth=2)
//================ EMA35 ========================
float ema35 = useCloseForEMA35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="EMA35", color=col35, linewidth=2)
//================ PNR ==========================
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc )
array.sort(win)
int idx = int(math.round(pnrPerc / 100.0 * pnrLen)) - 1
idx := idx < 0 ? 0 : (idx > pnrLen - 1 ? pnrLen - 1 : idx)
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="PNR", color=colPNR, linewidth=2)
//==================== P1 / P2 / P3 + FE ====================//
// ---------- Utilities ----------
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open , close )
bodyBot_at(i) => f_bodyBot(open , close )
aboveEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bt >= midv) : ((bt - math.max(bb, midv)) / body >= 0.75)
belowEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bb <= midv) : ((math.min(bt, midv) - bb) / body >= 0.75)
// ------- ตรวจ P2 (Long) ที่ offset i -------
isP2Long_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool green = isGreen_at(i)
float fu = fiveUp_200
float bb = bodyBot_at(i)
bool bodyAbove5 = not na(fu) and bb >= fu
float M2 = f_midBody_at(i)
bool leftOK = close <= M2 and close <= M2
bool rightOK = close <= M2 and close <= M2
hasRoom and green and bodyAbove5 and leftOK and rightOK
// ------- ตรวจ P2 (Short) ที่ offset i -------
isP2Short_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool red = isRed_at(i)
float fd = fiveDown_200
float bt = bodyTop_at(i)
bool bodyBelow5 = not na(fd) and bt <= fd
float M2s = f_midBody_at(i)
bool leftOK = close >= M2s and close >= M2s
bool rightOK = close >= M2s and close >= M2s
hasRoom and red and bodyBelow5 and leftOK and rightOK
// ------- หา P1 จากสตรีค (Long) โดยใช้ offset ของ P2 -------
f_findP1_long_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isGreen_at(i) and aboveEMA75_at(i)
foundRight := i
break
if na(foundRight)
int loBar = p2Off
float loVal = bodyBot_at(p2Off)
for i = p2Off to maxOff
float v = bodyBot_at(i)
if v < loVal
loVal := v
loBar := i
[open , loBar]
else
int j = foundRight
while j < 5000 and isGreen_at(j+1) and aboveEMA75_at(j+1)
j += 1
[open , j]
// ------- หา P1 (Short) โดยใช้ offset ของ P2 -------
f_findP1_short_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isRed_at(i) and belowEMA75_at(i)
foundRight := i
break
if na(foundRight)
int hiBar = p2Off
float hiVal = bodyTop_at(p2Off)
for i = p2Off to maxOff
float v = bodyTop_at(i)
if v > hiVal
hiVal := v
hiBar := i
[open , hiBar]
else
int j = foundRight
while j < 5000 and isRed_at(j+1) and belowEMA75_at(j+1)
j += 1
[open , j]
// ------- เลือก P3 ภายในหน้าต่าง (offset ช่วง start..end; step บวกเสมอ) -------
f_bin(v) => math.round(v / syminfo.mintick) * syminfo.mintick
f_pickP3_window(winStartOff, winEndOff, isLong) =>
// --- Normalize window ---
int s0 = math.min(winStartOff, winEndOff)
int e0 = math.max(winStartOff, winEndOff)
// --- Clamp to Pine's history limit (0..10000) และไม่เกินจำนวนแท่งที่มีอยู่ ---
int eCap = math.min(e0, math.min(10000, bar_index))
int sMin = math.max(0, s0)
// --- จำกัดความกว้างหน้าต่างตาม p3MaxWindowBars ---
int sTmp = math.max(eCap - p3MaxWindowBars + 1, sMin)
int s = math.max(0, math.min(sTmp, eCap))
int e = eCap
// ถ้า window กลายเป็นว่าง ให้คืนค่า na
if e < 0 or s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float minOpen = open
int minIdx = s
float maxOpen = open
int maxIdx = s
float prevBin = na
int curRun = 0
for t = s to e
float bin = f_bin(open )
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
if open < minOpen
minOpen := open
minIdx := t
if open > maxOpen
maxOpen := open
maxIdx := t
prevBin := bin
// หา cluster ≥ 3
int best = na
int bestCnt = 0
int bestRun = 0
int bestFirst = na
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= 3
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if not na(best)
int pickOff = array.get(firstI, best)
[open , pickOff]
else
if isLong
[open , minIdx]
else
[open , maxIdx]
// --------- สถานะ / ค่าที่ต้องจำ ---------
var int L_stage = 0
var int L_P2Abs = na
var float L_P2Close = na
var float L_M2 = na
var float L_P1Open = na
var int S_stage = 0
var int S_P2Abs = na
var float S_P2Close = na
var float S_M2 = na
var float S_P1Open = na
// --------- FE storage ---------
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_add_fe_set(p3Abs, y95, y105, y161, y261) =>
int x1 = p3Abs, x2 = p3Abs + feLenBars
line l95 = line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l105 = line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l161 = line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=col1618, width=2)
line l261 = line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=col2618, width=2)
linefill lf = linefill.new(l95, l105, color=colBandFill)
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_fill, lf)
array.push(FE_born, p3Abs)
f_delete_fe_index(idx) =>
linefill.delete(array.get(FE_fill, idx))
line.delete(array.get(FE_l95, idx))
line.delete(array.get(FE_l105, idx))
line.delete(array.get(FE_l161, idx))
line.delete(array.get(FE_l261, idx))
array.remove(FE_l95, idx)
array.remove(FE_l105, idx)
array.remove(FE_l161, idx)
array.remove(FE_l261, idx)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
// ลบตามอายุ (เดินหน้าแล้วอ้างย้อนกลับ เพื่อเลี่ยง step ติดลบ)
if array.size(FE_born) > 0
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
int born = array.get(FE_born, i)
if bar_index >= born + feLife
f_delete_fe_index(i)
// --------- เครื่องจักรสถานะ: Long ---------
int candL = 2
if bar_index >= 4 and L_stage == 0
if isP2Long_at(candL)
L_P2Abs := bar_index - candL
L_P2Close := close
L_M2 := f_midBody_at(candL)
= f_findP1_long_rel(candL)
L_P1Open := __p1OpenTmp
L_stage := 1
if L_stage == 1
int p2Ago = bar_index - L_P2Abs
if p2Ago >= 1 and close <= L_M2
L_stage := 2
if L_stage == 2
if isGreen_at(0) and close >= L_M2
int p2Ago = bar_index - L_P2Abs
int wStart = 0
int wEnd = math.max(p2Ago - 1, 0) // ไม่รวมแท่ง P2 เอง
= f_pickP3_window(wStart, wEnd, true)
int p3Abs = bar_index - p3Off
float wave = L_P2Close - L_P1Open
if showFE and wave > 0 and not na(p3Open)
float y95 = p3Open + 0.95 * wave
float y105 = p3Open + 1.05 * wave
float y1618 = p3Open + 1.618 * wave
float y2618 = p3Open + 2.618 * wave
f_add_fe_set(p3Abs, y95, y105, y1618, y2618)
L_stage := 0
L_P2Abs := na, L_P2Close := na, L_M2 := na, L_P1Open := na
// --------- เครื่องจักรสถานะ: Short ---------
int candS = 2
if bar_index >= 4 and S_stage == 0
if isP2Short_at(candS)
S_P2Abs := bar_index - candS
S_P2Close := close
S_M2 := f_midBody_at(candS)
= f_findP1_short_rel(candS)
S_P1Open := __p1OpenTmpS
S_stage := 1
if S_stage == 1
int p2SAgo = bar_index - S_P2Abs
if p2SAgo >= 1 and close >= S_M2
S_stage := 2
if S_stage == 2
if isRed_at(0) and close <= S_M2
int p2SAgo = bar_index - S_P2Abs
int wStartS = 0
int wEndS = math.max(p2SAgo - 1, 0)
= f_pickP3_window(wStartS, wEndS, false)
int p3AbsS = bar_index - p3OffS
float waveS = S_P1Open - S_P2Close
if showFE and waveS > 0 and not na(p3OpenS)
float y95s = p3OpenS - 0.95 * waveS
float y105s = p3OpenS - 1.05 * waveS
float y1618s = p3OpenS - 1.618 * waveS
float y2618s = p3OpenS - 2.618 * waveS
f_add_fe_set(p3AbsS, y95s, y105s, y1618s, y2618s)
S_stage := 0
S_P2Abs := na, S_P2Close := na, S_M2 := na, S_P1Open := na
//==================== DSI (Dynamic Structure Indicator) ====================
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
// ระบุชนิดชัดเจนเพื่อหลีกเลี่ยง NA-type
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na, dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na, dsi_potS2 := na
// ยืนยัน RS/SR เมื่อราคาวิ่งผ่านระยะ ATR ตามที่กำหนด
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_supCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_supCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_resCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_resCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? color.green : color.new(color.red, 50)) : color.new(color.black, 100), title="DSI Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? color.red : color.new(color.green, 50)) : color.new(color.black, 100), title="DSI Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=color.red, style=plot.style_linebr, title="DSI PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=color.red, style=plot.style_linebr, title="DSI PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(color.red, 10) : color.new(color.black, 100), title="DSI Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=color.green, style=plot.style_linebr, title="DSI PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=color.green, style=plot.style_linebr, title="DSI PR2")
fill(dsi_pr1plot, dsi_pr2plot, color=showDSI and drawPreviousStructure ? color.new(color.green, 10) : color.new(color.black, 100), title="DSI Previous Resistance Zone")
EMA Crossover with AlertsIndicator with Fast and Slow EMA Crossovers, includes alerts on such cross overs
Trading Session Zones - Asia, London, NY - AMD
What it does:
This Pine Script indicator automatically identifies and highlights the high/low price ranges for the three major global trading sessions: Asia, London, and New York. It draws filled colored boxes around each session's price action, making it easy to spot key support/resistance levels and session boundaries
Key Features:
Three distinct colored zones: Teal for Asia, Blue for London, Orange for New York
Filled boxes with transparency: Clear visibility without obscuring price action (80% transparency)
Session labels:Each box displays the session name in the center
Clean transitions: London session automatically ends when New York begins (no overlap)
Real-time updates:Boxes expand as sessions progress, tracking new highs and lows
Technical Details:
Uses user-defined types for efficient session tracking
Automatically handles session transitions
Works on any timeframe and any instrument
Optimized for performance with proper object limits
SPX Futures Momentum Detector (MVP Enhanced)Our SPX Futures Momentum Detector is a precision trading tool built for professional futures and options traders.
Optimized for SPX and ES/MES futures, this indicator identifies high probability momentum entries, filters noise, and provides clear CALL/PUT signals for rapid decision-making.
It layers proprietary filters to reduce false positives in volatile or choppy conditions.
This enhanced version leverages our proprietary MVP Momentum framework, incorporating Renko-style brick simulation and momentum confirmation layers.
It is designed for scalping and short-term swing strategies in highly liquid markets.
**Key Features**
• Proprietary momentum detection logic
• Optimized for 5m, 15m, and Renko charts
• Works with SPX, ES, and MES futures contracts and any highly liquid option contracts
• CALL/PUT labeling with A+ setup classification (Hot CALL Signal)
• Zero repaint logic for reliable backtesting
**What it does**
• Detects momentum inflections on SPX/ES/MES using a Renko-style brick simulation + dual EMA context.
• Designed for 1m–5m timeframes; exceptional clarity on Line Break charts.
• Signals: CALL (momentum up), PUT (momentum down). No lookahead; signals print on confirmed bar close.
**How to use**
• Recommended charts: SPX, ES, MES (futures) or any highly liquid options charts.
• Recommended chart types: Line Break for clarity; standard candles for entry points.
• Timeframes: 1m or 5m (scalping to intraday).
• Add alerts: “CALL Signal” and “PUT Signal”, set to “Once per bar close.”
**Inputs explained**
• Fast EMA / Slow EMA – Short/medium trend filters for momentum context.
• Renko Box Size ($) – Sensitivity of the brick simulation (larger = fewer but higher-quality signals).
• Confirmation Bars – Ensures price follow-through (filters weak trends).
• Volume Breakout Multiplier – Confirms breakouts with significant volume increase.
• Consolidation Bars – Filters out sideways action before a momentum shift.
**Risk & limitations**
• Momentum tools perform best in trending sessions. Expect fewer clean signals in chop.
• No guarantees of profit. Use with your own risk management and exit plan.
• Backtest across multiple regimes (trend, post-FOMC, month-end) before live use.
**Best practices**
• Pair with optional companion exit logic for trade management.
• Use alerts at bar close to avoid noise.
• Not recommended for full automation yet: validate broker fills, slippage, and latency.
**Disclaimers**
• Educational tool. Not financial advice. Past performance ≠ future results.
• We do not guarantee outcomes, you are responsible for your trades.
**Changelog**
v1.0 – Initial invite-only release (MVP Enhanced): Renko-style momentum + EMA filters, bar-close alerts, repaint safe security calls.
Enhanced Circle CandlestickEnhanced Circle Candlestick
This script transforms standard candlesticks into circles, visualizing momentum, volume, and volatility in a unique way. The size and color of the circles change based on the body size of the candlestick, while a change in color signifies a volume spike. Long wicks are also highlighted, providing a quick visual cue for potential reversals or indecision.
Features
Circle Visualization: Replaces the standard candlestick body with a circle. The size of the circle is determined by the size of the candlestick body, making it easy to spot periods of high momentum.Gradient Color: The circle's opacity changes based on the body size. Smaller bodies have a lighter color, while larger, more powerful bodies have a darker, more vivid color. This visual gradient provides a clear indication of a bar's strength.Volume Spike Highlight: The circle's color will change to a bright yellow when the current volume exceeds the average volume by a user-defined factor, indicating a significant influx of buying or selling pressure.Long Wick Markers: The script draws a small triangle above or below the candlestick when a wick's length surpasses a user-defined percentage of the body's size. This helps identify potential exhaustion, rejection, or indecision in the market.
Settings
Bullish/Bearish Color: Customize the base colors for bullish (green) and bearish (red) circles.Volume Spike Color: Choose the color for the circle when a volume spike occurs.Volume Spike Factor: Set the multiplier for the volume spike detection. For example, a value of 2.0 means a volume spike is detected when the current volume is twice the 20-period moving average.Circle Opacity (0-100): Adjust the base transparency of the circles. Lower numbers result in more opaque (solid) colors.Opacity Factor: Controls how quickly the color gradient changes based on the body size. A higher value makes the color change more dramatic.Wick Length Factor (vs Body): Set the threshold for marking long wicks. A value of 0.8 means a wick is marked if its length is 80% or more of the candlestick body's size.
How to Use
Add this indicator to your chart.Open the Chart Settings.In the "Symbol" tab, set the transparency of the candlestick "Body" to 0%. (This step is essential because the indicator's settings will not be applied when the indicator is not selected, and the default platform settings take precedence.)
I do not speak English at all. Please understand that if you send me a message, I may not be able to reply, or my reply may have a different meaning. Thank you for your understanding.
EEI Strategy — Greedy/Guarded v1.2Purpose
Day‑trading strategy (5‑min focus) that hunts “armed” setups (PRE) and confirms them (GO) with greedy-but‑guarded execution. It adapts to symbol type, trend strength, and how long it’s been since the last signal.
Core signals & regime
Trend/Regime: EMA‑200 (intraday bias), VWAP, and a non‑repainting HTF EMA (via request.security(...) ).
Momentum/Structure: Manual Wilder DMI/ADX, micro‑ribbon (EMA 8/21), Bollinger‑Keltner squeeze + “squeeze fire,” BOS (break of swing high/low), pullback to band.
Liquidity/Vol: RVOL vs SMA(volume) + a latch (keeps eligibility a few bars after the first spike).
Volatility: ATR + ATR EMA (expansion).
PRE / GO engine
Score (0–100) aggregates trend, momentum, RVOL, squeeze, OBV slope, ribbon, pullback, BOS, and an Opening‑Range (OR) proximity penalty.
PRE arms when the adjusted score ≥ threshold and basic hygiene passes (ATR%, cooldown, etc.).
GO confirms within a dynamic window (1–3 bars):
Wick‑break mode on hot momentum (trend‑day / high ADX+RVOL): stop orders above/below the PRE high/low with a tick buffer.
Close‑through mode otherwise: close must push through PRE high/low plus ATR buffer.
Chase guard: entry cannot be too far from PRE price (ATR‑based), with a tiny extra allowance when the 8/21 ribbon aligns.
Multiple PREs per squeeze (capped) + per‑entry cooldown.
Adaptive behavior
Presets (Conservative/Balanced/Aggressive/Turbo) shift score/ADX/RVOL/ATR gates, GO window, cooldown, and max chase.
Profiles / Auto by Symbol:
Mega Trend (e.g., AMD/NVDA/TSLA/AAPL): looser chase, ATR stop, chandelier trail.
Mid Guarded (e.g., TTD/COIN/SOFI): swing stop, EMA trail, moderate gates.
Small Safe (e.g., BTAI/BBAI class): tighter gates, more guardrails.
BBAI micro‑override: easier arming (lower score/ADX/RVOL), multi‑PRE=3, swing stop + EMA trail, lighter OR penalty.
Trend‑day detector: if ADX hot + RVOL strong + ATR expanding + distance from day‑open large → GO window = 1 and wick‑break mode.
Mid‑day relaxers: mild score bonus between 10:30–14:30 to keep signals flowing in quieter tape.
Auto‑Relaxer (no‑signal fallback): after N bars without PRE/GO, gradually lowers score/ADX/RVOL/ATR% gates and raises max chase so the engine doesn’t stall on sleepy symbols.
Auto‑Session fallback: if RTH session isn’t detected (some tickers/premarket), it falls back to daily boundaries so Opening Range and day‑open logic still work.
Risk & exits
Initial stop per side chosen by ATR, Swing, or OR (computed every bar; no conditional calls).
Scaled targets: TP1/TP2 (R‑based) + runner with optional Chandelier or EMA trailing.
BE logic: optional move to breakeven after TP1; trailing can start after TP1 if configured.
Opening Range (OR)
Computes day open, OR high/low over configurable minutes; applies a penalty when entries are too close to OR boundary (lighter for small caps/BBAI). Protects against boundary whips.
Alerts & visuals
Alertconditions: PRE Long/Short Armed, GO Long/Short + explicit alert() calls for once‑per‑bar automation.
Plots: EMA‑200, HTF EMA, BB/KC bands, OR lines, squeeze shading, and PRE markers.
Why it’s robust
Non‑repainting HTF technique, all series precomputed every bar, no function calls hidden in conditionals that could break history dependence, and consistent state handling (var + sentinels).
Tuning cheat‑sheet (fast wins)
More trades: lower scoreBase, adxHot, or rvolMinBase a notch; reduce cooldownBase; increase maxPREperSqueeze.
Fewer whips: increase closeBufferATR, wickBufferTicks, or atrMinPct; reduce maxChaseATRBase.
Trend capture: use trailType="Chandelier", smaller trailLen, slightly larger trailMult; set preset="Aggressive".
Choppy names: prefer stopMode="Swing", enable EMA trail, keep OR penalty on.
Berkusa trend 2This is a strategy created purely for educational and testing purposes. It is not recommended for buy/sell decisions. You can test it and provide feedback to see whether it works for trend-following. It is written with a simple logic similar to SuperTrend. I believe it might be useful for scalping. However, do not use it for trading without careful observation.
SMC Genesis Pro - Institutional Flow Scanner🎯 Transform Your Trading with Professional-Grade Smart Money Analysis
SMC Genesis Pro isn't just another SMC indicator—it's your institutional trading edge. Developed by professional traders who understand that successful SMC requires precise timing, confluence validation, and institutional-level insights.
⚡ Why Genesis Pro Outperforms Other SMC Indicators:
🔥 Advanced Signal Intelligence
Dynamic Signal Strength Rating (1-3 scale) - Know exactly how confident each signal is
Multi-Confluence Detection - FVG + Order Block + Trend alignment for maximum accuracy
Smart Trend Filtering - Only trade with institutional momentum, not against it
Real-Time Risk/Reward Calculator - Automatically calculates R:R ratios for every signal
🧠 Professional-Grade Features
Enhanced Memory Management - Zero lag, smooth performance on any timeframe
Smart Session Analysis - Identifies London/NY/Asia sessions for optimal timing
Volatility Risk Assessment - Adapts to market conditions automatically
Institutional Dashboard - 12+ real-time metrics in a sleek trading terminal
📦 Complete SMC Arsenal
✅ Fair Value Gaps with intelligent retest detection
✅ Order Blocks with volume-based validation
✅ Break of Structure and Change of Character alerts
✅ Swing Point Mapping for key support/resistance
✅ Liquidity Zone Identification for institutional footprints
🎯 Perfect For:
Day Traders seeking high-probability entries
Swing Traders following institutional flow
ICT Students implementing Smart Money Concepts
Professional Traders needing robust, reliable signals
📈 Proven Performance Features:
16 Custom Alert Types - Never miss a setup
Multiple Timeframe Support - 5M to Daily charts
Real-Time Signal Processing - No repainting, no delays
Professional Risk Management - Built-in SL/TP calculations
⚙️ Exclusive Pro Features:
Market Structure Analyzer - Tracks internal & swing structures
Price Momentum Scanner - EMA-based momentum confirmation
Session-Based Analysis - Trade only during high-volume sessions
Advanced Zone Management - Automatic cleanup prevents chart clutter
🚀 Ready to Trade Like the Institutions?
SMC Genesis Pro gives you the same analytical power that professional traders use to consistently profit from institutional movements. Stop guessing—start following the smart money.
💎 Join Our Exclusive Trading Community
🔗 JOIN GENESIS DISCORD 🔗
Get Access To:
🎯 Exclusive Beta Scripts - Test cutting-edge indicators before public release
📚 Professional SMC Education - Learn from traders who actually profit
💬 Live Trading Room - Real-time analysis and setups
🔔 Priority Alerts - Get notified of major market moves first
🛠️ Custom Script Requests - Help shape our next indicators
📊 Performance Analytics - Track your improvement with our tools
Limited Time: First 100 members get lifetime access to all beta releases.
⚠️ Disclaimer
This indicator is for educational purposes only. Past performance does not guarantee future results. Always use proper risk management and trade responsibly.
FXWIZ NeoLine-T3 AlignFXWIZ NeoLine-T3 Align PRO is a dual-signal precision tool combining:
1) NeoLine (ATR + Bollinger Bands) trend reversal signal
2) Adaptive RSI-driven T3 alignment signal
Concept:
- NeoLine detects breakout-based trend shifts with optional ATR filtering.
- Adaptive RSI T3 Line adjusts dynamically in length to market momentum.
- Background highlight appears only when the active trade mode (from NeoLine) aligns with the T3 crossover in the same direction.
- Two independent but complementary signals:
• NeoLine Trend Flip (▲ / ▼)
• T3 Align Event (BG highlight + alerts)
The built-in MTF Signal Table shows the NeoLine vs T3 crossover trend for five user-selected timeframes.
Unique Points:
- Dual confirmation system reduces false entries.
- Visual minimalism: clean line plots, single background highlight.
- Alerts for both trend flips and alignment events.
Invite-Only: FXWIZ students & community members only. No redistribution or resale.
Portions of the T3/RSI concept are inspired by ChartPrime (MPL 2.0). Logic reimplemented and integrated by FXWIZ.
[Top] ≈ SyncLineFind the hidden currents between markets.
What it does
SyncLine overlays up to three cross-asset guide lines on your current chart, translating each selected symbol’s intraday position into the price scale of the chart you’re viewing. The result is a clean, session-aware “sync” of other markets on your chart so you can quickly spot alignment, leadership, and divergence without clutter.
How it works
For each selected symbol, SyncLine calculates that symbol’s intraday position relative to its own session baseline, then projects that position onto your active chart based on its own baseline.
Lines reset each session to remain relevant to the current day’s action.
Optional smoothing makes the guides easier to read during noisy tape.
Note: This script is intraday-only . It will stop with a clear warning if applied to non-intraday timeframes.
Inputs
Symbols
Show Symbol 1/2/3 – Toggle each overlay line.
Symbol 1/2/3 – Choose any ticker (e.g., index futures, ETFs, single names).
Color 1/2/3 – Line colors.
Labels - Optional labels for each line.
Smoothing
Enable Smoothing – On/Off.
Method – EMA / SMA / WMA / RMA.
Length – 1–50.
How to use
Add one or more driver markets (e.g., ES, NQ, DXY, sector leaders) to observe when they align with your instrument.
Look for:
Confluence : your price and one or more SyncLines moving together.
Leadership : a SyncLine turns/accelerates before your price.
Divergence : your price disagrees with the majority of SyncLines.
Notes & limitations
Designed for intraday timeframes (1m–1h).
Lines are calculated from completed data and do not repaint after bar close .
Works best during regular liquid sessions ; thin markets can reduce signal quality.
Best practices
Pair SyncLine with your execution framework (structure, liquidity zones, time-of-day).
Use distinct colors for each symbol and keep the set small (1–3) for clarity.