TradingView
kocurekc
١٩ آب أغسطس ٢٠٢٠ ٠٢:٤١

Cumulative distribution function - Probability  

Bitcoin / DollarBitfinex

الوصف

Cumulative distribution function (tScore and zScore)

This script provides the calculation of the cumulative distribution function (i.e., probability). The measure allows you to calculate the chances of a value of interest being above or below a hypothesized value over the measurement period—nothing fancy here, just good old statistics and mathematics. The closer you are to 0 or 1, the more significant your measurement. We’ve included a significance level highlighting feature. The ability to turn price and/or volume off.

We have included both the Z and T statistics. Where the ‘Z’ is looking at the difference of the current value, minus the mean, and divided by the standard deviation. This is usually pretty noisy on a single value, so a smoother is included. Nice shoutout to the Pinecoders Github Page with this function also. The t-statistic is measuring the difference between a short measurement, an extended measurement, and divided by the standard error (sigma/sqrt(n)). Both of these are neatly wrapped into a function, so please feel free to use them in your code. Add a bit of science to your guessing game. For the purists out there, we have chosen to use sigma in the t-statistic because we know the population's behavior (as opposed to the s-measure). We’ve also included two levels of the t-statistic cumulative distribution function if you are using a short sample period below 6.

Finally, because everyone loves choices, we’ve included the ability to measure the probability of:
  • the current value (Price and volume)
  • change
  • percent change
  • momentum (change over a period of time)
  • Acceleration (change of the change)
  • contribution (amount of the current bar over the sum)
  • volatility (natural log ratio of today and the previous bar)


Here is a chart example explaining some of the data for the function.


Here are the various options you have the print the different measurements



A comparison of the t-statistic and z-statistic (t-score and z-score)


And the coloring options
التعليقات
tartigradia
You have created a diamond here! TradingView should pick your indicator, it truly is incredible! Not only is the idea awesome, but it is excellently executed! And open-source! It is now one of my main go to tools to analyze the interactions between volume and price. I'd just suggest to set significance thresholding enabled by default, otherwise it's too cluttered. Overall, the signals are highly reliable and even leading! A true marvel, thank you very much for kindly sharing your work.
kocurekc
@tartigradia, Thank you very much! I do appreciate your support and your kind words. If John Elhers can share his stuff, then so can we...
aNuFFi
Wow - ridiculously cool, kudo's!

Now just to find a way to utilise it ...
jplvirgo
joke on me but the normal CDF is actually a log-normal right? Awesome script, so much for me to learn!
Bruce-JSH
It's a really good and scientific approach.
I've been developing an indicator that calculates probabilities using the distribution of trade-related values.
I came across your post while searching for PDF and CDF functions.
kocurekc
@Bruce-JSH, Thanks, Happy to help...feel free to grab those functions and use them in your own scripts. I would really like to see what you come up with, drop me a note when you publish something.
r327079
Great concept.

Can you pl. clarify the numeric value used in { F_t & CDF } calculations. Is it related to avg value (88).

I am trying to create normal distribution function for script. It would be great help. I want to use 26 period length, will these value change.

Thanks
Cheers
kocurekc
@r327079, So the F_c/F_v are the CFDs for either the price or volume calculations, their booleans are for including price/volume, and booleans for either gaussian or T distributions (n_CFD and T_CFD respectively). The Len and AVG and Smoothing (smo) are just the lengths for either the t-statistic or SMA (plus smoothing). For the 26 periods, you can use the gaussian (normal), with avg=26, then add the smoother as needed (to reduce the bar to bar noise. Not super clear on the (88) reference, happy to help more, just let me know. You can also do a few searches on TV, because several gaussian distributions are already published.
wizawiz
@kocurekc This is legit. Can i use it on Day Trade charts to confirm momentum/squeeze?
المزيد