TF Segmented Linear RegressionFit a line at successive intervals, where the interval period is determined by a user-selected time frame, this allows the user to have an estimate of the intrinsic trend within various intervals.
Settings
Timeframe : Determine the period of the interval, if the timeframe is weekly then a new line will be fit at the start each weeks, by default "Daily"
Mult : Multiplication factor for the RMSE, determine the distance between the upper and lower extremities
Src : Input data for the indicator
Plot Extremities : Logical value, if true then the extremities of the channel are plotted, if false only the midline is plotted, true by default.
Usage
The timeframe setting should be higher than the current chart timeframe, note however that too large values of timeframe might return an error. Since the maximum number of lines that can be plotted is 54, using the extremities will only return 18 channels.
The indicator can be compared to the "regression trend" drawing tool
Main tf = 5 min with the indicator using a daily timeframe, the filled area is produced by the regression trend drawing tool using the same interval as the indicator, and coincide with it.
Main tf = 15 min with the indicator using a weekly timeframe, wider channel indicate that the values tend to be farther away from the fitted line.
A line with a significant slope indicates a strong trend, in that case, the width of the channel is determined by the amplitude of the retracements in the trend, with a narrower channel indicating a cleaner trend.
When the fitted line has a low slope value and the channel is wide, it means that there were two or more variations of opposite directions with large amplitudes within the interval, this also indicates that a linear model is not appropriate.
A slope approximately equal to 0 with a low channel width indicates a trendless market with cyclical variations of low amplitude in it.
Refrences
Determining the starting and ending points of the fitted line was done using a linear combination between the wma and sma
The wma and sma functions both use a series as period by making use of the Wma and Sum functions in the following script
指標和策略
Stochastic Weights - Basic [BigBitsIO]This script is a compilation of several different stochastic indicators (and RSI) where the K value of each indicator is equally weighted. The purpose of the indicator is to combine many indicators together in a fashion that weights them easier. By default, the Stochastic and Stochastic RSI are both enabled - the idea is to speed up the relatively slower Stochastic and to slow down the relatively fast Stochastic RSI. Other Stochastics are also available, including some of my own custom calculations that can also be added to the weighted calculation. Only the K value is weighted, as the D value is just a moving average of the weighted K.
Explained:
- Calculates enabled indicators
- Calculates the weighted value of K for enabled indicators
- Calculates a D value from the weighted K
FAQ:
- Why is this script useful?
- To weight multiple indicators together so that you can attempt to find optimal values shared amongst the indicators. Ex: If Stochastic RSI is 100 and Stochastic is 50, K would be 75 and not particularly high. If you add in a 50 RSI, the K would be 67 in this example. If we weight indicators together that all have a high value they could potentially help find elements that align together to produce a stronger signal.
DISCLAIMER: For educational and entertainment purposes only. Nothing in this content should be interpreted as financial advice or a recommendation to buy or sell any sort of security or investment including all types of crypto. DYOR, TYOB.
Trend QualityThe quality of the current trend is calculated by adding or subtracting
one point to the total value depending on the following criteras:
1. EMA-8, MA-20, MA-50, MA-100, MA-200 , each get a point if they are increasing.
2. EMA-8 > MA-20 > MA-20 > MA-50 > MA-100 > MA-200 , each condition that is true gets one point.
On top of the Trend Quality value we apply a "weekly" (5 periods) and
a "monthly" (22 periods) moving average.
When above a value of 5, a strong trend is indicated and hence
a trend following strategy should be used.
Use this to Buy when bouncing back from e.g MA-20 or a confirming
consolidation/candlestick/trendline pattern.
When the trend decreases below Zero a trend shift may have occured.
Idea, curtesy: Tobbe Rosèn
SwingArm ATR Trend IndicatorThe general idea of using SwingArms is to provide a visual confirmation of a trend change.
Green for bullish (BUY)
Red for bearish (SELL)
A color-coded system providing an easy way for a novice to understand.
Converted to TradingView based on the work of Jose Azcarate.
I hope you guys enjoy.
Support Resistance MTFHello Traders,
This is Support Resistance script that uses Multi Time Frame. While getting Close/Open/High/Low values of Higher Time Frames the script does NOT use Security function , instead it calculates them.
while choosing Higher Time Frame, you can use "Auto" option so it uses predefined Higher Time Frames, or you can choose the Higher Time Frame Manually from the list. options for HTF => 15mins, 30mins, 60mins, 120mins, 180mins, 240mins, 720mins, Day, Week, 2 Weeks, Months, 3 Months, 6 Months, 12 Months.
You have option to use High/Low or Close/Open values while calculating support resistance levels.
"Period for Highest/Lowest Bars" option is used as loopback period to check if it's Highest/lowest bars. smaller numbers = more sensitive result.
You have option for transparency and coloring of support/resistance levels/zone => Red, Lime, Blue, White, Black, Olive, Gray
An example for 15 min chart, 4hours selected as HTF
You can set transparency and colors as you wish:
You can choose Close/Open prices while calculating S/R levels instead of High/Low
Enjoy!
Hull Candles [BigBitsIO]This script is for custom candles based on an HMA calculation with a default period of 10 as well as an SMA of the close price, defaulted to 1 period to only show the current price. The purpose of the custom candles is to try and reduce noise from candles and help identify trends. These custom candles somewhat resemble Heikin-Ashi candles in their appearance.
Explained:
- Open, High, Low and Close (o, h, l, and c) are all calculated using an HMA calculation based on a user input length/period, defaulted at 10.
- Candle colors are determined by using the same HMA calculation on the ohcl4 and comparing it to the previous candle. Green candles have an ohlc4 greater than the previous candle, all other candles are red.
- The current price is plotted with the default blue line with an SMA calculation with 1 period to allow customization of smoothing if necessary to identify trends.
DISCLAIMER: For educational and entertainment purposes only. Nothing in this content should be interpreted as financial advice or a recommendation to buy or sell any sort of security or investment including all types of crypto. DYOR, TYOB.
VAMA Volume Adjusted Moving Average FunctionThis indicator is a live analysis adaptation of Richard Arms' Volume Adjusted Moving Average coded as a single function. VAMA utilizes a period length that is based on volume increments rather than time. Settings are provided for using as a pair of fast and slow moving averages.
• SampleN - N volume bars used as sample to calculate average volume , 0 equals all bars.
• VAMA Source - Price used for volume weighted calculations.
• VAMA Length - Specified number of volume ratio buckets to be reached.
• VAMA VI Fct - Size of volume ratio buckets.
• VAMA Strict - Must meet desired volume requirements, even if number of bars has to exceed VAMA Length to do it.
Please see previous published example here for more details on VAMA's usage and inability to redraw the past on time based charts.
NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Funamental and financialsEarnings and Quarterly reporting and fundamental data at a glance.
A study of the financial data available by the "financial" functions in pinescript/tradingview
As far as I know, this script is unique. I found very few public examples of scripts using the fundamental data. and none that attempt to make the data available in a useful form
as an indicator / chart data. The only fitting category when publishing would be "trend analysis" We are going to look at the trend of the quarterly reports.
The intent is to create an indicator that instantly show the financial health of a company, and the trends in debt, cash and earnings
Normal settings displays all information on a per share basis, and should be viewed on a Daily chart
Percentage of market valuation can be used to compare fundamentals to current share price.
And actual to show the full numbers for verification with quarterly reporting and debuggging (actual is divided by 1.000.000 to keep numbers readable)
Credits to research study by Alex Orekhov (everget) for the Symbol Info Helper script
without it this would still be an unpublished mess, the use of textboxes allow me to remove many squiggly plot lines of fundamental data
Known problems and annoyances
1. Takes a long time to load. probably the amount of financial calls is the culprit. AFAIK not something i can to anything about in the script.
2. Textboxes crowd each other. dirty fix with hardcoded offsets. perhaps a few label offset options in the settings would do?
3. Only a faint idea of how to put text boxes on every quarter. Need time... (pun intended)
Have fun, and if you make significant improvements on this, please publish, or atleast leave a comment or message so I can consider adding it to this script.
© sjakk 2020-june-08
Binomial Option Pricing ModelA binomial option pricing model is an option pricing model that calculates an option's price using binomial trees. The BOPM method of calculating option prices is different from the Black-Scholes Model because it provides more flexibility in the type of options you want to price. The BOPM, unlike the BS model typically used for European style options, allows you to price options which have the ability to exercise early, such as American or Bermudan options. Although you can use the BOPM for any option style.
This specific model allows you to price both American and European vanilla options.
The way the BOPM calculates option prices is by:
First, dividing up the time until expiry into equal parts called steps. This specific model presented only uses 2 steps. For example, say you have an option with an expiry of 60 days, and your binomial tree has only two steps. Then each step will contain 30 days.
Second, the model will project the expected price of the underlying at the end of each step, called a node. The expected price is calculated by using the underlying's volatility and projecting what the price of the underlying would be if it were to rise and fall. This step is repeated until the terminal node, aka the end of the tree, is reached.
Third, once the terminal node's expected underlying prices are calculated, their expected option prices must be calculated.
Finally, after calculating the terminal option prices, backwards induction must be used to calculate the option prices at the previous nodes, until you reach Node 0, aka the current option price.
In order to use this model:
1st. Enter your option's strike price.
2nd. Enter the risk-free-rate of the currency the option is based in.
3rd. Enter the dividend yield of the underlying if it's a stock, or the foreign risk-free-rate if it's an FX option.
*For example, if you were trading an AAPL stock option, in the risk-free-rate box mentioned in step 2, you would enter the US risk-free-rate because AAPL options are traded in US dollars. In the dividend yield box mentioned in step 3, you would enter the stock's dividend yield, which for AAPL is 0.82.
*If you were, for example, trading an option on the EUR/JPY currency pair, the risk-free-rate mentioned in step 2, would be the Japanese risk-free-rate. Then in the the dividend yield box from step 3, you'd input the Eurozone risk-free-rate.
*If you were trading an options on futures contract, the risk-free-rate mentioned in step 2, would be the risk-free-rate for whatever currency the futures contract is denominated in. For example EUR futures are denominated in USD, so you would input the US risk-free-rate. Meanwhile, something like FTSE futures are denominated in GBP, so you would input the British risk-free-rate. As for the dividend yield box mentioned in step 3, for all options on futures, enter 0.
4th. Pick what type of underlying the option is based on: stock, FX, or futures.
5th. Pick the style of option: American or European.
6th. Pick the type of option: Long Call or Long Put.
7th. Input your time until expiry. You can express this in terms of days, hours, and minutes.
8th. Lastly, input your chart time-frame in term of minutes. For example, if you're using the 1 min time-frame enter 1, 4hr time-frame enter 480, daily time-frame enter 1440.
*Disclaimer, because this particular model only uses 2 steps, it won't work on stocks with high prices (over $100). If you want to use this on stocks with prices greater than $100, you would need to add more steps to the code, shown below. The model in its current form should work for stocks below $100.
Bayesian BBSMA OscillatorSometime ago (very long ago), one of my tinkering project was to do a spam or ham classification type app to filter news I'd wanna read. So I built myself a Naive Bayes Classifier to feed me my relevant articles. It worked great, I can cut through the noise.
The hassle was I needed to manually train it to understand what I wanna read. I trained it using 50 articles and to my surprise, it's enough.
Complexity Theory
I've been reading a book called The Road to Ruin by Jim Rickards. He described how he got to his conclusion of how the stock market works by using Complexity Theory. Bill Williams would agree. Jim tells us that by using just enough data, we calculate the probability of an event to occur. We can't say for sure when but we know it's coming. This was my light bulb moment.
While Jim talks much about Bayesian Inference in which a probability of an event can always be updated as more evidence comes to light, I had my eyes set on binary probabilities of when prices are going up and down.
Assumptions
These are my assumptions:
Prices breaking up a Bollinger basis line will have fuel to go up even higher
Prices will go down when prices have broken up a Bollinger upper band
Scalping is the main method so we should use a lower period Moving Average (MA)
When prices are above MA, it's likelier a correction to the downside is imminent
When prices are below MA, it's likelier a correction to the upside is imminent
Optimize parameters for 1 hour timeframe which will give us time to react while still having more opportunities to trade
Building Blocks
Jim Rickards started with limited data (events) while in technical trading, data are plentiful. I decided to classify 2 events which are:
Next candles would be breaking up
Next candles would be breaking down
Key facts:
We won't know for sure when prices are going to break
We won't know for sure how much the prices movements are going to be
Formulas
Breaking up:
Pr(Up|Indicator) = Pr(Indicator|Up) * Pr(Up) / Pr(Indicator|Up) * Pr(Up) + Pr(Indicator|Down) * Pr(Down)
Breaking down:
Pr(Down|Indicator) = Pr(Indicator|Down) * Pr(Down) / Pr(Indicator|Down) * Pr(Down) + Pr(Indicator|Up) * Pr(Up)
Reading The Oscillator
Green is the probability of prices breaking up
Red is the probability of prices breaking down
When either green or red is flatlining ceiling, immediately on the next candle when the probability decreases go short or long based on which direction you're observing - Strong Signal
When either green or red is flatlining ceiling, take no action while it's ceiled
Usually when either green or red is flatlining bottom, the next candle when the probability increases, immediately take a short long position based on the direction you're observing - Weak Signal
When either green or red is flatlining bottom, take no action while it's bottomed
Alerts
Use Once per Bar option when generating alerts.
Time Range StatisticsA good amount of users requested a text box showing various price statistics, the following script returns various of these stats in a user-selected range, and include classical ones such as a central tendency measurement (mean), dispersion (normalized range) and percent change, but also include less common statistics such as average traded volume and number of gaps. The script also calculates the correlation between the closing price and another user-selected instrument.
The script is currently the longest one I ever made and took some efforts, as I wasn't satisfied with the statistics to be originally included. Big thx to Gael for the enormous feedback and the idea of the normalized range, to user @Cookiecrush for the feedback ( without ya I would have posted something bad you know umu ? ), and Lulidolce for the support, friendship is magic!
Selected Range
The setting Start determine the bar at which the range starts, while End determine at which bar the range end. To help you select these values, the current bar number (bar index) is displayed at the right of the indicator title in blue.
The setting evaluate to last bar will use a range starting at Start and ending at the last bar, as such you can use a full range by using Start = 0 and select evaluate to last bar
The range is highlighted by an area on the chart. By default Start = 9000 and End = 10000, you might not have this amount of data in your chart, as such use the displayed bar index to select Start and End, then set the settings as default.
Displayed Statistics
The statistics panel is displayed on the right side of the last bar, the panel has 3 sections, a title section who shows the symbol ticker, timeframe, and overall trends represented by a chart emoji, the overall trends are determined by comparing the number of higher highs with the number of lower low.
Below are displayed the date ranges with time format: year/month/day/hour:minute.
The second section shows the general statistics. The first one is the mean, also represented by the orange line in the chart, the blue line displayed represent the highest price value in the range, while the red one represents the lowest price value.
The second stat is the normalized range, and determine how spread is the price in the user-selected range, why not the standard deviation? Because the standard deviation might return results varying widely depending on the scale of the closing price, you could get measures such as 0.0156 or 16 or even 56 depending on the instrument, as such using a normalized range can be more appropriate as it lays in a range of (0,1). Lower values indicate a low degree of price variation. Note that I still want to find another measure in the future.
The percentage change (or relative change) indicates at which percentage the price has increased or decreased, and is calculated by subtracting the closing at bar Start with the price at bar End , divided by the price at bar End , the result is then multiplied by 100.
The average traded volume calculate the mean of the volume in the selected range, I used the same format used by the original volume indicator for clarity.
Finally, the last stats of the section is the number of gaps, this stat is by default hidden. An up gap is detected when the open price is superior to the previous high, while a down gap is detected when the open price is inferior to the previous low, this allow to only retain significant gaps.
The last section of the indicator panel shows the correlation between the closing price and another instrument, by default GOOG, this correlation is also calculated within the user-selected range. Positive values indicate a positive relationship, that is the two instruments tend to move in the same direction. Negative values indicate a negative relationship, both instruments tend to move in a direction opposite to each other. Values closer to 1 or -1 indicate a stronger relationship, while values closer to 0 indicate no relationship.
In Summary
The script shows various stats, each calculated within a user-selected range, in general one would be more interested in how these stats might evolve with time, but checking them in a custom range can be quite interesting.
Thx for reading. umu
ATR Based Trendlines - JDThis script draws trendlines from the pivot points in the price chart.
The angle of the trendlines is determined by (a percentage of) the atr.
The angle follows the change in price, dictated by the atr at the moment where the pivot point is detected.
The atr percentage determines if the trendline follows the rate of change of the atr or a fraction ( value < 100) or a multiple ( value > 100) of that
JD.
#NotTradingAdvice #DYOR
Disclaimer.
I AM NOT A FINANCIAL ADVISOR.
THESE IDEAS ARE NOT ADVICE AND ARE FOR EDUCATION PURPOSES ONLY.
ALWAYS DO YOUR OWN RESEARCH!
Revolution Volatility Bands With Range Contraction Signal VIIAlso one of my favorite indicators. Very simple and easy to use. Essentially volatility bands with a technical analysis pattern, the triangle/wedge, which I have called "contraction signal". Put simply: When price is written in blue, volatility overall is falling. When the outer bands start to fatten up in blue, a contraction signal is forming. Works with any length of your choosing.
Reminder Message (with color picker) - ApopheniaPaysThis is a very simple script. It displays a message above the latest price. I coded it because I need a constant reminder to keep me from overtrading.
You can customize several options:
- The message text
- How high above the latest price the message is displayed
- How often it is displayed. 1=display constantly, 2=only show it during every other period, 3=only show it every 3rd new period, etc. So, for example, if you are on the 15 minute chart, and set a frequency of 3, it will show it for the first 15 minutes out of every 45.
- Color and lightness. This can be used as an example of how to add a color selection input to your own scripts.
Mawreez' RSI Divergence DetectorThe idea behind this indicator is to have an expression for the amount of divergence on a given chart at every point in time . To achieve this, it adds up the magnitudes any valid divergence of any kind; bullish, bearish or their hidden variants. Where a valid divergence consists of a line on the source series (almost always the closing price), and a line on an oscillator (here: the RSI). The slopes of said lines must have opposite signs, that is to say, one line must be sloping up while the other slopes down. Said lines may not cross their respective series.
The length of the RSI is configurable (default length: 14). The lengths of the divergences are configurable (default: minimum length 3 and maximum length 28 - the latter being twice the default length of the RSI).
This indicator will detect divergences which are still building up. Be duly warned: upcoming divergences may still get invalidated. Another case that one should be very mindful of is that an upcoming divergence may still increase in magnitude before it plays out. Possibly over several more timesteps, there may even be entire additional drives.
The value of this indicator indeed reflects the magnitude of divergence on a chart. However, there is no reason to think the magnitude of a divergence affects the likelihood of said divergence playing out.
The color of the indicator indicates the kind of divergence. The default colors are
green for bullish divergence,
maroon (dark red) for bearish divergence,
lime/light green for hidden bullish divergence,
dark pink for hidden bearish divergence.
Please let me know if you would like to see a version of this indicator that plots both the RSI and this histogram. I will do this for personal use, but I am being a bit of a purist with this publication.
In fact, please don't hesitate to make any comment or to give any kind of suggestion.
US Fed Balance SheetThe United States Fed assets by USD value on their publicly available balance sheet.
From: fred.stlouisfed.org
There is an option to show change from the previous period. Not every category from the website is listed in the indicator.
Listed categories:
Total
Treasury Bills
Treasury Notes and Bonds, Nominal
Mortgage-Backed Securities
Repurchase Agreements
Fed Agency Debt Securities (Primary/Secondary/Seasonal Credit + TALF)
Commercial Paper Funding Facility
Commercial Paper Funding Facility II (Post 2020-04-14)
Central Bank Liquidity Swaps
Related reading:
Funding, Credit, Liquidity, and Loan Facilities - www.federalreserve.gov
CPFF - www.federalreserve.gov
TALF - www.federalreserve.gov
Central Bank Liquidity Swaps - www.federalreserve.gov
Correlation Cycle, CorrelationAngle, Market State - John EhlersHot off the press, I present this "Correlation Cycle, CorrelationAngle, and Market State" multicator employing PSv4.0, originally formulated by Dr. John Ehlers for TASC - June 2020 Traders Tips. Basically it's an all-in-one combination of three Ehlers' indicators. This power packed triplet indicator, being less than a 100 line implementation at initial release, is a heavily modified version of the original indicator using novel techniques that surpass John Ehlers' original intended design.
This is also a profound script in numerous ways. First of all, these three indicators are directly from the illustrious mastermind himself Dr. John Ehlers. Secondarily, this is my "50th" script published on TV, which makes it even more significant. I'm especially proud of this script to "degrees" of imagination I once didn't know was theoretically possible in code. My intellect has once again been mathemagically unlocked pondering new innovations with this code revelation. Thirdly, this PSv4.0 script shows the empowering beauty and elegance of hacking the stock markets with TV's ultra utilitarian Pine Editor(PE) in a common browser! Some of you may be wondering if I worked on this for days... nope! This only took a few hours, followed by writing this description for another hour plus.
I have created many of Ehlers' indicators in PE, a few of which I have published in my profile, but I wanted to show how programming with Pine Script can be an artistic form of craftsmanship and poetry. None of this would be possible without the ingeniously minded Tradingview staff revolutionizing algorithmic trading at it's finest. If you should ever encounter them by chance, ponder humbly thanking these computing wizards for their diligence and dedication. They are providing, and shall award to us members, some of the most fascinating conceptualized tech imaginable in the coming future. I can assure you, much, much more is yet to be unveiled for us TV members/enthusiasts. Thank you TV and all you offer to this community.
As always, I have included advanced Pine programming techniques that conform to proper "Pine Etiquette" by example. There are so many Pine mastery techniques included, I don't have an abundance of time to elaborate on all of them. For those of you are code savvy, you may have notice I only used one "for" loop for increased server efficiency, instead of the two "for" loops in the original formulation. For those of you who are newcomers to Pine Script, this code release may also help you comprehend the immense "Power of Pine" by employing advanced programming techniques while exhibiting code utilization in a most effective manner. This is commonly what my dense intricate code looks like behind the veil. If you are wondering why there is hardly any notes, that's because the notation is primarily in the variable naming.
Features List Includes:
Dark Background - Easily disabled in indicator Settings->Style for "Light" charts or with Pine commenting
AND a few more... Why list them, when you have the source code!
The comments section below is solely just for commenting and other remarks, ideas, compliments, etc... regarding only this indicator, not others. When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!
Separated Moving Average - evoHere are two moving averages, one based on positive candles and the other based on negative candles. If the current bar is positive, the negative MA will use its last known negative bar for the calculation. The default setting uses Heikin Ashi to smooth the candles with the trend, you can turn this off if you want in inputs.
Let me know if you find it useful :)
RedK_Supply/Demand Volume Viewer v1Background
============
VolumeViewer is a volume indicator, that offers a simple way to estimate the movement and balance (or lack of) of supply & demand volume based on the shape of the price bar. i put this together few years ago and i have a version of this published for another platform under different names (Directional Volume, BetterVolume) in case you come across them
what is V.Viewer
=====================
The idea here is to find a "simple proxy" for estimating the demand or supply portions of a volume bar - these 2 forces have the potential to affect the current price trend so we want an easy way to track them - or to understand if a stock is in accumulation or distribution - we want to do this without having access to Level II or bid/ask data, and without having to get into the complexity of exploring the lower timeframe price & volume data
- to achieve that, we depend on a simple assumption, that the volume associated with an up move is "demand" and the volume associated with a down move is "Supply". so we basically extrapolate these supply and demand values based on how the bar looks like - a full "green" price bar / candle will be considered 100% demand, and a full "red" price bar will be considered 100% supply - a bar that opens and closes at the same level will be 50/50 split between supply & demand.
- you may say this is a "too simple" of an assumption to make, but believe me, it works :) at least at the basic scenario we need here: i'm just exploring the volume movement and finding key levels - and it provides a good improvement compared to the classic way we see volume on a chart - which is still available here in VolumeViewer.
in all cases, i consider this to be work in progress, so i'd welcome any ideas to improve (without getting too complicated) - there's already a host of great volume-based indicators that will do the multi timeframe drill down, but that's not my scope here.
Technical Jargon & calculation
===========================
1. first we calculate a score % for the volume portion that is considered demand based on the bar shape
skip this part if it sounds too technical => if you're into coding indicators, you would probably know there are couple of different concepts for that algorithm - for example, the one used in Balance Of Power formula - which i'm a big fan of - but the one i use here is different. (how?) this is my own, ant it simply applies double weight for the "wick" parts of a price bar compared to the "body of the bar" -- i did some side-by-side comparison in past and decided this one works better. you can change it in the code if you like
2. after calculating the Bull vs Bears portion of volume, we take a moving average of both for the length you set, to come up with what we consider to be the Demand vs Supply - as usual, i use a weighted moving average (WMA) here.
3. the balance or net volume between these 2 lines is calculated, then we apply a final smoothing and that's the main plot we will get
4. being a very visual person, i did my best to build up the visuals in the correct order - then also to ensure the "study title" bar is properly organized and is simple and useful (Full Volume, Supply, Demand, Net Volume).
- i wish there was a way in Pine to hide a value that i still need to visually plot but don't want it showing its value on the study title bar, but couldn't find it. so the last plot value is repeated twice.
How to use
===========
- V.Viewer is set up to show the simplified view by default for simplicity. so when you first add it to a chart, you will get only the supply vs demand view you can see in the middle pane in the above chart
- Optional / detailed mode: go into the settings, and expose all other plots, you will be able to add the classic volume histogram, and the Supply / Demand lines - note these 2 lines will be overlay-ed on top of each other - this provides an easy way to see who is in control - especially if you change the display of these 2 lines into "area" style. This is what is showing in the lower pane in the above chart.
** Exploring Key Price Levels
- the premise is, at spots where there's big lack of balance, that's where to expect to find key price levels (support / resistance) and these price levels will come into play in future so can be used to set entry / exit targets for our trades - see the example in the AAPL chart where you can easily locate these "balance or reversal levels" using the tops/bottoms/zero-crossings from the Net Volume line
** Use for longer-term Price Analysis
- we can also use this simple indicator to gain more insights (at a high level) of the price in terms of accumulation vs distribution and if the sellers or buyers are in control - for example, in the above AAPL chart, V.Viewer tells us that buyers have been in control since October 19 - even during the recent drop, demand continued to be in play - compare that to DIS chart below for the same period, where it shows that the market was dumping DIS thru the weakness. DIS was bleeding red most of the time
Final thoughts
=============
- V.Viewer is an attempt to enhance the way we see and use Volume by leveraging the shape of the price bar to estimate volume supply & demand - and the Net between the 2
- it will work for stocks and other instruments as long as there's volume data
- note that V.Viewer does not track trend. each bar is taken in isolation of prior bars - the price may be going down and V.Viewer is showing supply going up (absorption scenario?) - so i suggest you do not use it to make decisions without consulting other trend / momentum indicators - of course this is a possible improvement idea, or can be implemented in another indicator, add in trend somehow, or maybe think of making this a +100 / -100 Oscillator .. feel free to play with these thoughts
- all thoughts welcome - if this is useful to you in your trading, please share with other trades here to learn from each other
- the code is commented - please feel free to use it as you like, or build things on top of it - but please continue to credit the author of this code :)
good luck!
-