OPEN-SOURCE SCRIPT
Telah dikemas kini

Serenity Model VIPI — by yuu_iu

307
Here’s a concise, practical English guide for Serenity Model VIPI (Author: yuu_iu). It covers what it is, how to set it up for daily trading, how to tune it, and how we guarantee non-repainting.

Serenity Model VIPI — User Guide (Daily Close, Non‑Repainting)

Credits
- Author: yuu_iu
- Producer: yuu_iu
- Platform: TradingView (Pine Script v5)

1) What it is
Serenity Model VIPI is a multi‑module, context‑aware trading model that fuses signals from:
- Entry modules: VCP, Flow, Momentum, Mean Reversion, Breakout
- Exit/risk modules: Contrarian, Breakout Sell, Volume Delta Sell, Peak Detector, Overbought Exit, Profit‑Take
- Context/memory: Learns per Ticker/Sector/Market Regime and adjusts weights/aggression
- Learning engine: Runs short “fake trades” to learn safely before scaling real trades

It produces a weighted, context‑adjusted score and a final decision: BUY, SELL, TAKE_PROFIT, or WAIT.

2) How it works (high level)
- Each module computes a score per bar.
- A fusion layer combines module scores using accuracy and base weights, then adjusts by:
- Market regime (Bull/Bear/Sideways) and optional higher‑timeframe (HTF) bias
- Risk control neuron
- Context memory (ticker/sector/regime)
- Optional LLM mode can override marginal cases if context supports it.
- Final decision is taken at bar close only (no intrabar repaint).

3) Non‑repainting guarantee (Daily)
- Close‑only execution: All key actions use barstate.isconfirmed, so signals/entries/exits only finalize after the daily candle closes.
- No lookahead on HTF data: request.security() reads prior‑bar values (series[1]) for HTF close/EMA/RSI.
- Alerts at bar close: Alerts are fired once per bar close to prevent mid‑bar changes.
What this means: Once the daily bar closes, the decision and alert won’t be repainted.

4) Setup (TradingView)
- Paste the Pine v5 code into Pine Editor, click Add to chart.
- Timeframe: 1D (Daily).
- Optional: enable a date window for training/backtest
- Enable Custom Date Filter: ON
- Set Start Date / End Date
- Create alert (non‑repainting)
- Condition: AI TRADE Signal
- Options: Once Per Bar Close
- Webhook (optional): Paste your URL into “System Webhook URL (for AI events)”
- Watch the UI
- On‑chart markers: AI BUY / AI SELL / AI TAKE PROFIT
- Right‑side table: Trades, Win Rate, Avg Profit, module accuracies, memory source, HTF trend, etc.
- “AI Thoughts” label: brief reasoning and debug lines.

5) Daily trading workflow
- The model evaluates at daily close and may:
- Enter long (BUY) when buy votes + total score exceed thresholds, after context/risk checks
- Exit via trailing stop, hard stop, TAKE_PROFIT, or SELL decision
- Learning mode:
- Triggers short “fake trades” every N bars (default 3) and measures outcome after 5 bars
- Improves module accuracies and adjusts aggression once stable (min fake win% threshold)
- Memory application:
- When you change tickers, the model tries to apply Ticker or Sector memory for the current market regime to pre‑bias module weights/aggression.

6) Tuning (what to adjust and why)
Core controls
- Base Aggression Level (default 1.0): Higher = more trades and stronger decisions; start conservative on Daily (1.0–1.2).
- Learning Speed Multiplier (default 3): Faster adaptation after fake/real trades; too high can overreact.
- Min Fake Win Rate to Exit Learning (%) (default 10–20%): Raises the bar before trusting more real trades.
- Fake Trade Every N Bars (default 3): Frequency of learning attempts.
- Learning Threshold Win Rate (default 0.4): Governs when the learner should keep learning.
- Hard Stop Loss (%) (default 5–8%): Global emergency stop.

Multi‑Timeframe (MTF)
- Enable Multi‑Timeframe Confirmation: ON (recommended for Daily)
- HTF Trend Source: HOSE:VNINDEX for VN equities (or CURRENT_SYMBOL if you prefer)
- HTF Timeframe: D or 240 (for a strong bias)
- MTF Weight Adjustment: 0.2–0.4 (0.3 default is balanced)

Module toggles and base weights
- In strong uptrends: increase VCP, Momentum, Breakout (0.2–0.3 typical)
- In sideways low‑vol regimes: raise MeanRev (0.2–0.3)
- For exits/defense: Contrarian, Peak, Overbought Exit, Profit‑Take (0.1–0.2 each)
- Keep Flow on as a volume‑quality filter (≈0.2)

Memory and control
- Enable Shared Memory Across Tickers: ON to share learning
- Enable Sector‑Based Knowledge Transfer: ON to inherit sector tendencies
- Manual Reset Learning: Use sparingly to reset module accuracies if regime changes drastically

Risk management
- Hard Stop Loss (%): 5–8% typical on Daily
- Trailing Stop: ATR‑ and volatility‑adaptive; tightens faster in Bear/High‑Vol regimes
- Max hold bars: Shorter in Bear or Sideways High‑Vol to cut risk

Alerts and webhook
- Use AI TRADE Signal with Once Per Bar Close
- Webhook payload is JSON, including event type, symbol, time, win rates, equity, aggression, etc.

