Creating Normalized Volatility Bands Using ProBuilder

23 Feb 2020
0 comment
0 attachment

This ProBuilder code snippet demonstrates how to create normalized volatility bands around a moving average of relative strength. The normalization process adjusts the upper band to 100 and the lower band to 0, making it easier to compare and visualize changes in volatility.

//---Settings
CloseMAPeriod = 144
RMAPeriod = 21
UpperValue = 3.0 //"Upperbands %"
LowerValue = 3.0 //"Lowerbands %"
//---end of settings

R = Close / Average[CloseMAPeriod]
RAve = Average[RMAPeriod](R)
UpperBand = RAve * (1 + (UpperValue / 100))
LowerBand = RAve * (1 - (LowerValue / 100))
RValue = ((R - LowerBand) / (UpperBand - LowerBand)) * 100

RETURN 100, 0, RValue as "R"

This code snippet is structured to calculate and plot normalized volatility bands based on the relative strength of a financial instrument. Here’s a breakdown of the code:

  • Settings Block: Defines the parameters for the moving averages and the percentage values for the upper and lower bands.
  • Relative Strength Calculation: The variable R is calculated as the ratio of the current close price to the moving average of the close price over a specified period (CloseMAPeriod).
  • Average of Relative Strength: RAve computes the moving average of the relative strength over another specified period (RMAPeriod).
  • Upper and Lower Bands Calculation: These are calculated by adjusting the average relative strength (RAve) by a specified percentage (UpperValue and LowerValue).
  • Normalization of R: The variable RValue normalizes the relative strength value R between the calculated upper and lower bands, scaling it to a range of 0 to 100.
  • Return Statement: Outputs the constant values 100 and 0, along with the normalized relative strength value RValue, which can be plotted on a chart to visualize the volatility bands.

This approach helps in visualizing how the current price’s relative strength compares to its historical volatility, scaled in a normalized manner.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/having-trouble-adding-volatility-bands-to-price-chart/#post-102594

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
Vonasi Master
V-oyaging ON A S-mall I-ncome
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...