chi2InvLibrary "chi2Inv"
chi2Inv(p, n)
Returns the inverse cumulative distribution function (icdf) of the chi-square distribution with degrees of freedom nu, evaluated at the probability values in p. Goldstein approximation
Parameters:
p : float, probability
n : float, degress of freedom source.
Returns: float.
Statistics
Standard Deviation Histogram (SDH)This script tells you what standard deviation the price is from the mean. Due to the limitations of the calculations this study only works for stocks. Further limitations include and inability to calculate past 10 deviation. I have added a smoothing feature and the ability to change the colors. Dont be afraid to change the style to line instead of a histogram. Enjoy!
Candlestick Pattern Criteria and Analysis Indicator█ OVERVIEW
Define, then locate the presence of a candle that fits a specific criteria. Run a basic calculation on what happens after such a candle occurs.
Here, I’m not giving you an edge, but I’m giving you a clear way to find one.
IMPORTANT NOTE: PLEASE READ:
THE INDICATOR WILL ALWAYS INITIALLY LOAD WITH A RUNTIME ERROR. WHEN INITIALLY LOADED THERE NO CRITERIA SELECTED.
If you do not select a criteria or run a search for a criteria that doesn’t exist, you will get a runtime error. If you want to force the chart to load anyway, enable the debug panel at the bottom of the settings menu.
Who this is for:
- People who want to engage in TradingView for tedious and challenging data analysis related to candlestick measurement and occurrence rate and signal bar relationships with subsequent bars. People who don’t know but want to figure out what a strong bullish bar or a strong bearish bar is.
Who this is not for:
- People who want to be told by an indicator what is good or bad or buy or sell. Also, not for people that don’t have any clear idea on what they think is a strong bullish bar or a strong bearish bar and aren’t willing to put in the work.
Recommendation: Use on the candle resolution that accurately reflects your typical holding period. If you typically hold a trade for 3 weeks, use 3W candles. If you hold a trade for 3 minutes, use 3m candles.
Tldr; Read the tool tips and everything above this line. Let me know any issues that arise or questions you have.
█ CONCEPTS
Many trading styles indicate that a certain candle construct implies a bearish or bullish future for price. That said, it is also common to add to that idea that the context matters. Of course, this is how you end up with all manner of candlestick patterns accounting for thousands of pages of literature. No matter the context though, we can distill a discretionary trader's decision to take a trade based on one very basic premise: “A trader decides to take a trade on the basis of the rightmost candle's construction and what he/she believes that candle construct implies about the future price.” This indicator vets that trader’s theory in the most basic way possible. It finds the instances of any candle construction and takes a look at what happens on the next bar. This current bar is our “Signal Bar.”
█ GUIDE
I said that we vet the theory in the most basic way possible. But, in truth, this indicator is very complex as a result of there being thousands of ways to define a ‘strong’ candle. And you get to define things on a very granular level with this indicator.
Features:
1. Candle Highlighting
When the user’s criteria is met, the candle is highlighted on the chart.
The following candle is highlighted based on whether it breaks out, breaks down, or is an inside bar.
2. User-Defined Criteria
Criteria that you define include:
Candle Type: Bull bars, Bear bars, or both
Candle Attributes
Average Size based on Standard Deviation or Average of all potential bars in price history
Search within a specific price range
Search within a specific time range
Clarify time range using defined sessions and with or without weekends
3. Strike Lines on Candle
Often you want to know how price reacts when it gets back to a certain candle. Also it might be true that candle types cluster in a price region. This can be identified visually by adding lines that extend right on candles that fit the criteria.
4. User-Defined Context
Labeled “Alternative Criteria,” this facet of the script allows the user to take the context provided from another indicator and import it into the indicator to use as a overriding criteria. To account for the fact that the external indicator must be imported as a float value, true (criteria of external indicator is met) must be imported as 1 and false (criteria of external indicator is not met) as 0. Basically a binary Boolean. This can be used to create context, such as in the case of a traditional fractal, or can be used to pair with other signals.
If you know how to code in Pinescript, you can save a copy and simply add your own code to the section indicated in the code and set your bull and bear variables accordingly and the code should compile just fine with no further editing needed.
Included with the script to maximize out-of-the-box functionality, there is preloaded as alternative criteria a code snippet. The criteria is met on the bull side when the current candle close breaks out above the prior candle high. The bear criteria is met when the close breaks below the prior candle. When Alternate Criteria is run by itself, this is the only criteria set and bars are highlighted when it is true. You can qualify these candles by adding additional attributes that you think would fit well.
Using Alternative Criteria, you are essentially setting a filter for the rest of the criteria.
5. Extensive Read Out in the Data Window (right side bar pop out window).
As you can see in the thumbnail, there is pasted a copy of the Data Window Dialogue. I am doubtful I can get the thumbnail to load up perfectly aligned. Its hard to get all these data points in here. It may be better suited for a table at this point. Let me know what you think.
The primary, but not exclusive, purpose of what is in the Data Window is to talk about how often your criteria happens and what happens on the next bar. There are a lot of pieces to this.
Red = Values pertaining to the size of the current bar only
Blue = Values pertaining or related to the total number of signals
Green = Values pertaining to the signal bars themselves, including their measurements
Purple = Values pertaining to bullish bars that happen after the signal bar
Fuchsia = Values pertaining to bearish bars that happen after the signal bar
Lime = Last four rows which are your percentage occurrence vs total signals percentages
The best way I can explain how to understand parts you don’t understand otherwise in the data window is search the title of the row in the code using ‘ctrl+f’ and look at it and see if it makes more sense.
█ [b}Available Candle Attributes
Candle attributes can be used in any combination. They include:
[*}Bodies
[*}High/Low Range
[*}Upper Wick
[*}Lower Wick
[*}Average Size
[*}Alternative Criteria
Criteria will evaluate each attribute independently. If none is set for a particular attribute it is bypassed.
Criteria Quantity can be in Ticks, Points, or Percentage. For percentage keep in mind if using anything involving the candle range will not work well with percentage.
Criteria Operators are “Greater Than,” “Less Than,” and “Threshold.” Threshold means within a range of two numbers.
█ Problems with this methodology and opportunities for future development:
#1 This kind of work is hard.
If you know what you’re doing you might be able to find success changing out the inputs for loops and logging results in arrays or matrices, but to manually go through and test various criteria is a lot of work. However, it is rewarding. At the time of publication in early Oct 2022, you will quickly find that you get MUCH more follow through on bear bars than bull bars. That should be obvious because we’re in the middle of a bear market, but you can still work with the parameters and contextual inputs to determine what maximizes your probability. I’ve found configurations that yield 70% probability across the full series of bars. That’s an edge. That means that 70% of the time, when this criteria is met, the next bar puts you in profit.
#2 The script is VERY heavy.
Takes an eternity to load. But, give it a break, it’s doing a heck of a lot! There is 10 unique arrays in here and a loop that is a bit heavy but gives us the debug window.
#3 If you don’t have a clear idea its hard to know where to start.
There are a lot of levers to pull on in this script. Knowing which ones are useful and meaningful is very challenging. Combine that with long load times… its not great.
#4 Your brain is the only thing that can optimize your results because the criteria come from your mind.
Machine learning would be much more useful here, but for now, you are the machine. Learn.
#5 You can’t save your settings.
So, when you find a good combo, you’ll have to write it down elsewhere for future reference. It would be nice if we could save templates on custom indicators like we can on some of the built in drawing tools, but I’ve had no success in that. So, I recommend screenshotting your settings and saving them in Notion.so or some other solid record keeping database. Then you can go back and retrieve those settings.
#6 no way to export these results into conditions that can be copy/pasted into another script.
Copy/Paste of labels or tables would be the best feature ever at this point. Because you could take the criteria and put it in a label, copy it and drop it into another strategy script or something. But… men can dream.
█ Opportunities to PineCoders Learn:
1. In this script I’m importing libraries, showing some of my libraries functionality. Hopefully that gives you some ideas on how to use them too.
The price displacement library (which I love!)
Creative and conventional ways of using debug()
how to display arrays and matrices on charts
I didn’t call in the library that holds the backtesting function. But, also demonstrating, you can always pull the library up and just copy/paste the function out of there and into your script. That’s fine to do a lot of the time.
2. I am using REALLY complicated logic in this script (at least for me). I included extensive descriptions of this ? : logic in the text of the script. I also did my best to bracket () my logic groups to demonstrate how they fit together, both for you and my future self.
3. The breakout, built-in, “alternative criteria” is actually a small bit of genius built in there if you want to take the time to understand that block of code and think about some of the larger implications of the method deployed.
As always, a big thank you to TradingView and the Pinescript community, the Pinescript pros who have mentored me, and all of you who I am privileged to help in their Pinescripting journey.
"Those who stay will become champions" - Bo Schembechler
Market Sessions [Kaspricci]A simple indicator to show you the opening hours of the main markets in London, New York, Tokio and Sydney. It is not shown in your main chart window and as such does not make the chart more difficult to read.
You can turn each market on and off individually and also change the start and end time, if you wish so. All based on GMT timezone, but will be translated into your local timezone.
Happy to receive your feedback.
Crypto Map Dashboard v1.0🔰Overview
Charts are an essential part of working with data, as they are a way to condense large amounts of data into an easy to understand format. Visualizations of data can bring out insights to someone looking at the data for the first time, as well as convey findings to others who won’t see the raw data. There are countless chart types out there, each with different use cases. Often, the most difficult part of creating a data visualization is figuring out which chart type is best for the task at hand.
What are the types of metrics, features, or other variables that you plan on plotting? Although it depended on some multiple factors!
But my choices of the chart type for this Crypto datas was Pie chart or Donut char for crypto dominances ,and Colum (Bar) chart for Total MarketCaps .
The audiences that I plan on presenting this for them could be all tradingviewrs , especially crypto lovers ,or those who just aim to have an initial exploration for themselves ,like me!
so this indicator mostly could be an educational indicator script for pine coders !
We can use the " Crypto Map Dashboard " indicator to Get an quick overview of the crypto market and monitor where the smart money Flow changing by comparing the dominances and totals Caps .
In general, it consists of 4 parts:
✅1 =>> Table1 : If you like to see and compare and monitor the changes of dominances of (Bitcoin, Ethereum, Usdt , Usdc , etc.) and their market cap in different times you can see the table on The upper-right corner.
✅2 =>> Table2: Also, in the table lower-right corner, you can see the changes of the totals(Total, Total2 , Total3 and TotalDefi) in the same time periods.
✅3 =>> pie chart or donut chart: By viewing this , you understand better about Table1 Datas, that it depicts exactly how Dominance is distributed and specialized.
✅4 =>> column chart (bar chart) : And in the last you can clearly compare the total marketcaps and see how far they are from their ATHs.
You also can even notice the entry and exit of liquidity from the crypto market!
I must also mention that I am definitely still a beginner compared to more experienced pine coders, and there may be some bugs in my codes and calculations, but I am an open person and I welcome your comments ,Also Let me know if you have any questions.
Lots of Love to all tradingviewers and pineCoder ,Cheers!💚❤️💙
SMA 10/20/50 by Bull Bear Investing BabyThis script basically is a combination of 3 different simple moving averages line to determine the trend of the assets
The colour indicating which moving averages are as per following:
1) Green- 10MA
2) Red- 20MA
3) Blue- 50MA
When the moving averages are aligned as per following, the trend is indicating towards an uptrend:
---> 10ma > 20ma > 50ma
Likewise when the moving averages are aligned as per following, the trend is indicating towards a downtrend:
---> 10ma < 20ma < 50ma
Dollar Cost Averaging (Portfolio)
You can use it in daily, weekly and monthly candles. It can be used on multiple assets(10). All assets must have data and make sure they all use the same currency. See style in settings for plot titles If you are interested in passive investing, I hope it helps.
------------------
Günlük, haftalık, aylık mumlarda kullabilirsiniz. Birden fazla varlıkta kullanılabilir. Çoklu kullanım için hepsinin verisi olmalı ve aynı para birimini kullanmalı. Ayarlardan stilde grafik başlıklarını bulabilirsiniz. Pasif yatırım ile ilgiyseniz umarım yardımcı olur.
TPO Market Profile [Kioseff Trading]REPOST; SCRIPT WORKS!!
Due to technical error, this script was republished! Thank you for your support (:
Hello!
This indicator comprises a real time TPO Market Profile!
The script works on any timeframe 1 second or greater - the script calculates relative to the timeframe selected for your chart.
The image above shows the 1-minute BTCUSD chart; 650 +/- tick levels are set.
To see the script in full functionality - try using bar replay on a cryptocurrency 1-minute chart (start at the beginning of a regular hours session). Be sure to adjust the tick spread if necessary (:
So far, the script's held up in real time - I've not had any array loop errors or timeouts. The TPO profile updates accordingly with changes in time / high and low prices. Letters are appended to the profile in real time.
The image above shows configurations for the indicator. I plan to update the indicator quite a bit over the coming days - more to come.
You can select the timeframe change the indicator accounts for. For instance, you can have set the indicator to reset every day, every 30 minutes, every 5 minutes, every week, month, etc.
In the image above, I configured the indicator to recalculate every 3 months. Consequently, the indicator will record a TPO profile for three consecutive, reset, then record a TPO profile for the next 3 months. This setting makes the indicator compatible with any timeframe greater than 1 minute.
You can also use a drag & drop time-start bar to modify the starting point for the market profile TPO calculation.
The indicator hosts an option to auto calculate the tick spread between levels. However, as you switch timeframes and assets, sometimes, you'll have to manually set the tick range (:
Thanks for checking it out; more to come!
Sep 4
Release Notes: UPDATE: The indicator can work on seconds-based charts.
The image above shows the indicator working on the 1-second chart.
(Screenshot is old; characters are now numbered instead of strange unicode)
Release Notes: Added value area + vah + val. Font update. Changed characters to numbered once the alphabet is exhausted. POC, VAH, and VAL label located left of the first bar of the interval. Initial balance range can be toggled. Spaced the characters (more legible). Quite a bit of aesthetic changes so check it out!
Soon, I'll release a version of the script that shows VAH, POC, VAL, and TPO letters from previous sessions. I coded this feature into this indicator; however, it was removed due to load time complications. This feature will be its own script (:
If the script has trouble loading please let me know (:
TPO Letters [Kioseff Trading]Hello!
"TPO Letters" functions similarly to the script "Realtime TPO Profile"; however, TPO characters are appended to a developing bar. Simply, TPO characters display on the bar that formed them.
All colors are configurable.
The image above emphasizes functionality; TPO letters are colored on a gradient . Additionally, the value area range is shaded; characters that form within the range are gradient colored. Gray-colored characters extend beyond the value area.
The columned data displayed right of the TPO letters shows tick levels. Tick levels are shaded various colors, each color indicative of some occurrence.
Tick Levels
Red: Single Print
Yellow: POC
Lime Green: VAH or VAL
Lighter Green: Value Area Inclusive Level
Left of the TPO horizontal-axis, the aqua-colored line (blue-line inclusive) reflects the high-low range of the session; the blue-colored line reflects the initial-balance range (IBR).
You can select to color TPO letters within the IBR blue (any color).
Additionally, you can select to shade the IBR.
The image above shows auxiliary features.
Unfortunately, I'm unable to orient TPO letters at their intended tick levels using one label per bar, a contrasting feature of the "Realtime TPO Profile" script.
This means only 1000 TPO letters can be displayed simultaneously. If the number of TPO letters exceeds 1000, early-session and middle-session characters will begin to disappear. This isn't an issue for the "Realtime TPO Profile" script, as each tick level comprised one label, to which additional TPO characters were appended to the label as necessary and extended horizontally. Using this same method proved fallible for this indicator - vertical scaling is an issue. While I could append all letters formed for a bar to one label, the letters wouldn't superimpose atop their corresponding tick level (using " " didn't suffice).
Consequently, you'll have to, at times, rely on the label & box count oriented in the bottom-right table to see whether the number of labels & boxes transcends the upper threshold. You can hide this table at anytime (:
The image above exemplifies the "Fixed Range" portion of the indicator. A useful inclusion for the "Realtime TPO Profile" script however, while still useful for "TPO Letters", can only display 1000 TPO letters concurrently.
You can also reset the TPO profile at user-defined time intervals.
The indicator hosts an auto-calculate tick levels option; however, there will be times you'll need to manually adjust the tick levels to achieve digestible results (:
That's all! If the script would benefit from an excluded feature, or you notice an error, please let me know! Thank you (:
Shoutout to @kaigouthro for creating an exceptional library for gradient colors!! It was used in this script (:
YOY[TV1]Year-to-year comparison is a popular and effective way to evaluate a company's financial performance and investment performance.
Any measurable event that repeats yearly can be compared based on YoY.
As a rule, the indicator YoY (year to year) is the number of percentages indicating an increase or regression in relation to the future or past period.
For example, you can compare WM2NS using the YOY (Year to Year) method.
The Offset argument sets the data comparison period. For daily, weekly and monthly timeframes, if Offset is set to 0, it will be determined automatically.
Сравнение Год к году - популярный и эффективный способ оценки финансовых показателей компании и эффективность инвестиций.
Любое измеримое событие, которое повторяется ежегодно можно сравнить на основе YoY.
Как правило, показателем YoY (year to year) является количество процентов указывающее на прирост или регресс по отношению к будущему или прошлому периоду.
Например, вы можете сравнить WM2NS (эмиссию доллара) с помощью метода YOY (Год к году).
Допустим, в 2021 году вы эмитировали А долларов, а в 2022 вы эмитировали Б долларов
Итак итоговой формулой будет: ((Б - А) / А) * 100
Аргумент Offset устанавливает период сравнения данных. Для дневного, недельного и месячного таймфрейма, если Offset установлен в 0, будет определен автоматически.
Historical Crypto Conference DatesJust a basic list date script to display various conference dates from the crypto sector. Updates to add more conferences.
Red - BTC Miami
Blue - Consensus
VPT Timeleft v.10Timeleft counter for candle in minutes. It will countdown the time left for a candle to close and display near the running candle.
TradersCustomLibraryLibrary "TradersCustomLibrary"
TODO: add library description here
SelectOptimalTimeframeTrendlineSettings()
calculateShortStopLoss()
calculateLongStopLoss()
werdygerTrend()
trendLines()
stoch()
timeToString()
ETH Dominance Excluding BTCThe indicator shows when ETH is undervalued or overvalued with regard to other alts. BTC capitalization is not taken into account.
Range-AnalysisMarkets usually tend to stay within a range during a specific time frame (for example first hour of the regular trading session, the whole regular trading session). For traders before initiating a trade it can be helpful to determine the range potential left for the targeted time frame. So they can decide to either try to ride the current trend further or fade the current trend in the case there is no range potential left for the specific time frame. This could be especially helpful for example in the E-Mini S&P future during the first hour.
The script calculates the average range for the last x days of the session defined and plots a line at the expected range extremes based on that average (for example: RangeExtremeHigh would be currentSessionLow+average Range of the last x days.
Any feedback is appreciated.
BTC Profitable Wallets StrategyBTC Profitable Wallets Strategy - plots the percentage of profitable BTC wallets and places long orders when the profitable wallet share crosses above 50%, historically a very accurate point to catch the next Bull Run early.
The only setting is a smoothing option using the Moving Average method and length of your choice.
On Chain Data is queried from IntoTheBlock.
This is a 'HODL' strategy, with no exit given. If you'd like to see the historical performance check the Open Profit or place a sell order at the current date.
TALibrary "TA"
General technical analysis functions
div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bullish divergence
Parameters:
pS : Price series (float)
iS : Indicator series (float)
cp_length_after : Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
cp_length_before : Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
pivot_length : Bars before and after prior pivot low to be considered valid pivot (optional int)
lookback : Bars back to search for prior pivot low (optional int)
no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW : Weight of change in price, used in degree of divergence calculation (optional float)
iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bearish divergence
Parameters:
pS : Price series (float)
iS : Indicator series (float)
cp_length_after : Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
cp_length_before : Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
pivot_length : Bars before and after prior pivot high to be considered valid pivot (optional int)
lookback : Bars back to search for prior pivot high (optional int)
no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW : Weight of change in price, used in degree of divergence calculation (optional float)
iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
PipMotionFXHi guys,
If you are looking to add some watermark into your charts. You can use this indicator.
You can add add a title and a subtitle, if you want to write in diferents lines, you can use as you can see in the script.
All the features are customizable: position, text size, text color, background.
Enjoy it.
Opening Range Breakout with Price TargetsJust publishing a version of the script amitgandhinz already created, which is amazing.
Added fib levels that amitgandhinz already started but commented out
Added mid point that is often found effective as a starting point, SL, etc
Price ProfileThe indicator shows number of candles present in the horizontal box areas for the given time window. You can set up:
1) Start time
2) Stop time
3) Number of horizontal bars
Machine Learning: kNN (New Approach)Description:
kNN is a very robust and simple method for data classification and prediction. It is very effective if the training data is large. However, it is distinguished by difficulty at determining its main parameter, K (a number of nearest neighbors), beforehand. The computation cost is also quite high because we need to compute distance of each instance to all training samples. Nevertheless, in algorithmic trading KNN is reported to perform on a par with such techniques as SVM and Random Forest. It is also widely used in the area of data science.
The input data is just a long series of prices over time without any particular features. The value to be predicted is just the next bar's price. The way that this problem is solved for both nearest neighbor techniques and for some other types of prediction algorithms is to create training records by taking, for instance, 10 consecutive prices and using the first 9 as predictor values and the 10th as the prediction value. Doing this way, given 100 data points in your time series you could create 10 different training records. It's possible to create even more training records than 10 by creating a new record starting at every data point. For instance, you could take the first 10 data points and create a record. Then you could take the 10 consecutive data points starting at the second data point, the 10 consecutive data points starting at the third data point, etc.
By default, shown are only 10 initial data points as predictor values and the 6th as the prediction value.
Here is a step-by-step workthrough on how to compute K nearest neighbors (KNN) algorithm for quantitative data:
1. Determine parameter K = number of nearest neighbors.
2. Calculate the distance between the instance and all the training samples. As we are dealing with one-dimensional distance, we simply take absolute value from the instance to value of x (| x – v |).
3. Rank the distance and determine nearest neighbors based on the K'th minimum distance.
4. Gather the values of the nearest neighbors.
5. Use average of nearest neighbors as the prediction value of the instance.
The original logic of the algorithm was slightly modified, and as a result at approx. N=17 the resulting curve nicely approximates that of the sma(20). See the description below. Beside the sma-like MA this algorithm also gives you a hint on the direction of the next bar move.
Impulse Strategy Signals V2This is a low timeframe strategy based on SMMAs and RSI, shared by Investishare.
This script turns the indicator into a strategy and allows for several variables to be customized.