Editor's PicksOPEN-SOURCE SCRIPT

Probability Cones

Aktualisiert
A probability cone is an indicator that forecasts a statistical distribution from a set point in time into the future.

Features
  • Forecast a Standard or Laplace distribution.
  • Change the how many bars the cones will lookback and sample in their calculations.
  • Set how many bars to forecast the cones.
  • Let the cones follow price from a set number of bars back.
  • Anchor the cones and they will not update from their last location.
  • Show or hide any set of cones.
  • Change the deviation used of any cone's upper or lower line.
  • Change any line's color, style, or width.
  • Change or toggle the fill colors between any two cone lines.


Basic Interpretations
  • First, there is an assumption that the distribution starting from the cone's origin, based on the number of historical bars sampled, is likely to represent the distribution of future price.
  • Price typically hangs around the mean.
  • About 68% of price stays within the first deviation cones.
  • About 95% of price stays within the second deviation cones.
  • About 99.7% of price stays within the third deviation cones.
  • When price is between the first and second deviation cones, there is a higher probability for a reversal.
  • However, strong momentum while above or below the first deviation can indicate a trend where price maintains itself past the first deviation. For this reason it's recommended to use a momentum indicator alongside the cones.
  • There is no mean reversion assumption when price deviates. Price can continue to stay deviated.
  • It's recommended that the cones are placed at the beginning of calendar periods. Like the month, week, or day.
  • Be mindful when using the cones on various timeframes. As the lookback setting, which selects the number of bars back to load from the cone's origin, will load the number of bars back based on the current timeframe.


Second Deviation Strategy
How to react when price goes beyond the second deviation is contingent on your trading position.
  • If you are holding a losing trade and price has moved past the second deviation, it could be time to stop trading and exit.
  • If you are holding a winning trade and price has moved past the second deviation, it would be best to look at exit strategies to capitalize on the outperformance.
  • If price has moved beyond the second deviation and you hold no position, then do not open any new trades.
Versionshinweise
  • Update cone input setting labels with "Upper" and "Lower" prefixes.
Versionshinweise
  • Add Anchor Type input. Select between placing the origin based on bars or a date selection.
  • New Select Date to Place Cones input. When Anchor Type is set to Select Date, the input will anchor and start the cone's origin from a selected date.
  • Add RicardoSantos to Acknowledgements for Date Select feature contribution. Thank you!
Versionshinweise
  • Fix: OriginAnchor and OriginAnchorSub switch update.
Versionshinweise
Recommended update! Remove and readd the indicator to your charts.
  • Resolve error: "The study references too many candles in history (5001)."
Versionshinweise
New cone anchor feature and quality-of-life inputs/tooltips update.
  • Add "Higher Timeframe" to Anchor Type input. Anchor the cones to the beginning of a higher timeframe automatically.
  • Add "Anchor Offset" input. Only effects the Higher Timeframe Anchor Type. Set to 1 by default. Offsets the cones to the right or left of the anchor position. Left is a positive number, right is negative.
  • Change "Anchor Cones to Bars Back" input to "Lock Cones to Anchor Type". Tooltip reflects change.
  • Update "Distribution" input tooltip.
  • Update "Bar Forecast" input tooltip. Gives instructions on how to get forecasts past 70 bars.
  • Add "Enable Fills" input tooltip.
  • Update the Mean Settings section input layout.

What is the purpose of off-setting the Higher Timeframe anchor from its original anchor point?
When forecasting a period it is helpful to make the desired anchor point of the cone itself out of sample. This is especially noticeable using the Higher Timeframe Anchor Type. If the cones are anchored to the first candle of a period, and that candle is highly volatile, then that volatile candle will significantly alter the cones in spread and direction. It is arguably safer, at least certainly a more consistent practice for interpretations, to offset the cones so that they're not in sample of the desired forecast period.
Versionshinweise
Changelog
  • Update "Distributions" input title to to "Deviations". This more accurately represents what is being selected.
  • The "Laplace" setting now says "Laplace Stdev" to clarify that it is the standard deviation measure.
  • Add "Absolute" to Deviations input, this is the Absolute Deviation of the Mean input.
  • New "Mean" input to select the desired mean for a deviation calculation. Default setting is "Auto" which will pick a predetermined mean for each selected Deviation input.
  • Switch between Median Absolute Deviation and Average Absolute Deviation by changing the Mean calculation input.
  • Mean Auto Setting:"Standard" uses Average. "Laplace Stdev" uses Median. "Absolute" uses Median.
  • Update note on Basic Interpretations for the cones below.
  • Change "Anchor Offset" input title to "HTF Anchor Offset" for clarity.


Why switch from "Distributions" to "Deviations"?
Because no statistical distributions (CDFs / PDFs) are being calculated in this indicator. This indictor offers measurements for different kinds of statistical deviations to calculate the upper and lower cones with. Each cone line is a multiple of that deviation above and below the mean.

There are 2 major points from in the Basic Interpretations section that need to be updated:
1. The 68-95-99.7 rule does not apply when interpreting the cones. That applies to log returns, not price.
2. There is no higher probability or assumption of reversal when price is "between the first and second deviation cones."
Thanks to lejmer for his help, advice, and these corrections for the interpretations.

What is Absolute Deviation?
Mean Absolute Deviation, or MAD for short, it is another way of measuring the variability of data.

Wikipedia, "Moreover, the MAD is a robust statistic, being more resilient to outliers in a data set than the standard deviation. In the standard deviation, the distances from the mean are squared, so large deviations are weighted more heavily, and thus outliers can heavily influence it. In the MAD, the deviations of a small number of outliers are irrelevant."
Versionshinweise
Correction: Thanks to Anton Berlin for his help, advice, and these corrections for the interpretations.

lejmer's acknowledgement was for an separate project, an open source library I have in development.
Versionshinweise
  • 🆕 Use Mean Drift tick input. Adds or removes the drift to the cones caused by the mean's increasing or decreasing value in the future. Turning Use Mean Drift off projects forward only the initial value of the mean, and shifts the values of the cone's deviation lines relative to the mean.
Versionshinweise
Refactored the indicator's code. It's half the code line length, with more features, and loads significantly faster!

  • 🆕 Toggle "Stepped Cone Lines" switch the cones from drawing a curve to a set of horizontal lines. Making it easier to find each forecasted timestep's value.
  • 🆕 Toggle "Anchor Lines" to display lines that connect to the anchor bar.
  • 🆕 Toggle "Open Anchor" to switch between including or excluding the anchor bar in the volatility calculation. Disabling this will connect the cone's lines to the anchor point.
  • 🔄 Rework deviation line toggles so the upper and lower cone line can be toggled individually.
  • 🔄 Rename "Lock Cones to Anchor Type" to "Bars Back Lock" as it now only impacts the Bars Back Anchor Type.
  • 🔄 Rename "Select Date to Place Cones" to "Date Anchor" and update default to January 1st 2024.
  • 🔄 Rename "HTF Anchor Offset" to "Anchor Offset". This offset now applies to all Anchor Types.
  • 🔄 Move upper and lower cone fill toggles next to their respective fill color inputs.
  • 📝 Update tooltips and add some for the new settings.
  • ⏩ Indicator loading speed and recalculation improvements.


This update adds the "Open Anchor" setting which can give slightly different cone calculations from the last version. If you want the cones to calculate exactly like in the last version, simply toggle the "Open Anchor" setting on and adjust the rest of your settings as you like.
conesdistributionforecastforecastingjoebauslaplaceprobabilitystandardStandard DeviationVolatility

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?


Auch am:

Haftungsausschluss