OPEN-SOURCE SCRIPT
Oracle

# Oracle
**Oracle** fits an adaptive, weighted polynomial regression to recent price action and projects the most likely path forward as **Japanese candlesticks** — so the forecast reads exactly like the chart you're already looking at, not an abstract line. On top of the forecast, Oracle draws a **Prediction Trail** of its own past forecasts, giving you an honest, visual track record of how accurate the model has actually been on the current symbol and timeframe.
It's designed around one principle: a projection is only as useful as your ability to trust it — so Oracle constantly shows you its confidence and adapts itself to fit the market better.
## 🔮 What it does
- Studies the last *N* candles and models their underlying curve (trend + curvature).
- Projects the next candles into the future and renders them as **up/down candlesticks with wicks**.
- Continuously scores the fit quality with **R²** and adjusts (or hides) the projection accordingly.
- Plots a **trail of past predictions** so you can compare "what the model expected" against "what actually happened."
## 🧠 How it works
- A **weighted quadratic regression** is fitted to recent closes, with more weight on the newest candles so the model stays responsive.
- The fitted curve is extrapolated forward to build the projected candles.
- An **R² confidence score** (0–100%) measures how cleanly price fits the model — high R² means a clean, trend-like structure; low R² means choppy, unpredictable conditions.
- Optional market filters refine the raw projection so it respects real market behavior.
## ✨ Key features
**Projection**
- Future path drawn as **projected candlesticks** (body + wick), color-coded up/down.
- Adjustable projection length, candle body width, and wick size.
**Prediction Trail (track record)**
- Plots the model's earlier forecasts, shifted forward, so each point lines up with the candle it was predicting.
- Instantly shows whether the model has been leading price accurately or diverging.
- Adjustable horizon, color, and width.
**Accuracy Enhancements (all optional)**
- **Auto-Optimize Lookback** — automatically selects the lookback window with the best fit (highest R²), so you don't have to guess.
- **Damp Far Extrapolation** — blends distant candles toward a straight line so the curve stays realistic and never "explodes."
- **Scale by Confidence** — flattens the projection toward price when fit quality is low, keeping forecasts conservative when the market is unclear.
**Context & filters**
- **ATR confidence bands** around the projection (static or volatility-adjusted).
- **Volume Delta** bias, **EMA trend** filter, **RSI** softening, and **Support/Resistance** capping — each toggled independently.
**Usability**
- R² confidence label + info readout (ATR, volume ratio, volatility factor).
- Fully customizable colors, widths, label sizes, and an analysis start-date filter.
- **Every input has a built-in tooltip** explaining what it does.
## ⚙️ Suggested workflow
1. Add Oracle to a clean chart and keep the default enhancements on.
2. Read the **R² label** first — the higher it is, the more weight the projection deserves.
3. Check the **Prediction Trail**: if it has been hugging price recently, the model is in tune with this market; if it's diverging, treat the forecast with caution.
4. Use the projected candles as a **scenario / bias**, then confirm with your own strategy and risk plan.
**Tips:** Raise the *Min Confidence Threshold* and keep *Damping* on for calmer, more realistic forecasts. Use a longer lookback for swing context and a shorter one for intraday.
## 📈 Best on
Works on **any market and timeframe** — crypto, forex, indices, metals, and stocks. Trending and structured conditions produce the highest R² and the most reliable projections; in pure chop, low confidence will (correctly) flag the projection as unreliable.
## ⚠️ Disclaimer
Oracle is a **statistical projection and study tool**. It does not predict the future, guarantee any outcome, or constitute financial advice. Markets are uncertain — always do your own analysis and manage your risk. Past model behavior (including the Prediction Trail) does not guarantee future accuracy.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
هوزان طاهر: مبرمج ومتداول خبير (6+ سنوات). متخصص في التحليل الفني (إليوت، SMC، وايكوف، التحليل الزمني) واستراتيجيات التداول (Alpha). أقدم تدريبًا وأطور روبوتات تداول ذكية. (للتواصل، انظر روابط الملف الشخصي)
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
هوزان طاهر: مبرمج ومتداول خبير (6+ سنوات). متخصص في التحليل الفني (إليوت، SMC، وايكوف، التحليل الزمني) واستراتيجيات التداول (Alpha). أقدم تدريبًا وأطور روبوتات تداول ذكية. (للتواصل، انظر روابط الملف الشخصي)
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。