7) Recommended Daily preset (VN equities)
- MTF: Enable, Source: HOSE:VNINDEX, TF: D, Weight Adj: 0.3
- Aggression: 1.1
- Learning Speed: 3
- Min Fake Win Rate to Exit Learning: 15%
- Hard SL: 6%
- Base Weights:
- VCP 0.25, Momentum 0.25, Breakout 0.15, Flow 0.20
- MeanRev 0.20 (raise in sideways)
- Contrarian/Peak/Overbought/Profit‑Take: 0.10–0.20
- Leave other defaults as is, then fine‑tune by symbol/sector.

8) Reading the UI
- Table highlights: Real Trades, Win Rate, Avg Profit, Fake Actions/Win%, VCP Acc, Aggression, Equity, Score, Status (LEARNING/TRADING/REFLECTION), Last Real, Consec Loss, Best/Worst Trade, Pattern Score, Memory Source, Current Sector, AI Health, HTF Trend, Scheduler, Memory Loaded, Fake Active.
- Shapes: AI BUY (below bar), AI SELL/TAKE PROFIT (above bar)
- “AI Thoughts”: module contributions, context notes, debug lines

9) Troubleshooting
- No trades?
- Ensure timeframe is 1D and the date filter covers the chart range
- Check Scheduler Cooldown (3 bars default) and that barstate.isconfirmed (only at close)
- If MTF is ON and HTF is bearish, buy bias is reduced; relax MTF Weight Adjustment or module weights
- Too many/too few trades?
- Lower/raise Base Aggression Level
- Adjust base weights on key modules (raise entry modules to be more active; raise exit/defense modules to be more selective)
- Learning doesn’t end?
- Increase Min Fake Win Rate to Exit Learning only after it’s consistently stable; otherwise lower it or reduce Fake Trade Every N Bars

10) Important notes
- The strategy is non‑repainting at bar close by design (confirmed bars + HTF series[1] + close‑only alerts).
- Backtest fills may differ from live fills due to slippage and broker rules; this is normal for all TradingView strategies.
- Always validate settings across multiple symbols and regimes before going live.

If you want, I can bundle this guide into a README section in your Pine code and add a small on‑chart signature (Author/Producer: yuu_iu) in the top‑right corner.
Nota Keluaran
Hello everyone, I'm Yuu_iu.

I'm truly excited to start sharing my scripts with the TradingView community. This isn't just a simple indicator; it's a complete strategy where I've attempted to simulate an artificial intelligence (AI) model for trading.

I developed this strategy about six months ago, and after an extensive period of backtesting and validation, I'm quite satisfied with the results.

First and most importantly: I personally hate repainting indicators. You can be 100% assured that this script does not repaint, ever. The signals are confirmed on the bar's close and will never change.

My Trading Methodology
My personal trading style, which this strategy is built upon, is an End-of-Day (EOD) approach. Here is my process:

At the end of the trading day (after the market closes), I scan my watchlist.

I look for any asset that has triggered a "Buy" signal from this strategy.

If a signal is present, I place an "At-The-Open" (ATO) order for the very next trading session.

It's a simple, low-stress process, right?

This script is designed to replicate that exact logic. Because it waits for the close, you can fully trust the backtesting results and the performance report generated in the "Strategy Tester" tab.

Optimization & Markets
A quick note on optimization: This strategy was heavily fine-tuned for the Vietnamese stock market (VN Index), as that is my primary market.

However, the underlying logic is robust, and it should still perform well in other markets (like Crypto, Forex, or other global indices). As always, please do your own research and backtesting on your specific asset and timeframe before trading live capital.

IMPORTANT: Turn This Setting Off!
One last thing: The script includes a "Backtesting Date Range" filter.

This feature is turned ON by default.

I leave it on so I can quickly test how the strategy performs during specific periods, like major downtrends or long sideways markets.

When you first add the indicator to your chart, you MUST go into the Settings and turn this feature OFF to see all current and historical signals.

Detailed User Guide
This strategy is designed for simplicity and is best used on the Daily (1D) timeframe to follow the EOD methodology.

1. How to Use (Intended Method)
Timeframe: Apply the script to the Daily (1D) chart.

Signal Check: Wait for the daily candle to close.

Entry: If a "Buy" (Long) signal appears on the closed candle, prepare to enter.

Execution: Place an "At-The-Open" (ATO) or market order at the beginning of the very next trading session.

Exit: The strategy will provide corresponding "Sell" (Close) signals for exiting the position. Follow these signals using the same EOD logic.

2. Strategy vs. Indicator Mode
This script can be used as both a Strategy (for backtesting) and an Indicator (for live signals).

Strategy Mode: Use the "Strategy Tester" tab at the bottom of your chart to see detailed performance reports, equity curves, and trade lists. This is perfect for seeing how it performed historically.

Indicator Mode: If you prefer to set your own alerts, you can load it as a regular "Indicator" and use the signals as you see fit.

3. Key Setting: Backtesting Date Range
As mentioned in the introduction, this is the most important setting to check first.

Location: Settings > Inputs > (Look for "Date Range" or "Time Filter")

Default: ON

Action: Turn this checkbox OFF when you first load the script.

Purpose: You can turn this back on later if you want to test performance during specific years (e.g., "only show me trades from 2022").

I hope this strategy proves useful to you. Please feel free to leave comments or feedback below!

Happy trading, Yuu_iu
Nota Keluaran
input_enable_date_filter = input.bool(true, "Enable Custom Date Filter", group="TRAINING CONTROL", tooltip="When enabled, the AI will only trade and learn within the Start Date and End Date range below.")

TO
input_enable_date_filter = input.bool(false, "Enable Custom Date Filter", group="TRAINING CONTROL", tooltip="When enabled, the AI will only trade and learn within the Start Date and End Date range below.")
Nota Keluaran
update chart

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.