IQ Session Bayesian Particle Filter [TradingIQ]🔹 OVERVIEW
This indicator runs a genuine Sequential Monte Carlo particle filter; the Bayesian architecture used in robotics and signal tracking... on your chart! Session by session, it learns where trading volume concentrates and paints a forecast of the coming session's entire volume-by-price distribution before that session unfolds: every expected high-volume level at once, not a single line.
It is not a moving average wearing a costume. Each finished session is treated as evidence: hundreds of particles are weighed against what actually traded, resampled, and mutated. Predict → observe → update, honestly Bayesian, every session.
🔹 HOW IT WORKS
Two particle swarms run side by side:
• A shape swarm learns the form of the distribution; one lump or several, wide or tight, and where each volume node sits.
• A drift swarm learns how far from the open the session's center of gravity tends to land.
An empirical-Bayes trust term scales the drift forecast by how much it has actually earned: when its track record is poor, the forecast automatically hugs the open. The prediction you see is the shape swarm's density, re-anchored by the trusted fraction of the drift forecast, rendered through a kernel density estimate whose bandwidth follows Silverman's rule.
🔸 HOW TO READ IT
• Session heatmap — the predicted density painted from the session open to the profile. A two-tone gradient split at the open; the tones swap roles across it, so each side mirrors the other. Bold color = expected business, fade = expected quiet.
• Mirrored profile — the forecast on the left, split bullish/bearish at the session open; the realized session volume on the right in a single neutral color.
• Confidence honesty — the prediction's glow scales with the filter's live confidence. When it has been wrong lately, its side visibly goes quiet. The realized side never fades, because reality doesn't.
• Bias info box — seated between the halves: the share of predicted volume above vs below the open (🢁 / 🢃).
• Expected levels — dashed lines at the probability-weighted average predicted price of each half: the session's expected bull and bear magnets.
• HVN lines + POC — the predicted high-volume levels. The point of control always shows; the HVN Threshold input is your dial between a few safe targets and every level worth watching.
🔹 SELF-TUNING
Every statistical free parameter tunes itself from data: the KDE bandwidth (Silverman's rule for visual convenience), the observation noise, the swarms' search domain (tracks the observed session spread), the mutation rate (genetic adaptation), the scout rate (scales with recent error), and the center trust (regression shrinkage). The inputs you are given are visual preferences plus a compute preset. There is nothing statistical to fiddle with, on purpose.
🔸 INPUTS
• Session Engine — Session Timeframe (the session boundary; must exceed the chart timeframe), Prediction Quality (particles per swarm, Fast 100 → Max 4000), Sessions to Keep.
• Volume Profile — toggles for the profile, bias box and expected levels; width, offset, info-box width, transparency.
• Session Heatmap — toggle, faint/bold density transparencies, Tone A / Tone B.
• High Volume Nodes — toggle, HVN Threshold %, reach, color.
• Colors — Bullish, Bearish, Realized.
🔹 VALIDATION
The filter was tested on real intraday data; 10 large-cap symbols, three session horizons, every prediction one-step-ahead and out-of-sample, against uniform, yesterday's-profile, Gaussian-fit, rolling-average and EWMA baselines, with the test harness itself audited too.
• Against naive prediction (uniform prior, yesterday's profile) it wins every metric tested at every horizon.
• Against the strongest profile-averaging methods it trades wins: they edge the single-lump fit metrics; the filter captures materially more of the session's actual traded volume with its predicted levels, and is the only method that reliably names multiple simultaneous targets .
• On sessions with two or more real volume peaks; roughly 4 in 10 sessions, its targets covered 19–42% more realized volume than the best alternative.
🔸 LIMITATIONS AND HONEST NOTES
• The forecast for a session is set when that session opens and is not repainted ; the realized half updates live as the session trades.
• It estimates a distribution of volume , not a promise of direction. The bias %, expected levels and HVN set are probability-weighted readings of that distribution.
• The filter is stochastic by nature: two chart reloads can differ in fine detail, the way two runs of any Monte Carlo method do. The structure it finds is stable; the pixel-level noise is not.
• Requires volume data from your data feed. Not supported on non-standard chart types.
• The chart timeframe must be lower than the session timeframe.
Gösterge

Strategy Forecast EngineThe Strategy Forecast Engine is a regime-based Monte Carlo forecasting tool that estimates the future return distribution of trend-following strategies across different market environments. The model identifies the current market regime, conditions forecasts on historical returns observed during comparable regimes, and generates thousands of potential future price paths using Monte Carlo simulation. The resulting return distribution is presented through percentile projections and a structured, color-coded table that provides a comprehensive assessment of the forecast.
First, the model identifies the current market regime using the selected trend-following strategy. Users can choose between a moving-average crossover strategy, a volatility-based trailing stop strategy, or a combined strategy that incorporates both approaches. Supported moving-average types include the Exponential Moving Average (EMA), Simple Moving Average (SMA), Wilder’s Moving Average (RMA), and Weighted Moving Average (WMA). Supported volatility types include the Average True Range (ATR), Standard Deviation (SD), and Mean Absolute Deviation (MAD). By default, the model applies an asymmetric design in which conflicting signals default to bullish unless neutral regimes are enabled in the menu. Market regimes are determined as follows:
Bullish Trend Regime = (Fast MA – Slow MA) > (ATR × Trend Margin)
Bearish Trend Regime = (Fast MA – Slow MA) < –(ATR × Trend Margin)
Bullish Volatility Regime = Price > (Highest Price – (Volatility × Stop Factor))
Bearish Volatility Regime = Price < (Lowest Price + (Volatility × Stop Factor))
Bullish Combined Regime = Bullish Trend Regime and Bullish Volatility Regime
Bearish Combined Regime = Bearish Trend Regime and Bearish Volatility Regime
Once the current regime has been identified, the model collects all historical logarithmic returns that occurred during the same regime beginning from the selected start date. Only returns from the matching regime are used to generate the forecast, allowing projections to be conditioned on historically comparable market environments rather than treating all historical observations as equally relevant. If duration-adjusted forecast is enabled in the menu, the model further restricts the sample pool to returns from regimes that were at least as mature as the current regime.
The Monte Carlo simulation engine then generates thousands of possible future price paths over the selected forecast horizon. Each simulation randomly samples historical returns from the sample pool associated with the current regime and compounds them forward to generate a potential future price path. This process is repeated for the specified number of simulations to produce a broad range of possible future outcomes. The random seed controls reproducibility, ensuring that identical settings produce identical forecasts. Once all individual simulations have been completed, the resulting return distribution is summarized using percentile projections:
95% = 5% of simulations ended above this level and 95% ended below it.
75% = 25% of simulations ended above this level and 75% ended below it.
Median = 50% of simulations ended above this level and 50% ended below it.
25% = 25% of simulations ended below this level and 75% ended above it.
5% = 5% of simulations ended below this level and 95% ended above it.
The upper quartile (75%) and lower quartile (25%) define the Interquartile Range (IQR), which contains the middle 50% of all simulated outcomes and represents the central range of the projected outcome distribution. The upper and lower tail percentiles can be set to 10% (90% / 10%), 5% (95% / 5%), or 1% (99% / 1%). The default setting is 5%, which captures the middle 90% of simulated outcomes. At 10%, the range captures 80% of simulated outcomes, while at 1%, the range captures 98% of simulated outcomes. To further evaluate the risk/reward characteristics of the forecast, the model includes a built-in table with the following metrics:
Regime = Current market regime based on the selected strategy configuration.
Duration = Percentile rank of current regime duration relative to past regimes.
Forecast = Percentile rank of current duration including the forecast horizon.
Win Rate = Percentage of profitable simulations relative to total simulations.
Profit Factor = Ratio of total simulated profits to total simulated losses.
Expectancy = Average expected percentage return across all simulations.
Reward/Risk = Ratio of upper quartile return to lower quartile return.
Asymmetry = Ratio of selected upper tail return to selected lower tail return.
Skewness = Ratio of upside potential to downside risk relative to the median.
Sample Size = Number of historical returns available for the current regime.
Frequency = Percentage of historical returns belonging to the current regime.
In summary, the Strategy Forecast Engine is a comprehensive forecasting tool designed to help investors evaluate the return distribution of trend-following strategies based on the current market regime. By combining regime detection with Monte Carlo simulation, the model conditions forecasts on historical returns observed during comparable market regimes to estimate the distribution of potential outcomes and their associated risk/reward characteristics. While the model provides valuable insight into historical return patterns, investors should remain mindful that historical market behavior may not necessarily persist under future market conditions. Gösterge

Monte Carlo Simulation BandsMonte Carlo Simulation v2.4.2
Plots a one-bar-ahead price distribution band built from many simulated paths. The green band shows empirical percentiles of simulated final prices—these are distribution bounds, not a confidence interval of the mean.
What It Does
Simulates many one-bar price paths using a directional random walk with volatility scaling (uniform shocks, not Gaussian GBM).
Plots Mean Forecast, Median Forecast, and configurable percentile bounds (default 5th/95th).
Optional rolling HTF-days mean line (yellow) for trend context.
Optional labels and forward projection lines.
Alerts when the confirmed close breaks above or below the percentile band.
Non-Repainting & HTF Behavior (Fail-Closed)
All calculations are gated to confirmed bars only via explicit no_repaint_ok gate (barstate.isconfirmed).
If you select an HTF Resolution, the script uses a strict request.security(..., lookahead_off, gaps_off) pipeline.
If HTF data is unavailable, outputs are na—no silent fallback to chart timeframe.
A separate "HTF Alignment (lagged)" plot shows the prior HTF close (htf_price ) as visual proof of no look-ahead.
Volatility Source & Scaling
If "Use Historical Volatility" is enabled, volatility is estimated from log returns on the selected resolution (HTF if set, otherwise chart).
Annualization adapts to session type:
Equities: 6.5 hours/day, 252 trading days/year
Crypto: 24 hours/day, 365 days/year
Substeps increase path smoothness within the same one-bar horizon—they do not extend the forecast to multiple bars.
Key Inputs
• Prob Up / Prob Down — Must satisfy Prob Up + Prob Down ≤ 1.0. If violated, simulation is skipped and table shows "✗ PROB>1".
• # Simulations / # Substeps — Higher = smoother/more stable, but slower. Default 100×100 is a good balance.
• Lower/Upper Percentile — Define the band width (e.g., 5 and 95 for a 90% distribution band).
• Run On Last Bar Only — Performance mode (recommended). Skips historical computation; updates on each new confirmed bar.
• Resolution (HTF) — Leave blank for chart timeframe, or set to Weekly/Monthly for HTF-aligned simulation.
• Crypto 24/7 Session? — Enable for crypto markets to use correct annualization (365d, 24h).
How to Use (Quickstart)
Start with defaults and keep Run On Last Bar Only = true for speed.
Set Prob Up and Prob Down so their sum ≤ 1.0 (e.g., 0.5 + 0.5 = 1.0 for neutral).
Enable "Use Historical Volatility" and set a Volatility Lookback (e.g., 20 bars) for data-driven vol.
Set Resolution (HTF) if you want the model to run on higher timeframe data (e.g., 1W). Expect updates only when a new HTF interval starts.
Choose percentiles (e.g., 5 and 95) to define your distribution band width.
Enable alerts for "Price Above Upper Percentile" or "Price Below Lower Percentile" to get notified of breakouts.
Limitations & Disclosures
Forecast horizon is one bar only. Substeps do not create a multi-bar forecast.
Model uses uniform shocks with direction chosen from Prob Up/Down. This is not Geometric Brownian Motion (GBM) and is not calibrated to any option-implied distribution.
Bounds are percentiles of final simulated prices, not a statistical confidence interval of the mean.
HTF mode updates at the start of a new HTF interval (first chart bar where the HTF timestamp changes), so the band appears "step-like" in realtime.
Historical volatility requires enough bars for the selected lookback; until then, values may be na.
Performance depends on Sims × Substeps; extreme settings (e.g., 500×500) can be slow.
This indicator does not predict direction—it shows a probabilistic range based on your inputs.
Gösterge

Multi Brownian Forecast📊 Multi Brownian Forecast (Time-Adaptive, Probabilistic)
This indicator uses a sophisticated Geometric Brownian Motion (GBM) Monte Carlo simulation to project future price paths. It adapts to any chart timeframe and provides quantitative, multi-period probability signals.
---
🧠 Core Mathematical Methodology
The model relies on GBM, which is a continuous-time stochastic process that models asset prices.
1. Historical Analysis (Drift & Volatility):
* The script first calculates Logarithmic Returns over a user-defined Historical Lookback (Hours) .
* Drift ($\mu$): Computed as the average of the log returns.
* Volatility ($\sigma$): Computed as the standard deviation of the log returns.
* These values are then time-adapted to an hourly step, compensating for the chart's current timeframe (e.g., 5-minute, 1-hour).
2. Monte Carlo Simulation:
* It runs a specified Number of Simulations (e.g., 1000).
* For each simulation, the price is stepped forward hourly using the GBM formula, which incorporates the calculated drift and a random shock drawn from a normal distribution (generated via the Box-Muller transform ).
---
✨ Key Features
Probabilistic Quartile Forecast: Plots a dynamic "cone" of probability on the chart. It shows key price percentiles (Q1, Q2/Median, Q3, and Q4/Outer Bound) at the forecast's expiration, visualizing the expected range of price outcomes based on the simulations.
Multi-Period Probability Signals: This is the core signal feature. Users can define multiple, independent forecast periods (e.g., 4h, 16h, 48h) in a comma-separated list.
* For each period, a Probability Up and Probability Down is calculated based on hitting a custom Target Price Change (%) (e.g., 2%) at a certain confidence level given a simulation over the historical backlook.
* The probabilities are displayed in a chart table. The cell text turns white if the calculated probability exceeds the user-defined Signal Confidence (%) .
Conditional Fibonacci Retracement: Optionally displays a Fibonacci Retracement on the chart. This feature is only activated when one of the multi-period signals reaches its minimum confidence threshold, providing a contextual technical level when a probabilistic edge is found.
Gösterge

Monte Carlo (Polyline Traceback) [Kioseff Trading]Hello!
This script "Monte Carlo (Polyline Traceback) " performs a Monte Carlo simulation using polylines!
By using polylines, and tracing back the initial simulation to its origin point, we can better replicate the ideal output of a Monte Carlo simulation!
Such as:
The image above shows the output of a simulation (image sourced outside TV).
With this script, and polyline capabilities, we can come quite close on TradingView.
The image above shows the indicator in action! Not bad considering the ideal output.
Of course, the script is quite heavy and tries its best to circumvent limitations :D
You might run into load time errors, in which case you might try applying the built-in setting "Force Script Load". This setting will cut-off the visuals for some simulations, but has a higher chance of passing load-time limitations!
As shown in the image above, you can select to only show worst-case and best-case simulations. Using this option will reduce chart lag and improve load times.
Features
Monte Carlo Simulation: Performs Monte Carlo simulation to generate multiple future paths.
Asset Price: Can simulate future asset prices based on historical log returns.
Statistical Methods: Offers two simulation methods—Gaussian (Normal) distribution and Bootstrapping.
Adjustable Parameters: Offers numerous user-adjustable settings like number of simulations, forecast length, and more.
Historical Data Points: Option to specify the amount of historical data to be used in the simulation (price).
Best/Worst Case: Allows you to show only the best case / worst case outcome (range) for all simulations!
Thank you! Gösterge

Monte Carlo Simulation - Your Strategy [Kioseff Trading]Hello!
This script “Monte Carlo Simulation - Your Strategy” uses Monte Carlo simulations for your inputted strategy returns or the asset on your chart!
Features
Monte Carlo Simulation: Performs Monte Carlo simulation to generate multiple future paths.
Asset Price or Strategy: Can simulate either future asset prices based on historical log returns or a specific trading strategy's future performance.
User-Defined Input: Allows you to input your own historical returns for simulation.
Statistical Methods: Offers two simulation methods—Gaussian (Normal) distribution and Bootstrapping.
Graphical Display: Provides options for graphical representation, including line plots and histograms.
Cumulative Probability Target: Enables setting a user-defined cumulative probability target to quantify simulation results.
Adjustable Parameters: Offers numerous user-adjustable settings like number of simulations, forecast length, and more.
Historical Data Points: Option to specify the amount of historical data to be used in the simulation (price).
Custom Binning: Allows you to select the binning method for histograms, with options like Sturges, Rice, and Square Root.
Best/Worst Case: Allows you to show only the best case / worst case outcome (range) for all simulations!
Scatterplot: allows you to show up to 1000 potential outcomes for a specified trade number (or bars forward price endpoint) using a scatter plot.
The image above shows the primary components of the indicator!
The image above shows the best/worst case outcome feature in action!
The image above shows a "fun feature" where 1000 simulated end points for a 15-bar price trajectory are shown as a scatter plot!
How To Perform a Monte Carlo Simulation On Your Strategy
Really, you can input any data into the indicator it will perform a Monte Carlo Simulation on it :D
The following instructions show how to export your strategy results from TradingView to an Excel File, copy the data, and input it into the indicator.
However , you are not limited to following this method!
Wherever your strategy results are stored, simply copy and paste them into the indicator text area in the settings and simulations will begin.
Returns Should Follow This Format
1
3
-3
2
-5
The numbers are presented as a single column. No commas or separators used.
The numbers above are in sequential order. A return of "1" for the first trade and a return of "-5" for the last trade. Your strategy returns will likely be in sequential order already so don't worry too much about this (:
How To Perform a Monte Carlo Simulation On Your TradingView Strategy With Excel Data
Export your strategy returns to an excel file using TradingView
Navigate to your downloads folder to column G "Profit"
Click the column and press CTRL + SPACE to highlight the entire column
Press CTRL + C to copy the entire column
Open this indicator's settings and paste the returns into the text area
The image above illustrates the process!
Notes on Inputting Returns
*Must input your returns without a separate as a vertical list
*The initial text area can only hold so many return values. If your list of trades is large you can input additional returns into two additional text areas at the bottom of the indicator settings.
That should be it; thank you for checking this out!
Gösterge

Gösterge
