Profile Any Indicator [Kioseff Trading]Create a visible-range profile for almost any indicator!
Hello!
This script "Profile Any Indicator" allows you to create a visible-range profile for *almost* any indicator hosted on TradingView.
Therefore, the only requirement:
1. Indicator must have a retrievable plot value.
Should your indicator have a retrievable plot value (most indicators do), you can use this script to create a visible-range profile of its values!
Consequently, the profile's always oriented to the left-most or right-most side of your chart - updating as you scroll left or right.
The image above shows me using the indicator to create a profile for MACD. I am largely zoomed out and the profile has adjusted to chart orientation.
Let's zoom in and see what happens!
Voila!
The indicator adjusted to my chart positioning and created a new visible-range profile! No manual adjustments are required (:
Instructions
1. Load the indicator you'd like to profile on the chart.
The image above shows me applying the OBV indicator to the chart. Additionally, the "Profile Any Indicator" script is also loaded on the chart, instructing me to add an indicator to its settings.
2. From the settings for "Profile Any indicator", locate the "Indicator" setting and select the indicator you would like to profile.
The image above shows me selecting the OBV indicator in the settings for "Profile Any Indicator".
Once steps 1 and 2 are complete you'll have a visible-range profile for the selected indicator on your chart!
The image above shows the completion of the process.
3. Merge the indicator pane or select to plot the selected indicator in the current pane.
From here, you can select to plot the value of the selected indicator in the current pane or merge the selected indicator's pane (which must stay on the chart) with the pane designated to the "Profile Any Indicator" script.
The image above shows the two panes merged.
The image above shows the two panes separate. Alternatively, in the settings for "Profile Any Indicator", I selected to plot OBV in its pane.
You can select to populate the visible-range profile on the right of the chart!
Additionally, you can modify the POC line, value area %, and, essentially, any parameter you'd find for a volume-profile-like indicator!
Thanks for checking this out (:
Statistics
Premium Linear Regression - The Quant ScienceThis script calculates the average deviation of the source data from the linear regression. When used with the indicator, it can plot the data line and display various pieces of information, including the maximum average dispersion around the linear regression.
The code includes various user configurations, allowing for the specification of the start and end dates of the period for which to calculate linear regression, the length of the period to use for the calculation, and the data source to use.
The indicator is designed for multi-timeframe use and to facilitate analysis for traders who use regression models in their analysis. It displays a green linear regression line when the price is above the line and a red line when the price is below. The indicator also highlights areas of dispersion around the regression using circles, with bullish areas shown in green and bearish areas shown in red.
Quantitative Price Forecasting - The Quant ScienceThis script is a quantitative price forecasting indicator that forecasts price changes for a given asset.
The model aims to forecast future prices by analyzing past data within a selected time period. Mathematical probability is used to calculate whether starting from time X can lead to reaching prices Y1 and Y2. In this context, X represents the current selected time period, Y1 represents the selected percentage decrease, and Y2 represents the selected percentage increase. The probabilities are estimated using the simple average.
The simple average is displayed on the chart, showing in red the periods where the price is below the average and in green the periods where the price is above the average.
This powerful tool not only provides forecasts of future prices but also calculates the distribution of variations around the average. It then takes this information and creates an estimate of the average price variation around the simple average.
Using a mean-reverting logic, buying and selling opportunities are highlighted.
We recommend turning off the display of bars on your chart for a better experience when using this indicator.
Unlock the full potential of your trading strategy with our powerful indicator. By analyzing past price data, it provides accurate forecasts and calculates the probability of reaching specific price targets. Its mean-reverting logic highlights buying and selling opportunities, while the simple moving average displayed on the chart shows periods where the price is above or below the average. Additionally, it estimates the average variation of price around the simple average, giving you valuable insights into price movements. Don't miss out on this valuable tool that can take your trading to the next level
Intrabar Analyzer [Kioseff Trading]Hello!
This indicator (Intrabar Analyzer) presents intrabar data in various derivative forms.
On-Chart Features
Traditional price data down to 1 min.
Heikin-Ashi price data down to 1 min.
Kagi price data down to 1 min.
Point & Figure price data down to 1 min.
Renko price data down to 1 min.
Linebreak price data down to 1 min.
LinReg channel
SMA
EMA
ALMA
Echomorphic Average (A @kaigouthro special!)
HMA
RMA
WMA
VWMA
VWAP
SWMA
SAR
Supertrend
On-Chart Features
Price x Volume graph
Intrabar technical rating
Positive volume index
Negative volume index
Price volume trend
RSI
%k
ROC
MFI
MFC
OBV
CCI
BBW
CMO
COG
KCW
MOM
RANGE
%r
Let's look at the objects populated by the indicator!
The image above shows what data correlates to the populated graphs!
Let's dial in on the price x volume graph.
The image above provides an example/explanation of the price x volume graph. All data is sourced from a lower timeframe (configurable - default = 1 minute).
Colors are configurable; the plot characters are configurable.
The numbers above show an alternative view of the price x volume graph!
Price graph
The price graph can populate 6 variations of price data: traditional, heikin-ashi, renko, point & figure, line break, and kagi.
The subsequent images will show all available forms of price data, in addition to a randomly selected, on-chart technical indicator!
Kagi + LinReg
Traditional + EMA
Renko + SAR
Point & Figure + ALMA
Heikin-Ashi + Supertrend
Line Break + VWAP
You can display up to three indicators concomitantly - all calculated using intrabar data!
Lastly, the indicator displays the TradingView calculated technical rating for the intrabar.
The technical ratings are multiplied by x100 and oriented left & right of the price box. Left values are negative; right values are positive. The "0" value is not shown; therefore, if the technical rating isn't highlighted then the rating is "0".
The image above shows the technical rating system in action (:
That's it!
This was a fun project and I'm certainly willing to add more - let me know if there's anything you'd like included.
Additionally, a future feature involves compatibility with any custom indicator! Stay tuned; thank you for checking this out (:
Thank you to @kaigouthro, TradingView and @PineCoders for providing some cool libraries to play with!
Weekday Change & Volume Average TableHaving a reference point for comparing with current data has always been an important task in market analysis. This script tried to give a better understanding based on weekdays.
This script shows that in the current ticker, what is the average movement of the price (High-Low) and volume for each weekday. Depending on the market and the exchange it should be different.
The Interesting point is that, for example in BINANCE:BTCUSDT , on Saturday and Sunday, volume is about 30% less and the price movement is about 20% less.
The script can be used on any timeframe and any symbol, just remember that the data shown is based on the candles on the chart, so it is different also based on your tradingview's account since Historical bars available for Basic is 5K, Pro & Pro+ is 10K and Premium is 20K; And in lower timeframes it is calculating more recent data.
BTC Performance Table / BTC Seasonality Visualization
This script visualizes Bitcoins "seasonality", in form of a colored table (based on the idea from "BigBangTheory")
The history table shows you which months do statistically perform better/worse in comparison to other months.
How to use this script:
Choose ticker "BLX" ("BraveNewCoin Liquid Index for Bitcoin").
Set the charts time frame to weekly or daily. Tables position on the screen and its colors are configurable.
Table explanation:
Cells show whether a gain or a loss occured from month to month, since BTC came out in 2010.
The price difference, between monthly open and monthly close, determines the cell color (negative -> red, positive -> green).
The year column shows total gain (green) or loss (red) for that particular year.
Each value is presented as a rounded percentage number.
How this script works:
The script calculates the price difference between each monthly and yearly open and close, storing those numbers inside arrays.
Then it populates the table, by using those numbers and doing the cell coloring (there will be a yellow cell, in case no change should occur).
German Short-Description
Prozentuale Übersicht in Tabellenform, der monatlichen, sowie jährlichen, Performance des Bitcoin (basierend auf der Idee von "BigBangTheory").
Hierdurch wird die "Saisonalität" des Bitcoin sichtbar. D.h. welche Monate des Jahres, im Vergleich zu anderen Monaten, statistisch gesehen öfter positiv/negativ schließen.
Zwecks vollständiger Darstellung muss der Ticker "BLX" ("BraveNewCoin Liquid Index for Bitcoin") im weekly oder daily time frame aktiv sein.
Central Bank Dark Energy TracerCentral Bank Dark Energy Tracer (CBDE Tracer)
What makes The Universe grow at an accelerating pace?
Dark Energy.
What makes The Economy grow at an accelerating pace?
Debt.
Debt is the Dark Energy of The Economy.
The CBDE Tracer is a tool that tracks currency assets in US dollars that can be scaled to fit other assets on TradingView.
The example provided is QQQ with scale factors and offsets applied that best curve fit to the most recent price action.
The white line is non-US assets from the following central banks:
-JPY (Japan)
-CNY (China)
-UK (British Pound)
-SNB (Swiss National Bank)
-ECB (European Central Bank )
The lime green line is for US Federal Reserve data including a midpoint of WRESBAL and the fed liquidity calculation (WALCL - WTREGEN) and then subtracting RRPONTSYD
The purple line is the average of the two, US assets, and non-US.
The settings can be configured so that only the average is showing, which should the closest aggregate of all liquidity data.
TICK - Custom Tickers [Pt]Traditionally, the TICK index is a technical analysis indicator that shows the difference in the number of stocks that are trading on an uptick vs a downtick in a particular period of time. This indicator allows user to choose up to 40 tickers to calculate TICK.
By default, it uses the SPY Top 40 stocks, but can be changed to any tickers.
There are options to show:
- Top 7 , ie. can be used for just showing TICK for FAANGMT => $FB + $AMZN + $AAPL + $NFLX + $GOOG + $MSFT + $TSLA
- Top 10
- Top 20
- Top 30
- Top 40
Data can be displayed in candle bars, line, or both.
Enjoy~
RSI Impact Heat Map [Trendoscope]Here is a simple tool to measure and display outcome of certain RSI event over heat map.
🎲 Process
🎯Event
Event can be either Crossover or Crossunder of RSI on certain value.
🎯Measuring Impact
Impact of the event after N number of bars is measured in terms of highest and lowest displacement from the last close price. Impact can be collected as either number of times of ATR or percentage of price. Impact for each trigger is recorded separately and stored in array of custom type.
🎯Plotting Heat Map
Heat map is displayed using pine tables. Users can select heat map size - which can vary from 10 to 90. Selecting optimal size is important in order to get right interpretation of data. Having higher number of cells can give more granular data. But, chart may not fit into the window. Having lower size means, stats are combined together to get less granular data which may not give right picture of the results. Default value for size is 50 - meaning data is displayed in 51X51 cells.
Range of the heat map is adjusted automatically based on min and max value of the displacement. In order to filter out or merge extreme values, range is calculated based on certain percentile of the values. This will avoid displaying lots of empty cells which can obscure the actual impact.
🎲 Settings
Settings allow users to define their event, impact duration and reference, and few display related properties. The description of these parameters are as below:
🎲 Use Cases
In this script, we have taken RSI as an example to measure impact. But, we can do this for any event. This can be price crossing over/under upper/lower bollinger bands, moving average crossovers or even complex entry or exit conditions. Overall, we can use this to plot and evaluate our trade criteria.
🎲 Interpretation
Q1 - If more coloured dots appear on the top right corner of the table, then the event is considered to trigger high volatility and high risk environment.
Q2 - If more coloured dots appear on the top left corner, then the events are considered to trigger bearish environment.
Q3 - If more coloured dots appear on the bottom left corner of the chart, then the events are considered insignificant as they neither generate higher displacement in positive or negative side. You can further alter outlier percentage to reduce the bracket and hence have higher distribution move towards
Q4 - If more coloured dots appear on the bottom right corner, then the events are considered to trigger bullish environment.
Will also look forward to implement this as library so that any conditions or events can be plugged into it.
Historical Federal Fund Futures CurveUse this indicator to plot the federal funds futures implied rates term structure against historical curves
Based upon the work of @BarefootJoey, @longfiat, @OpptionsOnly
BTC / DXY, BTC / US10Y
The combination of the DXY and US02Y can be used to gauge market sentiment and assess the state of the global economy.
When the DXY is rising, it indicates that the U.S. dollar is strengthening relative to other currencies, which can lead to increased risk aversion among investors as the U.S. dollar is often seen as a safe-haven currency.
When the US02Y is rising, it suggests that market expectations for future inflation and interest rate increases are increasing, which can lead to a decrease in the value of riskier assets such as stocks.
In general, the combination of the DXY and US02Y can provide important information on the direction of global market trends and the state of the economy, and as such, they are important indicators to consider when making investment decisions.
RISK MANAGEMENTHi dear Traders,
Here I would present you my 'Risk Management' tool which is based on your buy orders, trading fees and your desired benefit.
Easily, fulfill the price and volume of each entries. Add to this, you can prepare the info about your next proposed entries, just let them not check at first and by meeting the prices then active the check-box beside it.
Two line will be presented on your candle-plot, one of the indicate the place that without any lose/win you can exit and also the desired exit position by considering user defined benefit.
Use it for free but please do not forget to boost the script.
Best regards and happy trading.
Shakib
Global LiquidityPlots the sum of the balance sheets of the world's major central banks - FED, ECB, BoE, PBoC, BOJ, India and Switzerland - in a currency of your choice. Defaults to USD.
Also shows FED net liquidity (balance sheet - tga - rrp) for comparison. Uses a configurable multiplier to make the two lines viewable on the same price scale.
Balance of Force Day of the Week (BOFDW)The script is a custom technical indicator for TradingView that is based on an analysis of the price movements of a financial instrument over the course of a week. The indicator uses a variety of inputs, including the open and close prices for each day of the week, to determine the "BOF" (BOF) for each day.
The BOF is calculated based on the relative magnitude of bullish and bearish price movements and is then used to determine the average BOF over a moving window of data points. This average BOF is displayed on the chart as an overlay, providing a measure of the average bullishness or bearishness of the financial instrument over the course of a week.
The indicator also allows users to specify the location of the overlay on the chart and to customize the appearance of the overlay with options for text and box colors. The script provides a number of built-in options for chart position, including the top-left, top-middle, top-right, middle-left, middle-center, middle-right, bottom-left, bottom-middle, and bottom-right corners of the chart.
Overall, this custom technical indicator is a useful tool for traders and investors who are looking to gain a deeper understanding of the price trends of a financial instrument over the course of a week. By providing a clear and concise measure of the average POF over time, the indicator can help users identify key patterns in the market and make more informed trading decisions.
VIX OscillatorThis is my VIX Oscillator indicator.
About it:
This indicator takes the Z-Score of the VIX and of the current ticker you are on and presents them in the format of an oscillator.
Key parts of the indicator:
A diagram of the key elements of the indicator are displayed above.
Purple Line: Represents the Z-Score of the current Ticker.
Blue Line: Represents the Z-Score of the VIX
Green fill line: Represents bullish divergence
Red fill line: Represents bearish divergence
How to use it:
Characteristics for long entries:
- Look for recent bullish divergence (green fill line)
- Look for the ticker line (purple line) to be holding above 0 (neutrality)
- look for a bullish cross (purple line (ticker) crossing over blue line (VIX))
Characteristics for short entries:
- Look for recent Bearish divergence
- Look for the VIX line (blue line) to be holding above 0 and the Ticker
- Look for the ticker line to be holding below 0
- Look for a bearish cross (blue crossing above purple)
Some principles:
The bands represent oversold, overbought and neutral.
0 is absolute neutrality. No bias here.
Anything towards + 2.5 is considered normal, moving towards overbought (2.5 or higher).
Anything towards -2.5 is considered normal, moving towards oversold (-2.5 or lower).
+2.5 or higher is overbought.
-2.5 or lower is oversold.
As always, I have prepared a quick tutorial video for your reference of this indicator:
Please let me know your questions, comments or suggestions about this indicator below.
Thank you for checking it out!
Delta Ladder [Kioseff Trading]Hello!
This script presents volume delta data in various forms!
Features
Classic mode: Volume delta boxes oriented to the right of the bar (sell closer / buy further)
On Bar mode: Volume delta boxes oriented on the bar (sell left / buy right)
Pure Ladder mode: Pure volume delta ladder
PoC highlighting
Color-coordinated delta boxes. Marginal volume differences are substantially shaded while large volume differences are lightly shaded.
Volume delta boxes can be merged and delta values removed to generate a color-only canvas reflecting vol. delta differences in price blocks.
Price bars can be split up to 497 times - allowing for greater precision.
Total volume delta for the bar and timestamp included
The image above shows Classic mode - delta blocks are oriented left/right contingent on positive/negative values!
The image above shows the same price sequence; however, delta blocks are superimposed on the price bar. Left-side blocks reflect negative delta while right-side blocks reflect positive delta! To apply this display method - select "On Bar" for the "Data Display Method" setting!
The image above shows "Pure Ladder" mode. Delta blocks remain color-coordinated; however, all delta blocks retain the same x-axis as the price bar they were calculated for!
Additionally, you can select to remove the delta values and merge the delta boxes to generate a color-based canvas indicative of volume delta at traded price levels!
The image above shows the same price sequence; however, the "Volume Assumption" setting is activated.
When active, the indicator assumes a 60/ 40 split when a level is traded at and only one metric - "buy volume" or "sell volume" is recorded. This means there shouldn't be any levels recorded where "buy volume" is greater than 0 and "sell volume" equals 0 and vice versa. While this assumption was performed arbitrarily, it may help better replicate volume delta and OI delta calculations seen on other charting platforms.
This option is configurable; you can select to have the script not assume a 60/ 40 split and instead record volume "as is" at the corresponding price level!
I plan to roll out additional features for the indicator - particularly tick-based price blocks! Stay tuned (:
Thank you!
Machine Learning: Lorentzian Classification█ OVERVIEW
A Lorentzian Distance Classifier (LDC) is a Machine Learning classification algorithm capable of categorizing historical data from a multi-dimensional feature space. This indicator demonstrates how Lorentzian Classification can also be used to predict the direction of future price movements when used as the distance metric for a novel implementation of an Approximate Nearest Neighbors (ANN) algorithm.
█ BACKGROUND
In physics, Lorentzian space is perhaps best known for its role in describing the curvature of space-time in Einstein's theory of General Relativity (2). Interestingly, however, this abstract concept from theoretical physics also has tangible real-world applications in trading.
Recently, it was hypothesized that Lorentzian space was also well-suited for analyzing time-series data (4), (5). This hypothesis has been supported by several empirical studies that demonstrate that Lorentzian distance is more robust to outliers and noise than the more commonly used Euclidean distance (1), (3), (6). Furthermore, Lorentzian distance was also shown to outperform dozens of other highly regarded distance metrics, including Manhattan distance, Bhattacharyya similarity, and Cosine similarity (1), (3). Outside of Dynamic Time Warping based approaches, which are unfortunately too computationally intensive for PineScript at this time, the Lorentzian Distance metric consistently scores the highest mean accuracy over a wide variety of time series data sets (1).
Euclidean distance is commonly used as the default distance metric for NN-based search algorithms, but it may not always be the best choice when dealing with financial market data. This is because financial market data can be significantly impacted by proximity to major world events such as FOMC Meetings and Black Swan events. This event-based distortion of market data can be framed as similar to the gravitational warping caused by a massive object on the space-time continuum. For financial markets, the analogous continuum that experiences warping can be referred to as "price-time".
Below is a side-by-side comparison of how neighborhoods of similar historical points appear in three-dimensional Euclidean Space and Lorentzian Space:
This figure demonstrates how Lorentzian space can better accommodate the warping of price-time since the Lorentzian distance function compresses the Euclidean neighborhood in such a way that the new neighborhood distribution in Lorentzian space tends to cluster around each of the major feature axes in addition to the origin itself. This means that, even though some nearest neighbors will be the same regardless of the distance metric used, Lorentzian space will also allow for the consideration of historical points that would otherwise never be considered with a Euclidean distance metric.
Intuitively, the advantage inherent in the Lorentzian distance metric makes sense. For example, it is logical that the price action that occurs in the hours after Chairman Powell finishes delivering a speech would resemble at least some of the previous times when he finished delivering a speech. This may be true regardless of other factors, such as whether or not the market was overbought or oversold at the time or if the macro conditions were more bullish or bearish overall. These historical reference points are extremely valuable for predictive models, yet the Euclidean distance metric would miss these neighbors entirely, often in favor of irrelevant data points from the day before the event. By using Lorentzian distance as a metric, the ML model is instead able to consider the warping of price-time caused by the event and, ultimately, transcend the temporal bias imposed on it by the time series.
For more information on the implementation details of the Approximate Nearest Neighbors (ANN) algorithm used in this indicator, please refer to the detailed comments in the source code.
█ HOW TO USE
Below is an explanatory breakdown of the different parts of this indicator as it appears in the interface:
Below is an explanation of the different settings for this indicator:
General Settings:
Source - This has a default value of "hlc3" and is used to control the input data source.
Neighbors Count - This has a default value of 8, a minimum value of 1, a maximum value of 100, and a step of 1. It is used to control the number of neighbors to consider.
Max Bars Back - This has a default value of 2000.
Feature Count - This has a default value of 5, a minimum value of 2, and a maximum value of 5. It controls the number of features to use for ML predictions.
Color Compression - This has a default value of 1, a minimum value of 1, and a maximum value of 10. It is used to control the compression factor for adjusting the intensity of the color scale.
Show Exits - This has a default value of false. It controls whether to show the exit threshold on the chart.
Use Dynamic Exits - This has a default value of false. It is used to control whether to attempt to let profits ride by dynamically adjusting the exit threshold based on kernel regression.
Feature Engineering Settings:
Note: The Feature Engineering section is for fine-tuning the features used for ML predictions. The default values are optimized for the 4H to 12H timeframes for most charts, but they should also work reasonably well for other timeframes. By default, the model can support features that accept two parameters (Parameter A and Parameter B, respectively). Even though there are only 4 features provided by default, the same feature with different settings counts as two separate features. If the feature only accepts one parameter, then the second parameter will default to EMA-based smoothing with a default value of 1. These features represent the most effective combination I have encountered in my testing, but additional features may be added as additional options in the future.
Feature 1 - This has a default value of "RSI" and options are: "RSI", "WT", "CCI", "ADX".
Feature 2 - This has a default value of "WT" and options are: "RSI", "WT", "CCI", "ADX".
Feature 3 - This has a default value of "CCI" and options are: "RSI", "WT", "CCI", "ADX".
Feature 4 - This has a default value of "ADX" and options are: "RSI", "WT", "CCI", "ADX".
Feature 5 - This has a default value of "RSI" and options are: "RSI", "WT", "CCI", "ADX".
Filters Settings:
Use Volatility Filter - This has a default value of true. It is used to control whether to use the volatility filter.
Use Regime Filter - This has a default value of true. It is used to control whether to use the trend detection filter.
Use ADX Filter - This has a default value of false. It is used to control whether to use the ADX filter.
Regime Threshold - This has a default value of -0.1, a minimum value of -10, a maximum value of 10, and a step of 0.1. It is used to control the Regime Detection filter for detecting Trending/Ranging markets.
ADX Threshold - This has a default value of 20, a minimum value of 0, a maximum value of 100, and a step of 1. It is used to control the threshold for detecting Trending/Ranging markets.
Kernel Regression Settings:
Trade with Kernel - This has a default value of true. It is used to control whether to trade with the kernel.
Show Kernel Estimate - This has a default value of true. It is used to control whether to show the kernel estimate.
Lookback Window - This has a default value of 8 and a minimum value of 3. It is used to control the number of bars used for the estimation. Recommended range: 3-50
Relative Weighting - This has a default value of 8 and a step size of 0.25. It is used to control the relative weighting of time frames. Recommended range: 0.25-25
Start Regression at Bar - This has a default value of 25. It is used to control the bar index on which to start regression. Recommended range: 0-25
Display Settings:
Show Bar Colors - This has a default value of true. It is used to control whether to show the bar colors.
Show Bar Prediction Values - This has a default value of true. It controls whether to show the ML model's evaluation of each bar as an integer.
Use ATR Offset - This has a default value of false. It controls whether to use the ATR offset instead of the bar prediction offset.
Bar Prediction Offset - This has a default value of 0 and a minimum value of 0. It is used to control the offset of the bar predictions as a percentage from the bar high or close.
Backtesting Settings:
Show Backtest Results - This has a default value of true. It is used to control whether to display the win rate of the given configuration.
█ WORKS CITED
(1) R. Giusti and G. E. A. P. A. Batista, "An Empirical Comparison of Dissimilarity Measures for Time Series Classification," 2013 Brazilian Conference on Intelligent Systems, Oct. 2013, DOI: 10.1109/bracis.2013.22.
(2) Y. Kerimbekov, H. Ş. Bilge, and H. H. Uğurlu, "The use of Lorentzian distance metric in classification problems," Pattern Recognition Letters, vol. 84, 170–176, Dec. 2016, DOI: 10.1016/j.patrec.2016.09.006.
(3) A. Bagnall, A. Bostrom, J. Large, and J. Lines, "The Great Time Series Classification Bake Off: An Experimental Evaluation of Recently Proposed Algorithms." ResearchGate, Feb. 04, 2016.
(4) H. Ş. Bilge, Yerzhan Kerimbekov, and Hasan Hüseyin Uğurlu, "A new classification method by using Lorentzian distance metric," ResearchGate, Sep. 02, 2015.
(5) Y. Kerimbekov and H. Şakir Bilge, "Lorentzian Distance Classifier for Multiple Features," Proceedings of the 6th International Conference on Pattern Recognition Applications and Methods, 2017, DOI: 10.5220/0006197004930501.
(6) V. Surya Prasath et al., "Effects of Distance Measure Choice on KNN Classifier Performance - A Review." .
█ ACKNOWLEDGEMENTS
@veryfid - For many invaluable insights, discussions, and advice that helped to shape this project.
@capissimo - For open sourcing his interesting ideas regarding various KNN implementations in PineScript, several of which helped inspire my original undertaking of this project.
@RikkiTavi - For many invaluable physics-related conversations and for his helping me develop a mechanism for visualizing various distance algorithms in 3D using JavaScript
@jlaurel - For invaluable literature recommendations that helped me to understand the underlying subject matter of this project.
@annutara - For help in beta-testing this indicator and for sharing many helpful ideas and insights early on in its development.
@jasontaylor7 - For helping to beta-test this indicator and for many helpful conversations that helped to shape my backtesting workflow
@meddymarkusvanhala - For helping to beta-test this indicator
@dlbnext - For incredibly detailed backtesting testing of this indicator and for sharing numerous ideas on how the user experience could be improved.
USD Liquidity IndexThis USD Liquidity Index composed of 2 parts, total assets and major liabilities of the Federal Reserve .
There is a certain positive correlation between USD liquidity and risk asset price changes in history.
Suggested that USD Liquidity is mostly determined by the Federal Reserve balance (without leveraged), this index deducts three major liabilities from the total assets (in green color line) of the Federal Reserve . They are the currency in circulation (WCURCIR) in gold color, the Treasury General Account (WTREGEN) in blue color, the Reverse Repo (RRPONTSYD) in red color.
The grey line is the calculation result of the USD Liquidity Index. With it goes up, liquidity increases, vice versa.
occ3aka weighted fair price
The ultimate price source for all your stuff, unless you go completely nuts.
The ultimate way to build line charts & do pattern trading, unless you go completely nuts.
Why occ3?
You need a one-point estimate for every bar, a typical price of every bar aye? But then you see that every bar has a different distribution of prices. You can drop a stat test on every bar and pick median, mean, or whatever. But that's still prone to error (imagine borderline cases).
Instead, you can transform the task into a geometric one and say, "I wanna find the center of mass of all dem ticks within a particular interval (a day, a week, a century)". But lol ofc you won't do it, so lets's estimate it:
1) a straight line from Open to Close more/less estimates a regression line if you woulda dropped regression on all the ticks within a given interval;
2) centroid always lies on regression line, so it's always in between the endpoints of regression line. So that's why (open + close) /2;
3) Then, you remember that sequence matters, + generally the volume is higher near the close, so...;
4) Voila, (open + close + close) / 3
Why "fair" price?
Take a daily bar:
1) High & low were the best prices to sell & buy;
2) Opening & closing auctions had acceptable prices, in exchange for the the biggest potential to transact serious volume;
3) "Fair" price, logically, is somewhere in between the acceptable prices;
4) Market is fractal => the same principles propagate everywhere;
4) No, POCs and VPOCs don't make much sense as fair prices.
Nothing else to say, really advise to use it as a line chart if you trade price patterns.
Forex Strength IndicatorThis indicator will display the strength of 8 currencies, EUR, AUD, NZD, JPY, USD, GBP, CHF, and CAD. Each line will represent each currency. Alongside that, Fibonacci levels will be plotted based on a standard deviation from linear regression, with customizable lengths.
For more steady Fibonacci levels, use higher lengths for both Standard Deviations and Linear Regression. All currency lines come from moving averages with options like EMA, SMA, WMA, RMA, HMA, SWMA, and Linear Regression.
When lines of the active pair are far from each other, it means higher divergence in those currency strengths among the other pairs. The closer the lines are, the lower the divergence.
You can use the Fibonacci levels as points for the reversal or end of the current trend. When the lines cross can be used as a parameter for a more accurate signal of the next movement.
All 28 pairs are loaded from the same time frame and will use the same moving average for all of them
Alerts from the line crossing are available.
Chatterjee CorrelationThis is my first attempt on implementing a statistical method. This problem was given to me by @lejmer (who also helped me later on building more efficient code to achieve this) when we were debating on the need for higher resource allocation to run scripts so it can run longer and faster. The major problem faced by those who want to implement statistics based methods is that they run out of processing time or need to limit the data samples. My point was that such things need be implemented with an algorithm which suits pine instead of trying to port a python code directly. And yes, I am able to demonstrate that by using this implementation of Chatterjee Correlation.
🎲 What is Chatterjee Correlation?
The Chatterjee rank Correlation Coefficient (CCC) is a method developed by Sourav Chatterjee which can be used to study non linear correlation between two series.
Full documentation on the method can be found here:
arxiv.org
In short, the formula which we are implementing here is:
Algorithm can be simplified as follows:
1. Get the ranks of X
2. Get the ranks of Y
3. Sort ranks of Y in the order of X (Lets call this SortedYIndices)
4. Calculate the sum of adjacent Y ranks in SortedYIndices (Lets call it as SumOfAdjacentSortedIndices)
5. And finally the correlation coefficient can be calculated by using simple formula
CCC = 1 - (3*SumOfAdjacentSortedIndices)/(n^2 - 1)
🎲 Looks simple? What is the catch?
Mistake many people do here is that they think in Python/Java/C etc while coding in Pine. This makes code less efficient if it involves arrays and loops. And the simple code may look something like this.
var xArray = array.new()
var yArray = array.new()
array.push(xArray, x)
array.push(yArray, y)
sortX = array.sort_indices(xArray)
sortY = array.sort_indices(yArray)
SumOfAdjacentSortedIndices = 0.0
index = array.get(xSortIndices, 0)
for i=1 to n > 1? n -1 : na
indexNext = array.get(sortX, i)
SumOfAdjacentSortedIndices += math.abs(array.get(sortY, indexNext)-array.get(sortY, index))
index := indexNext
correlation := 1 - 3*SumOfAdjacentSortedIndices/(math.pow(n,2)-1)
But, problem here is the number of loops run. Remember pine executes the code on every bar. There are loops run in array.sort_indices and another loop we are running to calculate SumOfAdjacentSortedIndices. Due to this, chances of program throwing runtime errors due to script running for too long are pretty high. This limits greatly the number of samples against which we can run the study. The options to overcome are
Limit the sample size and calculate only between certain bars - this is not ideal as smaller sets are more likely to yield false or inconsistent results.
Start thinking in pine instead of python and code in such a way that it is optimised for pine. - This is exactly what we have done in the published code.
🎲 How to think in Pine?
In order to think in pine, you should try to eliminate the loops as much as possible. Specially on the data which is continuously growing.
My first thought was that sorting takes lots of time and need to find a better way to sort series - specially when it is a growing data set. Hence, I came up with this library which implements Binary Insertion Sort.
Replacing array.sort_indices with binary insertion sort will greatly reduce the number of loops run on each bar. In binary insertion sort, the array will remain sorted and any item we add, it will keep adding it in the existing sort order so that there is no need to run separate sort. This allows us to work with bigger data sets and can utilise full 20,000 bars for calculation instead of few 100s.
However, last loop where we calculate SumOfAdjacentSortedIndices is not replaceable easily. Hence, we only limit these iterations to certain bars (Even though we use complete sample size). Plots are made for only those bars where the results need to be printed.
🎲 Implementation
Current implementation is limited to few combinations of x and fixed y. But, will be converting this into library soon - which means, programmers can plug any x and y and get the correlation.
Our X here can be
Average volume
ATR
And our Y is distance of price from moving average - which identifies trend.
Thus, the indicator here helps to understand the correlation coefficient between volume and trend OR volatility and trend for given ticker and timeframe. Value closer to 1 means highly correlated and value closer to 0 means least correlated. Please note that this method will not tell how these values are correlated. That is, we will not be able to know if higher volume leads to higher trend or lower trend. But, we can say whether volume impacts trend or not.
Please note that values can differ by great extent for different timeframes. For example, if you look at 1D timeframe, you may get higher value of correlation coefficient whereas lower value for 1m timeframe. This means, volume to trend correlation is higher in 1D timeframe and lower in lower timeframes.
Aggregated Volume Profile Spot & Futures ⚉ OVERVIEW ⚉
Aggregate Volume Profile - Shows the Volume Profile from 9 exchanges. Works on almost all CRYPTO Tickers!
You can enter your own desired exchanges, on/off any others, as well as select the sources of SPOT, FUTURES and others.
The script also includes several input parameters that allow the user to control which exchanges and currencies are included in the aggregated data.
The user can also choose how volume is displayed (in assets, U.S. dollars or euros) and how it is calculated (sum, average, median, or dispersion).
WARNING Indicator is for CRYPTO ONLY.
______________________
⚉ SETTINGS ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Data Type — Choose Single or Aggregated data.
• Single — Show only current Volume.
• Aggregated — Show Aggregated Volume.
Volume By — You can also select how the volume is displayed.
• COIN — Volume in Actives.
• USD — Volume in United Stated Dollar.
• EUR — Volume in European Union.
• RUB — Volume in Russian Ruble.
Calculate By — Choose how Aggregated Volume it is calculated.
• SUM — This displays the total volume from all sources.
• AVG — This displays the average price of the volume from all sources.
• MEDIAN — This displays the median volume from all sources.
• VARIANCE — This displays the variance of the volume from all sources.
• Delta Type — Select the Volume Profile type.
• Bullish — Shows the volume of buyers.
• Bearish — Shows the volume of sellers.
• Both — Shows the total volume of buyers and sellers.
Additional features
The remaining functions are responsible for the visual part of the Volume Profile and are intuitive and I recommend that you familiarize yourself with them simply by using them.
________________
⚉ NOTES ⚉
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
If you have any ideas what to add to my work to add more sources or make calculations cooler, suggest in DM .
Also I recommend exploring and trying out my similar work.