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)
Statistics
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.
TPO Profile with Day StatFirst of all I want to Thank @noop42 for creating this wonderful Market Profile chart in Pine script
I have made some changes to this scripts
This Script can auto calculate the TPO Size for NSE Symbols and MCX Crude oil.
This Script Will only calculate the TPO's for visible range only so that the script use less heap size.
I have added some of the day Statistics to enhance your visualization.
Limitations of this Script
Currently This Script can Plot Market Profile Chart only for Historical Data.
It Can only Plot Market Profile Charts in 30-Mins Time Frame only so that you can't use it for Composite Profile Analysis.
To plot Market Profile Chart in Real Time and Historical please use "Market Profile With TPO by Drother"
Nonlinear Parametric Oscillator - PSOThis script is in development phase and may be buggy. use with your own risk. The idea here is to determine the sinusoidal directional changes in the supply and demand. Based on direction, you can enter and make huge gains. Recommended to use on 1 min chart. The sideways market would be indicated as flattening in the respective bands. There are four bands, bottom one is where market is in BEAR mode and top one is when market is in BULL mode.
The indicator doesnt work well when the ticker price is less than 10 dollars, i am working on it. Do not use on penny stocks, for the time. More-details when I make this a robust version.
LUNC Spot IndexIndex of several (eventually all) luna classic spot markets with some bonus features!
FOMC & CPI DatesThis indicator plots vertical lines at the scheduled times of US Federal Reserve's FOMC Meeting Dates.
Data is based on U.S. Federal Open Market Committee (FOMC) Meeting Minutes
Intraday Range CalculatorThis indicator shows an easy way to determine if the stock, index or ETF ended within a configurable intraday range.
This solution is ideal for those who study and like Iron Condors or Iron Butterflies strategies.
Results:
If the square is red, it means that the selected deviation limits have been exceeded within the chosen times.
If the square is green, the price stayed within the pre-set limits.
A yellow circle marks the moment when the price leaves the range, either by the upper band or by the lower band.
In the last bar a label with the test results will be displayed.
Settings:
In the configuration there are three fields:
1. Deviation : is the range in percentage that the price can move up or down from the start time to the end time.
2. Begin Time: is the time (in 24h or military format) where the process begins.
3. End Time: is the time (in 24h or military format) where the process ends.
Example:
* for the time 11:00 am, you must enter "1100"
* for the time 2:45pm, you must enter "1445"
Important:
The selected timeframe must be less than 1 hour and Extended Trading Hours in the lower left corner), otherwise the indicator may not show results.
Later I will make an improvement to solve these inconveniences.
Stock Gaps SPY Correlation StrategyThis is daytrade stock strategy, designed to take the best out of the daily gaps that are forming between the close of previous day and opening of present day.
At the same time its logic has been adapted for SPY chart, in order to use correlation with the other stocks/assets/ etf which are linked with SP500 movement.
Lastly it has been added 2 new confirmation logics, based on the USI: advance/decline chart and percentage above vwap among all US stocks.
The rules for entry are simple :
We are at the opening daily candle, we have a long/short gap based on where the opening is happening and at the same time we are checking to see that the current different between the current difference between low and previous high (or viceversa) is higher than an established parameter(minimal deviation )
For exit, we exit based on time/clock parameter, in this case by default I selected 1h and half before close of the US session.
For testing purposes I have used 10% of the available capital, with a 0.0035$ comission per each share bought ( IBKR comissions)
If there are any questions, please let me know either here or in private !
energies_correlation_zscoreA table to help track correlations between the four major energies contracts of the CME. The table shows the z-score of the current correlation value between HO, RB, CL, and NG. The inputs are:
- timeframe: the timeframe of the calcluation. the default is 5 minutes.
- window: the rolling window over which to calculate the correlations. the default is 48, or four hours given the default timeframe.
A score of zer means that the correlation over the latest window is in line with the average for all windows sampled from the chart history. More positive scores imply higher positive correlation than normal, and vice versa for negative scores.
BTC Hashrate ribbonsBTC Hash Rate ribbons / Hash Rate cross
This strategy goes long when BTCs Hash Rate 30 day moving average crosses above the 60 day moving average, signifying that miner capitulation is over and recovery has started.
When the opposite signal is given, which signifies the beginning of miner capitulation, the strategy goes short (or flat, depending on configuration). This is generally considered the most popular Hash Rate related strategy.
The strategy is based on this medium article: medium.com
Thanks to the recent integration of IntoTheBlock data into Tradingview, we can now effortlessly show Hash Rate data on our chart,
keep in mind however, that IntoTheBlock doesn't provide Hash Rate data on timeframes below daily, so this strategy is based used on the daily, weekly or even monthly time frames.
Hash Rate definition:
The Bitcoin hash rate is the number of times per second that computers on the Bitcoin network are hashing data to verify transactions and perform the encryption that secures the network. The hash rate is an indicator of how healthy the Bitcoin network is at any given time, and is driven primarily by difficulty mining and the number of miners. Generally, a high hash rate is considered a good thing.
More precisely, the Bitcoin hash rate is the number of times per second that computers on the Bitcoin network are hashing data to verify transactions and perform the encryption that secures the network.
Tickers Info ExtensionWith the indicator you can easily evaluate or compare any ticker with the one you choose in the options.
You can choose any of the tickers I provide in the mod options to your liking :
XAU
DXY
BTC
ETH
SPX
NASDAQ
AVG Stable Dominance
AVG Stock Price
Custom
You can also select or create your own ticker if you select the Custom in Mode option.
If the Compare mode is enabled, then the current ticker you are viewing is divided by the ticker selected in the indicator (in the Mode option).
Thus, you create a new pair and can evaluate the strength of this or that asset.
For example, if you have the ticker BTCUSDT open. And the ticker XAU is selected in the Mode option in the indicator. And the Compare mode is also enabled. Then you will get a new BTCUSDT/XAU pair. That means that now you can see the bitcoin/gold ratio. (Same as EUR/USD etc.)
If the Compare option is switched off then you will see the usual ticker you choose in the Mode option. You can also see if there is a correlation between the selected pairs.
Option ' AVG STABLE.D ' = Calculated as: USDT.D + USDC.D + DAI.D
- This is the average domination of the most important Stable Coins
Option ' AVG STOCK Price ' = Calculated as: (DJI + SPX + NDQ) / 3
- This is the average price of the most important Indexes.
BTC Hashrate with smoothingBTC Hashrate with smoothing - thanks to the recent integration of IntoTheBlock data into Tradingview, we can now effortlessly show Hashrate data on our chart.
One popular use for Hashrate is to buy when the 30 day moving average crosses above the 60 day moving average, signifying that miner capitulation is over and recovery has started.
Definition
The Bitcoin hash rate is the number of times per second that computers on the Bitcoin network are hashing data to verify transactions and perform the encryption that secures the network. The hash rate is an indicator of how healthy the Bitcoin network is at any given time, and is driven primarily by difficulty mining and the number of miners. Generally, a high hash rate is considered a good thing.
More precisely, the Bitcoin hash rate is the number of times per second that computers on the Bitcoin network are hashing data to verify transactions and perform the encryption that secures the network.
Relative Perfomance IndexHello Traders.
Lets keep it simple..
1. Take the major pairs that have USD in them and watch their change over a specific timeframe.
2. Now lets sort these changes of each pair from the most positive to the most negative.
Good, I see you have some ideas already.
This is exactly what this indicator does. You will visualize the biggest change in pairs of the timeframe of your choice and from this you can decide on pairs that you want to trade.
Covering Shadow Candle PatternThis indicator shows 3 types of objects on chart:
1. downward red triangle above a candle: 3 green candles followed by a fourth red candle of which the low price is lower than the low of the 3 previous green candles, this is usually the sign of reversal from upward movement to a downward one.
2. 1. upward green triangle below a candle: 3 red candles followed by a fourth green candle of which the high price is higher than the high of the 3 previous red candles, this is usually the sign of reversal from downward movement to a upward one.
3. boxes: these boxes are drawn when the patterns of cases 1 and 2 fails to perform as expected which means we have some important areas at that level so it can be a resistance or support zone .
testJust testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this
Intraday Accumulator [close-open]This script plots close-open cumulative from the beginning of the chart. It is made for use on equities with overnight sessions to view the intraday performance vs the candlestick chart.
Weighted percentile nearest rank oscillatorOriginal script
This is my attempt at making a price oscillator out of gorx1's weighted percentile nearest rank script. I centered everything to the 50th percentile and everything oscillates around that. The upper and lower bounds are 100th and 0th. Normalization normalizes the data to the top and bottom lines. The 'center line' represents the momentum of the 50th percentile in either direction. Good luck and happy hunting.
Improved Z-Score OverlayLast month I published an improved z-score script that goes underneath your chart, which helps to highlight overbought or oversold regimes. It is customizable, and allows changing the periods, whether smoothing capability is desired, whether to use simple or exponential moving averages, and which data source to use (open, high, low, close, ohlc4).
Some individuals may find that it is most useful not only to have the z-score visible underneath their price chart, but have the sigma values clearly visible on the chart itself to determine overbought or oversold levels.
Therefore, this improved z-score overlay script will place the centerline of price on the chart, and +3/+2/+1/0/-1/-2/-3 sigma.
These can be disabled if some values do not want to be shown, and the colors / opacity can be changed.
Additionally, you could also put this into a new pane below your chart and disable all of the +3 to -3 sigma values, and enable the "Z-Score" button. This will allow you to replicate the original Improved Z-Score Script.
If anyone has questions or would like to have any improvements made, let me know :)
- Jim Bosse
Normalized Correlation CoefficientThis is a normalized correlation coefficient that can be used with any timeframe or symbol desired (found in the indicator settings). The normalization function makes the coefficient bound between 0-1. There is a subjective threshold at 0.80 where anything below the threshold tends to be higher risk in trading as opposed to above the threshold.
Suggestions:
- Use a timeframe slightly higher than your current chart for optimal results.
- Do not use as a standalone strategy, rather, use it as a layer of confirmation.
- For altcoin cryptocurrencies, we suggest tethering the indicator to the "OTHERS" chart.