INVITE-ONLY SCRIPT

GA - Value at Risk

Updated
GA Value at Risk is a multifunctional tool. Its main purpose is to plot on the chart the Value at Risk. But it shows also integrated features related to the Volatility.


Value at Risk is a measure of the risk of loss for investments, given normal market conditions, in a period.

It measures and quantifies the level of financial risk. In this case, the risk is within position over a specific time frame.

Defining p as VaR, the probability of a loss greater than VaR is p, at most. Instead, the probability of loss that is less than VaR is 1-p, at least.

The VaR Breach occurs when a loss exceeds the VaR threshold.

For this case, VaR calculation uses the volatility estimation in a time interval. It defines the Probability Confidence according to the Normal Distribution. VaR is a percentile of the Normal Distribution. This is a multiplier of the Standard Deviation that define a Volatility Range.

The Normal Distribution Area around +- the Standard Deviation gives 68% of Confidence. 2 times the Standard Deviation returns a 95% of probability area. 3 time the Standard Deviation the Area returns 99.7% of Confidence.

Knowing VaR modeling, it is possible to determine the amount of a potential loss. Then, it is possible to know if there is enough capital to cover losses. In the same way, higher-than-acceptable risks forces reducing exposure in a financial instrument.

One of its practical use is to estimate the risk of an investment that is already at portfolio. Indeed, this is the purpose of the Value at Risk calculated in this script.

At the VaR Breach that investment has reached its worst scenario. Then, it can be the case to manage that investment into the balanced portfolio.

The Value at Risk does not tell when to enter the market.



Moving Averages

GA Value at Risk bases its calculations on a set of Moving Averages. Every feature of the script uses one of these Moving Averages for its algorithm.

Moving Averages from MA0 to MA8, are the core of each feature of the script.

By default, from MA0 to MA8, Moving Averages use the Fibonacci Series to define their lengths. This happens because of the power of the Golden Ratio in the market behavior.

Instead, the first moving average is an extra resource. Its purpose is to plot a Signal Line on the chart.

The script does not consider plotting every Moving Average on the chart. But it lets you enable the plotting of 7 Moving Averages (from MA0 to MA5 + Signal Line).

It is possible to select the Moving Average Formula to use in the script. This is a setting that affects every Moving Average. Then, it changes also the result of every feature of the script.

The selection is between:

  • Exponential Moving Average.
  • Simple Moving Average.
  • Weighted moving Average.



Simple Moving Averages and Pointers - Full Visibility

snapshot



Moving Averages and Partial Visibility

The plotting of each Moving Average can be total or partial.

By default, the plotting of Moving Averages and Signal Line is partial.

When the price approaches a Moving Average a little part of the curve becomes visible. This highlights supports or resistances.

Besides, this tracking remains on the chart. Then it shows supports and resistances that the price reached during its progression.

The Partial Visibility Algorithm is a great advantage, ruling how to plot curves. It uses a parameter to set how much of the curves is to plot.


Exponential Moving Averages and Pointers - Partial Visibility

snapshot


Exponential Moving Averages and Pointers - Full Visibility

snapshot



Moving Averages and Pointers

As it is clear, it is not necessary to plot entire curves of Moving Averages on the chart. But it becomes relevant to plot Pointers to Moving Averages.

Indeed, the script plots horizontal segments that point to the latest Average Prices.

Every segment has a Label that shows Average Price, Length, and its related Moving Average (from MA0 to MA8). Besides, it is possible to extend the segment to right.

These pointers are a very useful automatization. They point to the Moving Averages. In this way, they show Dynamic Supports and Resistances as horizontal segments.

They are adaptive. Used together with the Volume Profile their progression approaches Edges of High Nodes.

This adaptive behavior makes easy to see when the price reaches Volume High Nodes and slows down.

Moving Average Pointers use the Partial Visibility Algorithm. In this case, the algorithm shows pointers with higher frequency than curves.

Moving Averages Pointers have:

  • Horizontal Segment as a Pointer with Arrow.
  • Label with details.
  • Circle to the current Average Price.



