Statistics
RSI and Golden Cross ScreenerIts an example of basic cyclic screener. Looks for conditions on RSI and for Golden crosses for N bars back on top40 crypto on Binance. Feel free to contact me via tg @davidkohen if you got any questions!
It's an improvement of an old QuantNomad's idea :)
Key Financials A simple table with up to 9 key financials on your chart.
Simple, easy and configurable.
Market Profile Visible RangeSup TV, 2 important points .
1) surprisingly, it's the first MP Visible Range script on TV;
2) This one doesn't use any bagging/binning*, instead each row represents the time spent on the actual minimal price steps (aka ticks).
The script will be further extended with usual market profile related functionally in future updates. At this point we have:
- Profile itself (each row represents how many bars touch the given price);
- Mode of the profile (called POC)**;
* Still it will be introduced in future when I will find / design the proper aggregating technique. It is vital for processing very wide price ranges (for example, 500 days on ES futures).
** The script correctly calculates POC by finding all the modes in the data & choosing the closest one to data's midrange.
For this kind of technical instrument finally it was more convenient to use Pine Script 5 (btw it's my first Pine 5).
Basically this script is a side-effect of another R&D I'm doing, the stuff is useful tho so let's go.
By choosing length we both specify the amount of data to be processed & the profile's location screen-wise. It's pretty cool and & useful, on my screen it's always almost touching the left side and still always visible.
The code is heavily commented in order to be understood fast, nothing fantastic, just a lil patience required this time.
Rationale
Market & volume profiles are well known concepts, lotta info available, the most important point of all that is that MP is just another way of visualizing data that lets you notice things you don't usually notice on sequential charts. From my side I can only add that it's better to use your own brain for thinking and reconsidering using volume profile in all the cases, especially on decentralized markets (unless you're aggregating ALL the volume data from everywhere, including options, OTC etc).
Here is it, for you
Loft Strategy V4This strategy is an advanced version of the Loft Strategy V1, I shared earlier. (Loft Strategy V1 consists of a kalman filter (by alexgrover ) and a "stop and reverse" line which is following and the kalman filter. If the price goes in the same direction as the position side, the "stop and reverse" line approaches the kalman filter as set on the "Approach Decrease Step" parameter.)
In addition to the previous version, it includes a martingale like deviation and multiple take-profit.
Here it is some parameters definitions of the strategy:
Kalman Filter: The higher this parameter, the faster and more aggressive the filter. Otherwise the filter goes very smoothly
Beginning Approach: First approximation as a percentage of stop-n-reverse line
Final Approach: Minimum approximation of stop-n-reverse line
Approach Decrease Step: If the price moves in the same direction as the strategy, the approach percentage is reduced by this parameter. Otherwise nothing do
Base Order Quantity: Initial capital of position
Max Safe Order Attempt: This parameter determines the maximum number of times the strategy will raise the bet after losing in a row.
Safe Order Deviation: if the last trade is loss, multiply the bet by this parameter (aka. martingale factor)
Profit Deviation: if last trade in loss, multiply the take-profit points
Max Order Quantity: Maximum capital allowed for a position
TP1, TP2, TP3 : Take profit spots in percentage
QT1, QT2, QT3: Amount of take-profit spots
Stop Loss: Maximum stop loss allowed for a trade
Long Entry, Short Entry: Only long side, only short side or both side
Safe Stop After TP2: If the price reaches the TP2 point, move the stop-loss point to the entry price.
Safe Stop After TP1: If the price reaches TP1, move the stop-loss point to the stop-n-reverse line.
Feature scalerFeature scaler | Pine Utilities series, ready to be used in "study-on-study" fashion |
Includes min-max, normalization, standardization and unit length scaling.
One and only source: en.wikipedia.org
Endpoint inputs allow to set an interval of interest for min-max scaler.
Can be (and should be) applied to other studies, or to the chart itself. In this example, I applied min-max scaling to weighted linear regression's slope values.
Unfortunately, "All data" is still "experimental" and works only on charts where less than 5000 bars are available. max_bars_back() didn't help.
Sup TV
Valuation TableHey folks, I hope you are all doing well!
This is an indicator that you can use to help you to evaluate companies. There are a few things I added to the valuation table that I personally use and I will explain what they are.
I added Joel Greenblatt's ROC% because it takes Earnings before Interest and Taxes to reflect more closely what the company earns from its operations, while including the cost of depreciation/amortization of assets. A high double digit figure often means that the company has a defensible edge versus its competitors (e.g. a strong brand or a unique product). It's good for relative valuation (comparing two companies in the same industry).
I also added Donald Yacktman's forward rate of return. Yacktman defines forward rate of return as the normalized free cash flow yield plus real growth plus inflation . Unlike the Earnings Yield %, the Forward Rate of Return uses the normalized Free Cash Flow of the past seven years, and considers growth. The forward rate of return can be thought of as the return that investors buying the stock today can expect from it in the future. Yacktman’s Forward Rate of Return may or may not be a useful metric. However, it does present new ways to see and think about stocks we may want to buy.
I added a box called "real price" and that is from Peter Lynch's book, "One Up on Wall Street," where he talked about how the real price of the stock is really the current price - Net Cash Per Share.
I would also personally pair this script with TradingView's built in financial indicators that shows the revenue growth, net income, etc.
Note: the script only works on the weekly timeframe and it will take some time to load because it has a lot of data.
Heavy Weight Stocks for Bank NiftyHeavy Weight Stocks for Bank Nifty
Stocks which are part of Bank Nifty are displayed in the table.
If the %Change > 1 then bold green
If the %Change <1 and >0, then light green
If the %Change < -1 then bold red
If the %Change > -1 and <0 then light green
NSE:BANKNIFTY
NSE:HDFCBANK
NSE:ICICIBANK
NSE:AXISBANK
NSE:KOTAKBANK
NSE:SBIN
NSE:NIFTY
NSE:RELIANCE
NSE:HDFC
divergenceLibrary "divergence"
divergence: divergence algorithm with top and bottom kline tolerance
regular_bull(series, series, simple, simple, simple, simple, simple) regular_bull: regular bull divergence, lower low src but higher low osc
Parameters:
series : float src: the source series
series : float osc: the oscillator index
simple : int lbL: look back left
simple : int lbR: look back right
simple : int rangeL: min look back range
simple : int rangeU: max look back range
simple : int tolerance: the number of tolerant klines
Returns: array:
hidden_bull(series, series, simple, simple, simple, simple, simple) hidden_bull: hidden bull divergence, higher low src but lower low osc
Parameters:
series : float src: the source series
series : float osc: the oscillator index
simple : int lbL: look back left
simple : int lbR: look back right
simple : int rangeL: min look back range
simple : int rangeU: max look back range
simple : int tolerance: the number of tolerant klines
Returns: array:
regular_bear(series, series, simple, simple, simple, simple, simple) regular_bear: regular bear divergence, higher high src but lower high osc
Parameters:
series : float src: the source series
series : float osc: the oscillator index
simple : int lbL: look back left
simple : int lbR: look back right
simple : int rangeL: min look back range
simple : int rangeU: max look back range
simple : int tolerance: the number of tolerant klines
Returns: array:
hidden_bear(series, series, simple, simple, simple, simple, simple) hidden_bear: hidden bear divergence, lower high src but higher high osc
Parameters:
series : float src: the source series
series : float osc: the oscillator index
simple : int lbL: look back left
simple : int lbR: look back right
simple : int rangeL: min look back range
simple : int rangeU: max look back range
simple : int tolerance: the number of tolerant klines
Returns: array:
least_squares_regressionLibrary "least_squares_regression"
least_squares_regression: Least squares regression algorithm to find the optimal price interval for a given time period
basic_lsr(series, series, series) basic_lsr: Basic least squares regression algorithm
Parameters:
series : int t: time scale value array corresponding to price
series : float p: price scale value array corresponding to time
series : int array_size: the length of regression array
Returns: reg_slop, reg_intercept, reg_level, reg_stdev
trend_line_lsr(series, series, series, string, series, series) top_trend_line_lsr: Trend line fitting based on least square algorithm
Parameters:
series : int t: time scale value array corresponding to price
series : float p: price scale value array corresponding to time
series : int array_size: the length of regression array
string : reg_type: regression type in 'top' and 'bottom'
series : int max_iter: maximum fitting iterations
series : int min_points: the threshold of regression point numbers
Returns: reg_slop, reg_intercept, reg_level, reg_stdev, reg_point_num
simple_squares_regressionLibrary "simple_squares_regression"
simple_squares_regression: simple squares regression algorithm to find the optimal price interval for a given time period
basic_ssr(series, series, series) basic_ssr: Basic simple squares regression algorithm
Parameters:
series : float src: the regression source such as close
series : int region_forward: number of candle lines at the right end of the regression region from the current candle line
series : int region_len: the length of regression region
Returns: left_loc, right_loc, reg_val, reg_std, reg_max_offset
search_ssr(series, series, series, series) search_ssr: simple squares regression region search algorithm
Parameters:
series : float src: the regression source such as close
series : int max_forward: max number of candle lines at the right end of the regression region from the current candle line
series : int region_lower: the lower length of regression region
series : int region_upper: the upper length of regression region
Returns: left_loc, right_loc, reg_val, reg_level, reg_std_err, reg_max_offset
on_balance_volumeLibrary "on_balance_volume"
on_balance_volume: custom on balance volume
obv_diff(string, simple) obv_diff: custom on balance volume diff version
Parameters:
string : type: the moving average type of on balance volume
simple : int len: the moving average length of on balance volume
Returns: obv_diff: custom on balance volume diff value
obv_diff_norm(string, simple) obv_diff_norm: custom normalized on balance volume diff version
Parameters:
string : type: the moving average type of on balance volume
simple : int len: the moving average length of on balance volume
Returns: obv_diff: custom normalized on balance volume diff value
moving_averageLibrary "moving_average"
moving_average: moving average variants
variant(string, series, simple) variant: moving average variants
Parameters:
string : type: type in
series : float src: the source series of moving average
simple : int len: the length of moving average
Returns: float: the moving average variant value
SuperTrend OptimizerHello!
This indicator attempts to optimize Supertrend parameters. To achieve this, 102 parameter combinations are tested concurrently - the top three performers are listed in descending order.
Parameters,
Factor: Changes to this parameter shifts the tested factor range. For instance, increasing the factor measure from 3.00 to 3.01 (+0.01) will remove 3.00 from the tested range - this setting controls the lower threshold of the range. The upper threshold, in all instances, is the lower Factor threshold + 3.3 (i.e. 3.0(lower) - 6.3(upper), 4.0(lower) - 7.3(upper), 2.5(lower) - 5.8(upper))
ATR period: Changes to this parameter shifts the tested ATR period range. For instance, increasing the ATR measure from 10 to 11 (+1) will remove 10 from the tested range - this setting controls the lower threshold of the range. The upper threshold, in all instances, is the lower threshold + 2 (i.e. 10(lower) - 12(upper), 11(lower) - 13(upper), 9(lower), - 11(upper))
The Factor parameter is modifiable to any positive decimal number; the ATR parameter is modifiable to any positive integer. Changing either parameter shifts the tested parameter combination range. Both parameters can be changed in the settings, to which you control the lower threshold of the range. If, for instance, you were to change the Factor measurement from 3.0 to 4.1 (+1.1) the 4.0 Factor measurement, and all Factor measures less than 4.0, will be excluded from the performance test.
Consequently, a Supertrend test will be performed with a Factor of 4.1 and an ATR period of 10 (default). This test repeats at 0.1 Factor intervals and 1.0 ATR intervals.
Therefore, assume you modify the Factor lower threshold to 3.1 and the ATR lower threshold to 10. The indicator will test three Supertrend systems with a Factor of 3.1 and an ATR period of 10.. then 11.. 12, then three systems with a Factor of 3.2 and an ATR period of 10.. then 11.. 12... until (lower Factor threshold + 3.3) and (lower ATR threshold + 2) are tested... which in this example is... a Factor of 6.4 and an ATR period of 12.
The tested Factor range and ATR range are displayed in a bottom right table alongside the top performing parameter combinations.
Of course, you can change the the lower thresholds, which means you can test numerous Supertrend parameter combinations! However, no greater than 102 parameter combinations will be tested simultaneously; the best performing Supertrend parameters are plotted on the chart automatically.
I will be working on this indicator more tomorrow! Let me know if you have questions or anything you would like included!
(I of course added something fun in the script. Be sure to try it with bar replay!)
StrengthA mathematically elegant, native & modern way how to measure velocity/ strength/ momentum. As you can see it looks like MACD, but !suddenly! has N times shorter code (disregard the functions), and only 1 parameter instead of 3. OMG HOW DID HE DO IT?!?
MACD: "Let's take one filter (1 parameter), than another filter (2 parameters), then let's take dem difference, then let's place another filter over the difference (3rd parameter + introduction of a nested calculation), and let's write a whole book about it, make thousands of multi-hours YouTube videos about it, and let's never mention about the amount of uncertainty being introduced by multiple parameters & introduction of the nested calculation."
Strength: "let's get real, let's drop a weighted linear regression & usual linear regression over the data of the same length, take dem slopes, then make the difference over these slopes, all good. And then share it with people w/o putting an ® sign".
Fyi, regressions were introduced centuries ago, maybe decades idk, the point is long time ago, and computational power enough to calculate what I'm saying is slightly more than required for macd.
Rationale.
Linearly weighted linear regression has steeper slope (W) than the usual linear regression slope (S) due to the fact that the recent datapoints got more weight. This alone is enough of a metric to measure velocity. But still I've recalled macd and decided to make smth like it cuz I knew it'll might make you happy. I realized that S can be used instead of smoothing the W, thus eliminating the nested calculation and keeping entropy & info loss in place. And see, what we get is natural, simple, makes sense and brings flex. I also wanna remind you that by applying regression we maximize the info gain by using all the data in the window, instead of taking difference between the first and the last datapoints.
This script is dedicated to my friend Fabien. Man, you were the light in the darkness in that company. You'll get your alien green Lambo if you'll really want it, no doubts on my side bout that.
Good hunting
Bond Yeild CurveBond Yeild Curve
A bond yeild curve is a line that plot the interest rate of bonds of each maturity dates.
The slope of the curve give the future of economy cycle.
if the slope could be normal (positive), flat or even inverted.
This indicator aquired data of bond yeild provided by TradingView.
How to use it.
Select the country of the bond / another country to compare.
Select the maturity of bond (this indicator set 2Y, 5Y, 10Y and 20Y as default).
You can toggle to 3 different data set; Yeild, Spread (10Y-2Y) and Yeild Curve.
In case that you select the "Yeild Curve", you can customize the desired past period to compare.
How we can get the benefit.
- If the current spread is greater than 1.0, it suppose that the economy of that country probably is ok.
- if the current spread is between 0 - 1.0, it suppose to be flatted and probably turn to invert and the economy cound be in a recession soon.
- if the current spread is below 0, it suppose to be inverted and economy is in recession.
when knowing the state of economy, it would help us to manage our investment.
When you select "Yeild"
When you select "Spread"
When you select "Yeild Curve"
I'm new for this.
if any idea, correction and suggestion, i do appreciate it.
VIX Cheat SheetHello!
This indicator - "VIX Cheat Sheet" - performs several calculations for $VIX against the asset on your chart. However, using $VIX as a risk proxy or volatility metric often fails beyond large-cap U.S equities. To remedy this, the VixFix indicator is included in the script; you can select whether the script performs calculations for an asset against $VIX or against VixFix (i.e. Forex, Crypto)
Measured are: $VIX correlation to an asset's price fluctuations, the average close-to-close gain/loss subsequent a $VIX/VixFix close above the upper Bollinger Band, the average 5-session gain/loss following the same occurrence in addition to the average 10-session gain/loss, all close-to-close, 5 session, and 10-session gains/losses are stored as tooltips for labels on the chart. The current close-to-close percentage gain/loss for $VIX and VixFix are displayed on the chart.
Displayed in the example image is a box incorporating $VIX price data alongside an upper Bollinger Band and lower Bollinger Band. The data isn't cast to its own price scale but is helpful for quick interpretation of $VIX fluctuations. You can select to plot VixFix data in the box in the user inputs table.
Displayed in the second example image is a semi-transparent blue box encompassing all price moves that occurred when $VIX measured above $40 for at least ten consecutive sessions. The largest percentage close-to-close loss is displayed below the box.
Also illustrated is a red label that appears when $VIX or VixFix closes above the upper Bollinger Band. The indicator will calculate and display the performance of the asset for the subsequent 10 sessions, to which the red label will disappear and all data stored as a tooltip in the blue labels stating "VIX Closed Above Upper Band" or "VixFix Closed Above Upper Band".
To reduce chart clutter, a label and line combination marking all $VIX closes above the upper Bollinger Band was not included. Instead, bar color changes were added. When "$VIX" is selected in the user inputs table the indicator will mark all sessions in which $VIX closed above the upper band as blue, in addition to plotting $VIX price data in the dynamic black box. When "VixFix" is selected, the indicator will mark all sessions where VixFix closed above the upper band as purple; the VixFix indicator will be plotted in the black box.
Be sure to hover over labels to access tooltip information; try the indicator with bar replay!
Volume Variation Index IndicatorThis tool is a quantitative tip for analysts who study volumes or create volume based trading strategies.
Like all our projects, we start with a statistical logic to which we add coding logic.
This indicator can save a huge amount of time in calculating the variation of volume between sessions .
How it work
The indicator calculates the difference between the volume of the last closing bar and the volume of the previous closing bar. It shows the difference between the trading volumes.
The session in which the trading volume is up are represented in green.
Red session represent trading volume down.
We have added a third function.
Through the User Interface the trader can activate or deactivate the variation average.
The indicator is able to calculate the average of the volume changes by representing it with a blue line.
To activate the average, simply set it to ON in the User Interface.
By default, the indicator calculates the average of the last 10 periods, but you are free to set this parameter in the User Interface.
Data access
To access the data, simply move the cursor. When you move the cursor over the green bars, the increase data will be displayed in green. By hovering the cursor over the red bars you will see the decrease data in red. By hovering the cursor over the average will show you the average data in blue.
The data is displayed in the top left corner of the indicator dashboard.
If you found this indicator helpful, please like our script.
WhaleCrew Crypto Open InterestUse Crypto Open Interest Data available on TradingView to your advantage.
Features
Auto-Detect Symbol (based on chart)
Preset Symbols (BTC, ETH, BNB, XRP, LUNA, ADA, SOL, AVAX and DOT)
Exchanges ( Binance and BitMex )
Inverse and USDT Pairs
Override Data Option to use any OI Data on TradingView
Customizable Candles
[TTI] All-time-high (ATH), (ATL), 52 week high and low Dots––––History & Credit
I wanted to show our community the idea that stocks that make All Time High are likely to continue making ATHs for some time. It goes contrary to the idea "buy cheap sell high". Actually, in the real market leaders the stocks that make 100+% return are just getting started on returns to few THOUSAND percent. I have used code from QuantNovad scrip in this one too. So thanks to him as well, since it speeded writing it from scratch!
–––––What it does
The script paints dots and shows stats.
The dots are 4 types:
🟢 = Every time a new ATH is achieved, a green dot paints above the bar
🟣 = Every time a new 52week High is achieved, a purple dot paints above the bar
🟡 = Every time a new ATL is achieved, a yellow dot paints below the bar
🟠 = Every time a new 52week Low is achieved, a orange dot paints below the bar
Stats =
Show in a box in the bottom right corner of the screen. How many times has this stock achieved:
👉 ATHs
👉 52WK High
👉 ATLs
👉 52WK LOW
–––––How to use it
This is really an illustrative script to get the idea of the methodology "buy high sell higher', that we teach as momentum traders.
Some notable examples to check are:
HOOD
MSFT
TSLA
AAPL
See the stock dynamics and understand that bottom fishing doesn't result in stocks making massive moves.
Average Quarterly and Annual Gain/Loss (Color Divided)Hello!
Simple script here!
(BE SURE TO TRY WITH BAR REPLAY)
This indicator measures the current quarterly gain/loss (Q1, Q2, Q3, Q4) and the average quarterly gain/loss.
The average percentage gain/loss for Q1, Q2, Q3, and Q4 are calculated and displayed on the chart; colors are adjustable.
By default, Q1 is measured as blue, Q2 as green, Q3 as red and Q4 as yellow.
Also measured is the average annual percentage gain/loss and the current year's running gain/loss.
Years are split by a dashed line, beneath which a label displays that year's percentage gain or loss, in addition to the average annual gain or loss.
Labels and lines update per bar!
A constantly updating line connects the high price of the first session for a quarter to the current high price. The line will delete and restart when a new quarter occurs.
Labels, lines, and line fills are color coded. So, any change to the quarterly/annual color scheme will change the color for all labels, lines, and line fills for that particular quarter!
Thanks for reading!
Interest Rates | USA / EU / UKThis script shows the Interest Rates of the USA, EU and UK.
USA = Red
EU = Blue
UK = White
PSAR Optimization ScriptHello!
User @henryph24 suggested I make this script!
This script calculates the cumulative and average gain/Loss of rising SAR following a price crossover of SAR.
The cumulative and average gain/Loss of falling SAR following a price crossunder is also measured.
Changes to the parameters of SAR will return the requisite calculations for evaluating performance.
Benchmark SAR can be used to compare performance against test SAR.
When changing the SAR parameters the script will recalculate and display the rising SAR and falling SAR performance of the modified parameters. The script works for any asset on any timeframe.
Essentially, this script allows you to optimize SAR parameters, and quickly ascertain what can/cannot work for an asset.
The script automatically plots the best performing SAR between a benchmark SAR (SAR #1) and a test SAR (SAR #2). Both benchmark SAR and test SAR works the same. The two are used to compare performance between different SAR parameters. If you would like the script not to plot the best performing SAR you can select "On" for the "Override SAR" input box. Doing so will plot the SAR parameters of your choice while still allowing you to compare the performance of benchmark SAR and test SAR.
There are tooltips available in the user input tab that explain the SAR parameters, in addition to what your modifications of the parameters will do, should you be unfamiliar with the indicator!
Enjoy!