[Pandora] Error Function Treasure Trove - ERF/ERFI/Sigmoids+PRAISE:
At this time, I have to graciously thank the wonderful minds behind the new "Pine Profiler Mode" (PPM). Directly prior to this release, it allowed me to ascertain script performance even more. While I usually write mostly in highly optimized Pine code, PPM visually identified a few bottlenecks that would otherwise be hard to identify. Anyone who contributed to PPMs creation and testing before release... BRAVO!!! I commend all of those who assisted in it's state-of-the-art engineering and inception, well done!
BACKSTORY:
This script is specifically being released in defense of another member, an exceptionally unique PhD. It was brought to my attention that a script-mod-event occurred, regarding the publishing of a measly antiquated error function (ERF) calculation within his script. This sadly resulted in the now former member jumping ship after receiving unmannerly responses amidst his curious inquiries as to why his erf() was modded. To forbid rusty and rudimentary formulations because a mod-on-duty is temporally offended by a non-nefarious release of code, is in MY opinion an injustice to principles of perpetuating open-source code intended to benefit thousands to millions of community members. While Pine is the heart and soul of TV, the mathematical concepts contributed from the minds of members is the inspirational fuel of curiosity that powers it's pertinent reason to exist and evolve.
It is an indisputable fact that most members are not greatly skilled Pine Poets. Many members may be incapable of innovating robust function code in Pine, even if they have one or more PhDs. We ALL come from various disciplines of mathematical comprehension and education. Some mathematicians are not greatly skilled at coding, while some coders are not exceptional at math. So... what am I to do to attempt to resolve this circumstantial challenge??? Those who know me best are aware that I will always side with "the right side of history" in order to accomplish my primary self-defined missions I choose to accept. Serving as an algorithmic advocate, I felt compelled to intercede by compiling numerous error functions into elegant code of very high caliber that any and every TV member may choose to employ, so this ERROR never happens again.
After weeks of contemplation into algorithms I knew little about, I prioritized myself to resolve an unanticipated matter by creating advanced formulas of exquisitely crafted error functions refined to the best of my current abilities. My aversion for unresolved problems motivated me to eviscerate error function insufficiencies with many more rigid formulations beyond what is thought to exist. ERF needed a proper algorithmic exorcism anyways. In my furiosity, I contemplated an array of madMAXimum diplomatic demolition methods, choosing the chain saw massacre technique to slaughter dysfunctionalities I encountered on a battered ERF roadway. This resulted in prolific solutions that should assuredly endure the test of time. Poetically, as you will come to see, I am ripping the lid off of Pandora's box of error functions in this case to correct wrongs into a splendid bundle of rights for members.
INTENTION:
Error function (ERF) enthusiasts... PREPARE FOR GLORY!! The specific purpose of this script is to deprecate classic error functions with the creation of a fierce and formidable army of superior formulations, each having varying attributes of computational complexity with differing absolute error ranges in their results for multiple compute scenarios. This is NOT an indicator... It is intended to allow members to embark on endeavors to advance the profound knowledge base of this growing worldwide community of 60+ million inquisitive minds. For those of you who believe computational mathematics and statistics is near completion at its finest; I am here to inform you, this is ridiculous to ponder. We are no where near statistical excellence that can and will exist eventually. At this time, metaphorically speaking, we are merely scratching microns off of the surface of the skin of a statistical apple Isaac Newton once pondered.
THIS RELEASE:
Following weeks of pondering methodical experiments beyond the ordinary, I am liberating these wild notions of my error function explorations to the entire globe as copyleft code, not just Pine. This Pandora's basket of ERFs is being openly disclosed for the sake of the sanctity of mathematics, empirical science (not the garbage we are told by CONTROLocrats to blindly trust), revolutionary cutting edge engineering, cosmology, physics, information technology, artificial intelligence, and EVERY other mathematical branch of human knowledge being discovered over centuries. I do believe James Glaisher would favor my aims concerning ERF aspirations embracing the "Power of Pine".
The included functions are intended for TV members to use in any way they see fit. This is a gift to ALL members to foster future innovative excellence on this platform. Any attempt to moderate this code without notification of "self-evident clear and just cause" will be considered an irrevocable egregious action. The original foundational PURPOSE of establishing script moderation (I clearly remember) was primarily to maintain active vigilance over a growing community against intentional nefarious actions and/or behaviors in blatant disrespect to other author's works AND also thwart rampant copypasting bandit operations, all while accommodating balanced principles of fairness for an educational community cause via open source publishing that should support future algorithmic inventions well beyond my lifespan.
APPLICATIONS:
The related error functions are used in probability theory, statistics, and numerous and engineering scientific disciplines. Its key characteristics and applications are innumerable in computational realms. Its versatility and significance make it a fundamental tool in arenas of quantitative analysis and scientific research...
Probability Theory - Is widely used in probability theory to calculate probabilities and quantiles of the normal distribution.
Statistics - It's related to the Gaussian integral and plays a crucial role in statistics, especially in hypothesis testing and confidence interval calculations.
Physics - In physics, it arises in the study of diffusion equations, quantum mechanics, and heat conduction problems.
Engineering - Applications exist in engineering disciplines such as signal processing, control theory, and telecommunications.
Error Analysis - It's employed in error analysis and uncertainty quantification.
Numeric Approximations - Due to its lack of a closed-form expression, numerical methods are often employed to approximate erf/erfi().
AI, LLMs, & MACHINE LEARNING:
The error function (ERF) is indispensable to various AI applications, particularly due to its relation to Gaussian distributions and error analysis. It is used in Gaussian processes for regression and classification, probabilistic inference for Bayesian networks, soft margin computation in SVMs, neural networks involving Gaussian activation functions or noise, and clustering algorithms like Gaussian Mixture Models. Improved ERF approximations can enhance precision in these applications, reduce computational complexity, handle outliers and noise better, and improve optimization and convergence, possibly leading to more accurate, efficient, and robust AI systems.
BONUS ALGORITHMS:
While ERFs are versatile, its opposite also exists in the form of inverse error functions (ERFIs). I have also included a modified form of the inverse fisher transform along side MY sigmoid (sigmyod). I am uncertain what sigmyod() may be used for, but it's a culmination of my examinations deep into "sigmoid domains", something I am fascinated by. Whatever implications it may possess, I am unveiling it along with it's cousin functions. For curious minds, this quality of composition seen here is ideally what underlies what I would term "Pandora functionality" that empowers my Pandora indication. I go through hordes of formulations, testing, and inspection to find what appears to be the most beneficial logical/mathematical equation to apply...
SCRIPT OPERATION:
To showcase the characteristics and performance of my ERF/ERFI formulations, I devised a multi-modal script. By using bar_index , I generated a broad sequence of numeric values to input into the first ERF/ERFI parameter. These sequences allow you to inspect the contours of the error function's outputs for both ERF and ERFI. When combined with compute-intensive precision functions (CIPFs), the polynomial function output values can be subtracted from my CIPFs to obtain results of absolute error, displaying the accuracy of the many polynomial estimation functions I tuned in testing for Pine's float environment.
A host of numeric input settings are wildly adjustable to inspect values/curvatures across the range of numeric input sequences. Very large numbers, such as Divisor:100,000,100/Offset:200,000,000 for ERF modes or... Divisor:100,000,100/Offset:100,000,000 for ERFI modes, will display miniscule output values calculated from input values in close proximity to 0.0 for the various estimates, similar to a microscope. ERFI approximations very near in proximity to +/-1.0 will always yield large deviations of absolute error. Dragging/zooming your chart or using the Offset input will aid with visually clipping off those ERFI extremes where float precision functions cannot suffice.
NOTICE:
perf() and perfi() are intended for precision computation (as good as it basically gets) in a float environment. However, they are CPU intensive (especially perfi). I wouldn't recommend these being used in ANY Pine script unless it's an "absolute necessity" to do so to accomplish your goal. I only built them to obtain "absolute error curvatures" of the error functions for the polynomial approximations. These are visible in the accuracy modes in the indicator Settings.
Sigmoid
Dynamic Gradient Filter
Sigmoid Functions:
History and Mathematical Basis:
Sigmoid functions have a rich history in mathematics and are widely used in various fields, including statistics, machine learning, and signal processing.
The term "sigmoid" originates from the Greek words "sigma" (meaning "S-shaped") and "eidos" (meaning "form" or "type").
The sigmoid curve is characterized by its smooth S-shaped appearance, which allows it to map any real-valued input to a bounded output range, typically between 0 and 1.
The most common form of the sigmoid function is the logistic function:
Logistic Function (σ):
Defined as σ(x) = 1 / (1 + e^(-x)), where:
'x' is the input value,
'e' is Euler's number (approximately 2.71828).
This function was first introduced by Belgian mathematician Pierre François Verhulst in the 1830s to model population growth with limiting factors.
It gained popularity in the early 20th century when statisticians like Ronald Fisher began using it in regression analysis.
Specific Sigmoid Functions Used in the Indicator:
sig(val):
The 'sig' function in this indicator is a modified version of the logistic function, clamping a value between 0 and 1 on the sigmoid curve.
siga(val):
The 'siga' function adjusts values between -1 and 1 on the sigmoid curve, offering a centered variation of the sigmoid effect.
sigmoid(val):
The 'sigmoid' function provides a standard implementation of the logistic function, calculating the sigmoid value of the input data.
Adaptive Smoothing Factor:
The ' adaptiveSmoothingFactor(gradient, k)' function computes a dynamic smoothing factor for the filter based on the gradient of the price data and the user-defined sensitivity parameter 'k' .
Gradient:
The gradient represents the rate of change in price, calculated as the absolute difference between the current and previous close prices.
Sensitivity (k):
The 'k' parameter adjusts how quickly the filter reacts to changes in the gradient. Higher values of 'k' lead to a more responsive filter, while lower values result in smoother outputs.
Usage in the Indicator:
The "close" value refers to the closing price of each period in the chart's time frame
The indicator calculates the gradient by measuring the absolute difference between the current "close" price and the previous "close" price.
This gradient represents the strength or magnitude of the price movement within the chosen time frame.
The "close" value plays a pivotal role in determining the dynamic behavior of the "Dynamic Gradient Filter," as it directly influences the smoothing factor.
What Makes This Special:
The "Dynamic Gradient Filter" indicator stands out due to its adaptive nature and responsiveness to changing market conditions.
Dynamic Smoothing Factor:
The indicator's dynamic smoothing factor adjusts in real-time based on the rate of change in price (gradient) and the user-defined sensitivity '(k)' parameter.
This adaptability allows the filter to respond promptly to both minor fluctuations and significant price movements.
Smoothed Price Action:
The final output of the filter is a smoothed representation of the price action, aiding traders in identifying trends and potential reversals.
Customizable Sensitivity:
Traders can adjust the 'Sensitivity' parameter '(k)' to suit their preferred trading style, making the indicator versatile for various strategies.
Visual Clarity:
The plotted "Dynamic Gradient Filter" line on the chart provides a clear visual guide, enhancing the understanding of market dynamics.
Usage:
Traders and analysts can utilize the "Dynamic Gradient Filter" to:
Identify trends and reversals in price movements.
Filter out noise and highlight significant price changes.
Fine-tune trading strategies by adjusting the sensitivity parameter.
Enhance visual analysis with a dynamically adjusting filter line on the chart.
Literature:
en.wikipedia.org
medium.com
en.wikipedia.org
True VolumeThis indicator is designed to provide in-depth analysis of volume data from multiple sources and distinguish highly liquid candles by measuring the density of the volume. By focusing on the density and concentration of volume, rather than just the volume itself, it offers a more nuanced view of the market. This can be particularly beneficial in markets like cryptocurrencies, where understanding the role of market makers versus retail traders is crucial for strategic trading.
This is how it works:
Multiple Asset Integration:
Unlike standard volume indicators, True Volume allows the inclusion of up to four different assets (or the same asset from various exchanges) into its volume calculations. This feature provides a broader and more accurate total volume representation, essential in markets like cryptocurrencies where volume is dispersed across multiple exchanges.
Adjustable Time Anchors:
It offers various time anchor options, allowing traders to analyze volume data over different time periods or a specific amount of lookback candles. This flexibility helps in understanding volume trends over both short and long-term time frames.
Volume Density Analysis:
The core of this indicator is the innovative concept of Volume Density. It's calculated using a sigmoid function that normalizes the volume-to-price movement ratio in a unique way without needing a max cap or having the density column spike off the chart. This method helps in distinguishing between normal volume fluctuations and those that are unusually dense for the given price movement. This distinction is key in identifying potential market maker activities.
The Visuals:
The Volume Density is displayed in a unique way without compromising the original volume bars or cap the density. Infinite density can essentially be represented without having an infinitely large bar or caping out the density data. There's also two different color themes, optional bar color, and an option to flip the density bars up-side down for a different representation. Each of the original volume sources can be displayed separately as well. All colors as customizable as well for your own preference.
Price Volume Trend (PVT):
Included in this indicator is also the Price Volume Trend, which cumulatively measures the density delta, offering insights into the longer-term momentum of the market.
How do I trade it?
This indicator aims to give you insight into 'the other side of the trade', the Market Makers. When you buy, they provide liquidity by selling to you. That drives the Volume Density up.
Consider whether the market maker is currently long or short and might need to cover their position by wicking price back, or "adjust inventory". Especially towards the end of a market session.
Consider dense candles during market gaps or weekends to be market manipulation moves.
The density also goes up when stop losses are hit. If price makes a higher high or lower low, high density could indicate a liquidation event.
[OCT] Moving Average Sigmoid VarianceUses a weighted sigmoid function to gauge the difference between two moving averages. Useful as an additional confirmation source for following trends.
The signal line hovers between -1 and 1, -1 being a negative delta and 1 being a positive delta.
Using a minimum and maximum threshold, a trend can be identified based on how far the signal line crosses the thresholds.
The signal is optionally (enabled by default) adjusted by a "momentum", which is calculated as a moving average of the *change* of a value over time. It's a bit finicky to describe, so please take a look at how it's calculated in code if you wish to use it.
The signal, by default, is green when the value is above the threshold, red when it's below the threshold, and yellow when inside the threshold.
NOTE:
This study is extremely untuned and should not be used as the sole inspiration for taking or exiting a position out of the box.
Please play around with the many available configuration options to fine tune the output to fit your personal strategy.
Configurable options:
- All colors
- All moving average algorithms
- All moving average sources
- All moving average lengths
- Threshold values
- Signal and momentum multipliers
- Whether or not to use the momentum
- Whether or not to plot the momentum
Logistic Difference (ps4)This is an PS4 update to the Logistic Difference Indicator. It uses logistic function (sigmoid), which stabilizes the variance of data. The logistic function resembles the inverse Fisher transform. This version has a repaint/non-repaint switch and a scaling feature.
Inverse Fisher Z-Score Introduction
The inverse fisher transform or hyperbolic tangent function is a type os sigmoid function (sometime called squashing function) , those types of functions can rescale a result in a certain range and are widely used in artificial intelligence. More in depth the fisher transform can make the correlation coefficient of a time series normally distributed, in practice if you apply the fisher transform to the correlation coefficient between a time series and a linear function you will end up with an estimate of the z-score of the time series. The inverse transform however can do the contrary, it can take the z-score and transform it into a rough estimate of the correlation coefficient, if your z-score is not smooth then you will have a non-smooth estimate of the correlation coefficient, that's quite nice no ?
The Indicator
The inverse fisher transform of the z-score will produce results in a range of 1/-1, here however i will rescale in a range of 100/0 because its a standard range for oscillators in technical analysis. Values over 80 indicate an overbought market, under 20 an oversold market. The smooth option in the indicator settings will make the indicator use a linearly weighted moving average as input thus resulting in a smoother result.
The indicator with smooth option.
Conclusion
I presented a new oscillator indicator who use the inverse fisher transform of a z-score. Using the fisher transform and its inverse can give a new shape to your indicator, make sure to control the scale of your indicator before applying the fisher transform, the inverse transform should be applied to values in range of 1/-1 but you can use higher limits (2/-2,3/-3...) , however remember that higher limits will approximate an heavy side step function (square shape) . I hope you will find an use to this indicator.
Thanks for reading !
Logistic DifferenceLogistic Difference Indicator uses logistic function (sigmoid), which stabilizes the variance of data.
Logistic CorrelationLogistic Correlation is a correlation oscillator using a logistic function.
A Logistic Function is a Sigmoid Function who stabilize the variance of data.The logistic function have the same function as the inverse fisher transform but with an advantage over it, the k constant can control the steepness of the curve, lowers k's will preserve the original form of the data while highers one will transform it into a more square shaped form.
10 k
20 k