Weighted Moving Averages and Pointers - Full Visibility

snapshot



Volatility Channels

Having Moving Averages, from MA0 to MA8, it is possible to plot 9 Volatility Channels.

Each Volatility Channel uses one of the Moving Averages, from MA0 to MA8.

Indeed, each Volatility Channel has the same designation of the Moving Average used.

The Standard Deviation defines the Volatility Range. It uses the length of the Moving Average related to the Volatility Channel.

The Volatility Range is unique for each Volatility Channel. In the same way, each Volatility Channel is unique because of its relation to only one Moving Average.

By default, each volatility channel has the 2 value as Standard Deviation Multiplier. This gives 95% of Confidence that the price will stay into the Volatility Range.

Using the Simple Moving Average, each Volatility Channel becomes a Bollinger Bands envelop.

Volatility Channels work very well even using Exponential or Weighted Moving Averages.


MA0 - Volatility Channel

snapshot


Volatility Channels - From MA0 to MA8

snapshot



Value at Risk (VaR)

GA Value at Risk plots VaR according to the volatility. The VaR plotting follows the Trend Momentum or Buying-Selling Waves.

By default, VaR follows the Trend Momentum by 2 times the Standard Deviation of MA0. Where MA0 is the first Moving Average and Volatility Channel of the set.

Besides, by default, the calculation of the Value at Risk is adaptive. It does not follow the Volatility Channel Bands. But it changes according to the fast reaction of the price into the Volatility Range.

By default, VaR follows the main momentum even if the price is moving in opposition to it. This occurs as long as the Trend Momentum persists.

In the settings box, It is possible to select the following of the latest Buying Wave or Selling Wave.

In this case, VaR changes according to the change of Buying Wave or Selling Wave. This means that, on these conditions, VaR follows main swings. Then it follows the weakening and the strengthening of the trend momentum as long as it persists.

The plotting of the Value at Risk can show these features:

  • Red cycle to show the Value at Risk at the current price.
  • Look Back Red Line that shows the progression of the Value at Risk.
  • Label with details.



MA0 - Value at Risk - Not Adaptive

snapshot


MA0 - Value at Risk - Adaptive

snapshot


It is possible to use a different Moving Average and Volatility Channel from the set. This affects the calculation and the plotting of the Value at Risk. In this way, the algorithm return the Value at Risk for the short, middle, or long-term.

Then, you can get the Value at Risk for that Financial Instrument, calculated for ~1 year or more so as for 1 month.

The Value at Risk does not tell you when to enter the market. Besides, it does not show you that the trend is changing.


MA3 - Value at Risk - Adaptive

snapshot



Value at Profit (VaP)

The Value at Profit has a descriptive purpose. It points the Volatility Band that is opposite to the Value at Risk.

I chose Value at Profit as a designation for this feature. It does not tell you where to exit the market.

But is shows what the price progression is pointing on. This happens following the switching between Volatility Ranges.

The VaP follows the Volatility Band where the price tends to converge.

An outperforming or underperforming price is running faster than the average trend. Then when the price runs enough to converge to the Volatility Band, it is over extended or under extended.

At these conditions, the increased buying or selling pressure affects the price behavior. This slows down the price progression.

The Algorithm behind the Value at Profit is adaptive. Then the pointer jumps up and down the Volatility Bands of the 9 Volatility Channels. This occurs according to the price progression, following the switching between Volatility Ranges.

So, the VaP points a Volatility Band as long as the price can have chances to converges on it. Instead, when the price has chances to exceed the Volatility Band, the VaP points to the next one.

The plotting of the Value at Profit occurs enabling its Label with details.


Value at Profit - MA0 Volatility Channel Upper Band

snapshot


Value at Profit - MA6 Volatility Channel Upper Band

snapshot



Price Extension

When the price runs far away from the average trend price, GA Value at Risk can plot the price extension.

It shows the distance in percentage of the price from a Moving Average of the set. This tends to highlight conditions where the price is over or under extended.

