VIBE QSFM-00523524 L v1.0 Trailing SL Indicator Pine by Panduck

# VIBE QSFM-00523524 L v1.0 Trailing SL Indicator Pine
## Install and enable alerts
1. Copy the entire Indicator Pine file into a NEW TradingView indicator. Save and add to standard OANDA:XAUUSD, 5-minute candles.
2. Choose Mode = Live for future signals. Live defaults to June3,2026 seed, permits one virtual trade, and has no end date. Load history from the seed; missing context can change EMA filters. Original backtest and Forward reference are historical modes that expire at their selected end; return to Live afterward. Indicator chart history does not inherit Deep Backtesting history.
3. Create ONE alert selecting this indicator and Any alert() function call. Choose notifications and expiry. PREPARE, EXECUTE, MOVE SL and MODEL EXIT toggles default ON. Avoid duplicate alerts for the same event set.
4. Recreate the alert after changing code, inputs, mode, symbol or timeframe. The saved server copy does not automatically update. Alerts fire on realtime bars; historical markers do not send past alerts. Compilation, chart overlay and actual notification delivery still need checking.
## Four messages
- PREPARE is provisional during an unfinished candle. Current compression range must be <=0.70 times median60 by default, with other current filters passing, including close>EMA20 and RSI>52. The prepare factor is adjustable, but does not change the exact tested entry rule. A growing candle can cancel the setup. Do not enter from PREPARE. At most one per developing bar; it is not required before EXECUTE.
- EXECUTE confirms all exact criteria at the candle CLOSE, including range<=0.55median60. Enter next available candle if taking the signal. Message entry/SL/TP values are estimates from signal close; recalculate from your actual fill.
- MOVE SL gives the raised model stop for the following candle, after a surviving completed candle. Raise only; keep TP fixed. The script cannot amend broker stops.
- MODEL EXIT reports an existing model SL/TP chart touch at candle close. It is not broker execution confirmation. Honor broker protection when reached rather than waiting for this message.
Distinct events may occur at the same close. The indicator cannot see your broker position, skipped signals or fill. Skipping a signal still creates a virtual trade and can suppress later model entries. Always check your actual position and protection independently.
## Long trailing instructions — TP never moves
For actual fill E, set initial SL=E−18 and fixed TP=E+36 immediately. After each completed M5 candle, first honor the SL/TP already active during it. If the trade survives, track H=highest high reached since your actual entry. Once H−E>=18, raise SL to max(existingSL,H−18), effective for the next candle. Never lower or widen a long SL. TP remains at its original level.
Example E4300:SL4282,TP4336. Completed surviving high4318 => nextSL4300; high4324 => nextSL4306; TP stays4336. Wicks count even if close rebounds; do not count pre-fill movement if entering late. Do not retroactively apply the new stop to earlier lows. A broker's continuous trailing feature follows different timing; use ordinary stops updated after completed candles to follow this model. If market is already below the proposed SL, the broker may reject it or require closing at the available price; do not lower the stop to make an amendment work. Gold price distances are not account risk, pips or broker lots.
## Why one backtest trade earned $6,842.65
Trade65 entered at5245.35 with a FIXED TP5281.35. After the weekend, the next available bar opened at5368.53. TradingView filled the sell limit at that better opening price, producing (5368.53−5245.35)×55.55=$6842.648999..., displayed$6842.65. The TP did not trail. At the specified TP, the same quantity would earn$1999.80. Actual executable broker fills and costs can differ; this gap is not a predictable normal target return.
A report can also combine several simultaneous trades. Original source training permits5; Live permits1. Keep individual trade P/L separate from grouped equity jumps.
## Method, initialization and sample notes
## Logic
Buy on a completed M5 candle whose full range is at most55% of the median of the last60 candle ranges, including itself. Require close above current EMA20, RSI14 strictly above52, and inclusive ATR rank120 from10% to60%. A bullish candle or breakout is not required.
Latest completed H1 close must exceed its EMA50, H2 close its EMA20, and custom H4 close its EMA50. H4 starts03/07/11/15/19/23UTC, year-round. Only full12/24/48-M5-bar higher-timeframe buckets update their EMA, seeded at first accepted close. Use only higher-timeframe buckets completed at decision candle OPEN. M5EMA20 seeds first source close; ATR14 seeds mean14TR then Wilder; RSI14 seeds first14changes then Wilder. The60-range median averages the sorted30th/31st values. At least241sourcebars are required. No extra body-size, momentum, retest or M5EMA50 trend filters.
Signal candles OPEN in18:00–18:59UTC weekdays; confirmed decisions occur18:05–19:00UTC, or01:05–02:00Bangkok the next day. FridayUTC can produce a SaturdayBangkok entry. Confirm at close, enter next available candle open.
## Management reference
Let E be actual long entry. Immediately place SL=E−18 and TP=E+36. After each completed candle, if the trade survived its existing SL/TP, update H=highest high since entry. Once H−E>=18, raise SL to max(existingSL,H−18), effective for the following candle. Never lower a long SL or move the fixed TP. Candle wicks count. Do not apply the newly calculated stop retroactively to an earlier low in its activation candle.
Example E4300:initialSL4282,TP4336;high4318=>nextSL4300;high4324=>nextSL4306;TPremains4336. Use only movement after your actual fill. A broker's continuous trailing function differs from completed-M5-candle updates. If price is already below the new stop, execution may require the next tradable price; do not lower the stop merely to get an amendment accepted. Script levels are model references and cannot amend broker orders.
## Historical samples and limitations
Original source rawcapacity5:176trades,128wins72.73%,net113746.39. Capacity1 alternative:69trades,48wins69.57%,net39686.11. These are different tests.
Source forward June3–October16,2026:11accepted trades,7wins63.64%,net5525.83,closedDD2000;29raw trades minus18safetyoverlaprejections. Forward reference preset generates withcapacity1, approximating rawcapacity5 followed by postfiltering; signal/exit availability may change the accepted path. Actual sourceforwardseed/feedcontext remains unconfirmed. Original source frequency was10.49trades/month versus2.47acceptedforward; do not assume the training frequency will persist.
An independent streaming calculation matched all181raw training signals, and a separately translated long management model matched all176source trades' entry/exit times, entry/finalstop/target prices and P/L. Neither check compiles Pine. Native broker-emulator both-hit ordering, gaps, tick/quantity rounding and executable bid/ask/costs can differ from the source's stop-first OHLC rules. Historical results are sample-specific, not future forecasts.
Official simulation documentation: tradingview.com/pine-script-docs/concepts/strategies/
## Reviewed TradingView subset
Strategyv1.0 Last365days:71trades,46wins/25losses,64.79%,net$53,401.32,PF3.1665. All71entrytimes/pricesandexittimesmatchsource;68exitpricesmatch. Report excludes105earliertrades. Three exits fill atnextavailableOPEN ratherthantheoreticallevels:Dec25 newlyraisedSLalreadythroughmarket;Jan22sessiongapaboveTP;Mar1weekendgapaboveTP. The long gap adds about$4843 before quantity rounding. Source full176tradeWR72.73% and forward11tradeWR63.64% are separate samples, not expected future winrates. Indicator conservative source-model exits may differ from those native Strategy Tester gap fills. Model translation verified176trades(cap5) and69(cap1), not Pine compilation or live alert delivery.
Optional table statistics preserve separate source/TV samples; visuals show the newest virtual trade while historical capacity5 manages all IDs. Table anchor, description and visual toggles are configurable.
Official alerts: tradingview.com/pine-script-docs/concepts/alerts/
## Install and enable alerts
1. Copy the entire Indicator Pine file into a NEW TradingView indicator. Save and add to standard OANDA:XAUUSD, 5-minute candles.
2. Choose Mode = Live for future signals. Live defaults to June3,2026 seed, permits one virtual trade, and has no end date. Load history from the seed; missing context can change EMA filters. Original backtest and Forward reference are historical modes that expire at their selected end; return to Live afterward. Indicator chart history does not inherit Deep Backtesting history.
3. Create ONE alert selecting this indicator and Any alert() function call. Choose notifications and expiry. PREPARE, EXECUTE, MOVE SL and MODEL EXIT toggles default ON. Avoid duplicate alerts for the same event set.
4. Recreate the alert after changing code, inputs, mode, symbol or timeframe. The saved server copy does not automatically update. Alerts fire on realtime bars; historical markers do not send past alerts. Compilation, chart overlay and actual notification delivery still need checking.
## Four messages
- PREPARE is provisional during an unfinished candle. Current compression range must be <=0.70 times median60 by default, with other current filters passing, including close>EMA20 and RSI>52. The prepare factor is adjustable, but does not change the exact tested entry rule. A growing candle can cancel the setup. Do not enter from PREPARE. At most one per developing bar; it is not required before EXECUTE.
- EXECUTE confirms all exact criteria at the candle CLOSE, including range<=0.55median60. Enter next available candle if taking the signal. Message entry/SL/TP values are estimates from signal close; recalculate from your actual fill.
- MOVE SL gives the raised model stop for the following candle, after a surviving completed candle. Raise only; keep TP fixed. The script cannot amend broker stops.
- MODEL EXIT reports an existing model SL/TP chart touch at candle close. It is not broker execution confirmation. Honor broker protection when reached rather than waiting for this message.
Distinct events may occur at the same close. The indicator cannot see your broker position, skipped signals or fill. Skipping a signal still creates a virtual trade and can suppress later model entries. Always check your actual position and protection independently.
## Long trailing instructions — TP never moves
For actual fill E, set initial SL=E−18 and fixed TP=E+36 immediately. After each completed M5 candle, first honor the SL/TP already active during it. If the trade survives, track H=highest high reached since your actual entry. Once H−E>=18, raise SL to max(existingSL,H−18), effective for the next candle. Never lower or widen a long SL. TP remains at its original level.
Example E4300:SL4282,TP4336. Completed surviving high4318 => nextSL4300; high4324 => nextSL4306; TP stays4336. Wicks count even if close rebounds; do not count pre-fill movement if entering late. Do not retroactively apply the new stop to earlier lows. A broker's continuous trailing feature follows different timing; use ordinary stops updated after completed candles to follow this model. If market is already below the proposed SL, the broker may reject it or require closing at the available price; do not lower the stop to make an amendment work. Gold price distances are not account risk, pips or broker lots.
## Why one backtest trade earned $6,842.65
Trade65 entered at5245.35 with a FIXED TP5281.35. After the weekend, the next available bar opened at5368.53. TradingView filled the sell limit at that better opening price, producing (5368.53−5245.35)×55.55=$6842.648999..., displayed$6842.65. The TP did not trail. At the specified TP, the same quantity would earn$1999.80. Actual executable broker fills and costs can differ; this gap is not a predictable normal target return.
A report can also combine several simultaneous trades. Original source training permits5; Live permits1. Keep individual trade P/L separate from grouped equity jumps.
## Method, initialization and sample notes
## Logic
Buy on a completed M5 candle whose full range is at most55% of the median of the last60 candle ranges, including itself. Require close above current EMA20, RSI14 strictly above52, and inclusive ATR rank120 from10% to60%. A bullish candle or breakout is not required.
Latest completed H1 close must exceed its EMA50, H2 close its EMA20, and custom H4 close its EMA50. H4 starts03/07/11/15/19/23UTC, year-round. Only full12/24/48-M5-bar higher-timeframe buckets update their EMA, seeded at first accepted close. Use only higher-timeframe buckets completed at decision candle OPEN. M5EMA20 seeds first source close; ATR14 seeds mean14TR then Wilder; RSI14 seeds first14changes then Wilder. The60-range median averages the sorted30th/31st values. At least241sourcebars are required. No extra body-size, momentum, retest or M5EMA50 trend filters.
Signal candles OPEN in18:00–18:59UTC weekdays; confirmed decisions occur18:05–19:00UTC, or01:05–02:00Bangkok the next day. FridayUTC can produce a SaturdayBangkok entry. Confirm at close, enter next available candle open.
## Management reference
Let E be actual long entry. Immediately place SL=E−18 and TP=E+36. After each completed candle, if the trade survived its existing SL/TP, update H=highest high since entry. Once H−E>=18, raise SL to max(existingSL,H−18), effective for the following candle. Never lower a long SL or move the fixed TP. Candle wicks count. Do not apply the newly calculated stop retroactively to an earlier low in its activation candle.
Example E4300:initialSL4282,TP4336;high4318=>nextSL4300;high4324=>nextSL4306;TPremains4336. Use only movement after your actual fill. A broker's continuous trailing function differs from completed-M5-candle updates. If price is already below the new stop, execution may require the next tradable price; do not lower the stop merely to get an amendment accepted. Script levels are model references and cannot amend broker orders.
## Historical samples and limitations
Original source rawcapacity5:176trades,128wins72.73%,net113746.39. Capacity1 alternative:69trades,48wins69.57%,net39686.11. These are different tests.
Source forward June3–October16,2026:11accepted trades,7wins63.64%,net5525.83,closedDD2000;29raw trades minus18safetyoverlaprejections. Forward reference preset generates withcapacity1, approximating rawcapacity5 followed by postfiltering; signal/exit availability may change the accepted path. Actual sourceforwardseed/feedcontext remains unconfirmed. Original source frequency was10.49trades/month versus2.47acceptedforward; do not assume the training frequency will persist.
An independent streaming calculation matched all181raw training signals, and a separately translated long management model matched all176source trades' entry/exit times, entry/finalstop/target prices and P/L. Neither check compiles Pine. Native broker-emulator both-hit ordering, gaps, tick/quantity rounding and executable bid/ask/costs can differ from the source's stop-first OHLC rules. Historical results are sample-specific, not future forecasts.
Official simulation documentation: tradingview.com/pine-script-docs/concepts/strategies/
## Reviewed TradingView subset
Strategyv1.0 Last365days:71trades,46wins/25losses,64.79%,net$53,401.32,PF3.1665. All71entrytimes/pricesandexittimesmatchsource;68exitpricesmatch. Report excludes105earliertrades. Three exits fill atnextavailableOPEN ratherthantheoreticallevels:Dec25 newlyraisedSLalreadythroughmarket;Jan22sessiongapaboveTP;Mar1weekendgapaboveTP. The long gap adds about$4843 before quantity rounding. Source full176tradeWR72.73% and forward11tradeWR63.64% are separate samples, not expected future winrates. Indicator conservative source-model exits may differ from those native Strategy Tester gap fills. Model translation verified176trades(cap5) and69(cap1), not Pine compilation or live alert delivery.
Optional table statistics preserve separate source/TV samples; visuals show the newest virtual trade while historical capacity5 manages all IDs. Table anchor, description and visual toggles are configurable.
Official alerts: tradingview.com/pine-script-docs/concepts/alerts/
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.