Probability Panel [BAPig]

Probability Panel is based on the Expected Move. While Expected Move gives fixed estimated probability range based on standard deviation, Probability Panel uses a cumulative distribution function(CDF) to get the estimated probability from any input price.

The CDF shows the probability a random variable X is found at a value equal to or less than a certain x.

In this model, we assume asset price follows a log-normal distribution and the log return follows a normal distribution.
Note: Normal distribution is just an assumption, it's not the real distribution of return

Setting "Estimation Period Selection" is for selecting the period we want to construct the prediction interval.
For "Current Bar", the interval is calculated based on the data of the previous bar close. Therefore changes in the current price will have little effect on the range. What current bar means is that the estimated range is for when this bar close. E.g., If the Timeframe on 4 hours and 1 hour has passed, the interval is for how much time this bar has left, in this case, 3 hours.

For "Future Bars", the interval is calculated based on the current close. Therefore the range will be very much affected by the change in the current price. If the current price moves up, the range will also move up, vice versa. Future Bars is estimating the range for the period at least one bar ahead.
There are also other source selections based on high low.

Time setting is only used when "Future Bars" is chosen for the period. The value in time means how many bars ahead of the current bar the range is estimating. When time = 1, it means the interval is constructing for 1 bar head. E.g., If the timeframe is on 4 hours, then it's estimating the next 4 hours range no matter how much time has passed in the current bar.
Note: It's probably better to use "probability cone" for visual presentation when time > 1

Probability Cone

Single side probability requires only one input. User can type in one side of the range in “Single Side Target Input” and probability panel will automatically give the other side of the range with the same amount of log return. Eg : 10% up and 10% down. (Equal probability when mean is zero).

Double side probability requires two input. “Target Upper Range” and “Target Lower Range”.

Target Upper Range is the input of the higher target to get the probability of closing above that target.
Target Lower Range is the input of the lower target to get the probability of closing below that target.
Target Upper Range should always be higher than the target lower range.
If the upper range is lower than lower range an error warning will appear.

Inside probability range is the probability of bar closing staying between the target upper range and lower range.
Outside probability range is the probability of bar closing staying outside the target upper range and lower range.

When target upper range is higher than the source (for estimation period "current bar" is the previous close, for "future bar" is current close). The probability closing above that target will always be lower than 50%. If it's lower than source, it's going to be higher than 50%.
When target lower range is lower than the source (for estimation period "current bar" is the previous close, for "future bar" is current close). The probability closing below that target will always be lower than 50%. If it's lower than source, it's going to be higher than 50%.

Note: All these probabilities are based on the normal distribution assumption for returns. It's the estimated probability, not the actual probability.

Volatility Models :

Sample SD: traditional sample standard deviation, most commonly used, use (n-1) period to adjust the bias

Parkinson: Uses High/ Low to estimate volatility , assumes continuous no gap, zero mean no drift, 5 times more efficient than Close to Close

Garman Klass: Uses OHLC volatility , zero drift, no jumps, about 7 times more efficient

Yangzhang Garman Klass Extension: Added jump calculation in Garman Klass, has the same value as Garman Klass on markets with no gaps.
about 8 x efficient

Rogers: Uses OHLC, Assume non-zero mean volatility , handles drift, does not handle jump 8 x efficient.

EWMA: Exponentially Weighted Volatility . Weight recently volatility more, more reactive volatility better in taking account of volatility autocorrelation and cluster.

YangZhang: Uses OHLC, combines Rogers and Garmand Klass, handles both drift and jump, 14 times efficient, alpha is the constant to weight rogers volatility to minimize variance.

Median absolute deviation: It's a more direct way of measuring volatility . It measures volatility without using Standard deviation. The MAD used here is adjusted to be an unbiased estimator.

Volatility Period is the sample size for variance estimation. A longer period makes the estimation range more stable less reactive to recent price. Distribution is more significant on larger sample size. A short period makes the range more responsive to recent price. Might be better for high volatility clusters.

People usually assume the mean of returns to be zero. To be more accurate, we can consider the drift in price from calculating the geometric mean of returns. Drift happens in the long run, so short lookback periods are not recommended. Assuming zero mean is recommended when time is not greater than 1.

When we are estimating the future range for time > 1, we typically assume constant volatility and the returns to be independent and identically distributed. We scale the volatility in term of time to get future range. However, when there's autocorrelation in returns( when returns are not independent), the assumption fails to take account of this effect. Volatility scaled with autocorrelation is required when returns are not iid. We use an AR(1) model to scale the first-order autocorrelation to adjust the effect. Returns typically don't have significant autocorrelation. Adjustment for autocorrelation is not usually needed. A long length is recommended in Autocorrelation calculation.
Note: The significance of autocorrelation can be checked on an ACF indicator.


Panel positions can be adjusted in the settings.
X position adjusts the horizontal position of the panel. Higher X moves panel to the right and lower X moves panel to the left.
Y position adjusts the vertical position of the panel. Higher Y moves panel up and lower Y moves panel down.

There's a bug in Tradingview label system. When the background of the label is transparent, the text will get burry when we scroll in and out on the chart. When this happens, changing any settings on the panel could refresh the text display. It could also be avoided by ticking the dark background setting to make the background not transparent.

People should not blindly trust the probability. They should be aware of the risk evolves by using the normal distribution assumption. The real return has skewness and high kurtosis . While skewness is not very significant, the high kurtosis should be noticed. The Real returns have much fatter tails than the normal distribution, which also makes the peak higher. This property makes the tail ranges such as range more than 2SD highly underestimate the actual range and the body such as 1 SD slightly overestimate the actual range. For ranges more than 2SD, people shouldn't trust them. They should beware of extreme events in the tails.

The probability is only for the closing price, not wicks. It only estimates the probability of the price closing at this level, not in between.

Probability Panel is absolutely neutral on the direction of price. It assumes there's an equal 50% to 50% chance of upward movement and downward movement from the source (When input = source, above and below target probability are both 50%) when drift is close to 0 (which is most of the time). Trying to get a directional bias by comparing the probability of upper and lower target is not recommended.

Remove from Favorite Scripts Add to Favorite Scripts
Our Website:

Sign up on our website to get access to our indicators.


Awesome work. Any chance i can use it?
+2 Reply
Would love to try this!
Any way to get access to your scripts? Love your work, cheers.
Amazing work !!
I would like to try it
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out