An overbought or oversold condition precedes the shortening of the Trust. It is a cause of the hesitation of the price to continue its progression. This includes also Climactic Points and Signs of Dominance.

The Price Extension plotting uses a variation of the Partial Visibility Algorithm. It plots the Price Extension Arrow only when there are specific volatility conditions.

When the Partial Visibility is set to 0, the Price Extension Arrow is always visible on the chart.

The plotting of the Price Extension includes a Label with details.


Over Extension - The Price is Outperforming MA0

snapshot


Under Extension - The Price is Underperforming MA0

snapshot



Price Extension Coloring for Bars and Line Chart

GA Value at Risk lets you enable the coloring of vertical charts. Green and Red colors mark the over and under extended price on bars, candle sticks, and also on the Line Chart.

The Price Extension Algorithm colors Bars and Line Chart by a momentum function.

Indeed, the coloring happens following Relative Strength Index or Bollinger Bands %B.

These 2 Momentum functions are different. Indeed, they color the chart according to the purpose of their curves.

Coloring the Line Chart, it is necessary to put on front the script visibility.


Overbought and Oversold Conditions on Line Chart by Bollinger Bands %B

snapshot


Overbought and Oversold Conditions on Candlesticks Chart by Relative Strength Index

snapshot



Note: I restrict access to the tool. Use the links in my signature field to gain access to the script. Feel free to send me a PM for any question.


Thank you

Girolamo Aloe
Founder of Profiting Me Finance Analytics



-


Disclaimer

Nobody in Girolamo Aloe websites and trading view profile is a Financial Advisor. Nothing therein is intended to be constructed as Financial Advice. The content on his websites is for information and educational purposes only.

Trading carries high risk. You should not invest money that you cannot afford to lose. Past performance is not an indication of future results.
Release Notes
Important Note

At the date of 9th February 2020, there is a Visual Overlapping Bug that does not depend on the script code. Waiting for a fixing, here details and a work around provided by the Trading View Support:

-

"It's a visual bug where the labels can overlap when additional historical data is loaded. We'll work on fixing it in the future, but I can't give an ETA right now. You should get notified when it is fixed.

As a temporary workaround, you can load additional historical data by scrolling a bit to the left, and then hide/unhide the indicator. That should stop the issue for all the space where the data was loaded before the indicator was unhidden."
Release Notes
Release Notes:

- Improved the Algorithm that calculate and plot the Price Extension %.
- Improved the use of Bollinger Band Width for the Partial Visibility of the Price Extension %.
- Now the Value at Risk Label can show the Buying Selling Wave when Value at Profit is disabled.
- Changed default Settings.
- Tidied up code.
- Other minor adjustment.
Release Notes
changelog

GA - Value at Risk
v1.1.5.1, 200501 - girolamoaloe

- Fixed a typing mistake.
- Adjusted versioning.
Release Notes
Change Log

GA - Value at Risk
— version 1.1.5.12, 200512 — girolamoaloe


- Plot the Pointer also for MA1 and MA2
- By default the plotting of Moving Averages Curves ( full or partial visibility ) is disabled.
- By default the plotting of MA5 Pointer full visibility is enabled.
Release Notes
Change Log

GA - Value at Risk
— version 1.1.5.26, 200526 — girolamoaloe

- Removed Plotting and Calculation of the Signal Line Moving Average.
- Added the Plotting of Pointers MA4, MA3, and MA2.
- Removed the Plotting of Pointer MA1.
- By default, MA5 Curve with partial visibility, is now on the chart.
Release Notes
Change Log

GA - Value at Risk
— version 2.1.6.11, 200611 — girolamoaloe


- Restructured Algorithms and Conditions.
- Restructured Tool Features.
- Restructured the Display Set.
- Added the GA Functions Set - version 1.1.6.5 - This includes Mathematical Functions and the new Partial Visibility Algorithm.
- Added 3 New Pointers and their Moving Averages MA8, MA9, MA10, extending Price Levels from 8 to 11.
- New Feature: Added the "Plot All Moving Averages", to show all curves.
- New Feature: Added the "Plot All Pointers Segments Extended to Left", to extended Pointers Horizontal Lines in the Visual Area.
- Changed the Algorithm for calculation and plotting of Adaptive Value at Risk.
- Changed the Partial Visibility Functions and Conditions to plot Moving Averages and their Pointers.
- Changed the Price Extension Mathematical Tools used in its Calculation.
- Removed the Unnecessary Volatility Ranges.
- Removed the Value at Profit Calculation and its Plot.
- Removed unnecessary options from the Display and the relative Plot Conditions for Pointers Horizontal Lines.
- Removed Select Boxes for Moving Averages.
- Removed Calculation and Plotting of the Over Extended Price on Candlestick, Bars, and Line Charts.
- Tidied up code.


GA - Value at Risk - Features

snapshot


GA - Value at Risk - Pointers for Curves and Trend Following Price Levels Segments

snapshot


GA - Value at Risk - Pointers Segments Extended to Left

snapshot


GA - Value at Risk - Partial Visibility Feature for each Curve and Pointer

snapshot
Release Notes
Change Log

GA - Value at Risk
— version 2.1.6.13, 200613 — girolamoaloe

- Restructured the Adaptive Asset Value at Risk Algorithm, giving higher precision and higher adaptability.
- New Feature: "Plot Value at Risk Look back from the beginning".
- New Feature: "Adaptive VaR Sensibility - Calculation Weight ] 10, 0 [
- Added a new Visibility Condition to plot Asset Value at Risk Label.
- Tidied up code.


GA -VaR - Value at Risk Look Back

snapshot


GA -VaR - Adaptive and Standard VaR Curves

snapshot

snapshot


GA -VaR - Adaptive VaR Sensibility Calculation - 11 Curves which show 11 Sensibility Degrees, from 10 to 0

snapshot

snapshot
Release Notes
GA - Value at Risk
— version 2.1.6.20, 200620 — girolamoaloe

- New Feature: Added the GA Functions Set — version 1.1.6.20 — This includes Mathematical Functions and the Partial Visibility Algorithm.
- Bug Fix: Schaff Trend Cycle Top and Bottom Edges Constriction, when the curve persists on the top or the bottom edge.
- Applied the New Partial Visibility Algorithm on Curves and Pointers.
Release Notes
Change Log

GA - Value at Risk
— version 2.1.6.25, 200625 — girolamoaloe

- New Feature: Added the GA Functions Set — version 1.1.6.21 — This includes Mathematical Functions and the Partial Visibility Algorithm.
- Added Fibonacci Numbers for the Adaptive VaR Curve Smooth.
- Changed Asset VaR Label_up and Label_down with the new Label_upper_left and Label_lower_left.
- Changed the Display Settings favoring a more user-friendly interface related the plotting settings of Moving Averages and their Pointers.
- Changed Algorithm Condition for the plotting of Moving Averages, Pointers, and their Partial Visibility.
- Removed the Adaptive VaR Sensibility Setting from the Display because it was not necessary.
- Tidied up code.
Release Notes
Change Log

GA - Value at Risk
— version 3.1.7.4, 200704 — girolamoaloe


- New Feature: Added the GA Functions Set — version 1.1.6.30 — This includes Mathematical Functions, Partial Visibility Algorithm, and Ticks Precision Algorithm.
- New Feature: Added Disclaimer in the Display Settings. When the Disclaimer is disabled, every plot function of the tool is disabled.
- New Feature: Distinct Moving Average Selection for Volatility Channel, Value at Risk, Moving Pointers.
- Added the missing Color Description for Pointers Segments Extended to Left.
- Added the Rolling Standard Deviation as a Non-Gaussian Distribution of Asset Returns, Value at Risk Base Function.
- Added One more Degree in the Value at Risk Weight Sensibility.
- Restructured and Simplified the Adaptive Asset Value at Risk Algorithm.
- Restructure Algorithm Conditions for Value at Risk Label and Plots.
- Tick Precision Algorithm now rules any number visible in the Label.
- Tidied up code.
Release Notes
Change Log

GA - Value at Risk
— version 3.1.7.5, 200705 — girolamoaloe

- Added Asset Conditions Set, including the Leverage Effect Conditions.
- Added Label Conditions to make the Label more informative.
- Restructured the Label Algorithm.
- Now the Label provide dynamic details about the Asset.
Release Notes
Change Log

GA - Value at Risk
— version 3.1.7.12, 200712 — girolamoaloe

- New Feature: Added the GA Functions Set — version 2.1.7.12 — This includes Mathematical Functions, Partial Visibility Algorithm, and Ticks Precision Algorithm.
- New Feature: Added Asset Details in the Asset Value at Risk Label.
- Added: Added Dark Green and Dark Red Colors in the GA Functions Set.
- Added Leverage Effect Algorithm Conditions.
- Added Excess of Kurtosis Algorithm Conditions.
- Added Dark Green and Dark Red Colors for Over Extension and Under Extension Indication and Label.
- Tidied up code.


Asset Value at Risk Details.

Asset Status Details.
- Leverage Effect ( Non-Gaussian Distribution of Asset Returns).
- Excess of Kurtosis - Leptokurtosis, Mesokurtosis, Platykurtosis ( Non-Gaussian Distribution of Asset Returns).
- Price Extension.
- Trend Momentum.
- Trend Waves.

GA - Value at Risk - Financial Mathematical Features
snapshot
Release Notes
Change Log

GA - Value at Risk
— version 4.1.8.30, 200830 — girolamoaloe


- New Feature: Added GA Functions Set — version 3.1.08.25 — This includes Mathematical Functions, Partial Visibility Algorithm, and Ticks Precision Algorithm.
- New Feature: Added GA Conditions Set — version 2.1.08.30 — This includes Fundamental Algorithm Calculations, Conditions, and Parameters.
- New Feature: "Plot Leptokurtic Pivot".
- New Feature: "Enable Leptokurtic Pivot Label" and "Enable Leptokurtic Pivot Compact Label".
- Added Leptokurtic Pivot Algorithm.
- Added a new Algorithm to Color Asset Value at Risk Curve and Label (Green for Bullish, Red for Bearish)
- Added a new Algorithm for Price Extension Visibility.
- Added a new Algorithm for Ticks Precision.
- Added a new Algorithm for Partial Visibility.
- Adjusted Excess of Kurtosis Conditions.
- Adjusted Schaff Trend Cycle Wave Conditions.
- Improved Pointer Label Details.
- Improved Asset Value at Risk Label Details.
- Removed Bollinger Band and Bollinger Width Calculations and Dependencies.
- Tidied up code.


Asset Value at Risk Details
- Value at Risk (Normal or Adaptive).
- Value at Risk Distance from the Average Trend Price.

Asset Status Details
- Leverage Effect (Rolling Standard Deviation as a Non-Gaussian Distribution of Asset Returns).
- Excess of Kurtosis - Leptokurtosis, Mesokurtosis, Platykurtosis (Non-Gaussian Distribution of Asset Returns).
- Price Extension.
- Trend Momentum.
- Trend Waves.
- Thrust.


GA - Value at Risk - Financial Mathematical Features

snapshot
Release Notes
Change Log

GA - Value at Risk
— version 4.1.8.31, 200831 — girolamoaloe

BugFix: Adjusted Visibility Conditions for Price Extension %
girolamoaloeMoving AveragesprofitingmesmaTrend AnalysisvalueatriskVARVolatilityvolatilitychannel

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact girolamoaloe for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases, you can find a good open-source alternative for free in our Community Scripts.

Author's instructions

Want to use this script on a chart?

Warning: please read before requesting access.

Gain access to my Scripts Registering on
Profiting Me Finance Analytics > profiting.me/

Girolamo Aloe - girolamoaloe.com/
FB - facebook.com/aloe.girolamo/
IN - instagram.com/aloe.girolamo/
Also on:

Disclaimer