Attachments forums

List of attachments posted on this forum.


All files on forums: 160999

Re: Volatility Indicators for MT4

mrtools, Thu Dec 09, 2021 7:13 am

whiplashtm wrote: Tue Dec 07, 2021 4:42 am Hi, is it possible to update directional volatility with the option to use the latest averages and prices? And would it be possible to "replace" the stdev calculation with mladens EMA deviation calclulation, and/or give the option to choose different averages for the deviation aswell (it's using SMA as standard). It would've been nice to have the indicator showing up on the entire charthistory aswell (probably because of the extcountbars code?).

Much appreciated. Take care.
Directional Volatility

Cleaned up the code and changed to Mladen's ema deviation and added the averages to the calculations.

What is the Directional Volatility indicator?

This indicator, known as Directional Volatility, utilizes the principles of volatility analysis through the application of standard deviations and moving averages. The primary objective is to compute a volatility measure and display it in the form of two separate lines, which signify upward (Long) and downward (Short) volatility trends.

The indicator works on price data, specifically the closing, high, and low prices, and is designed to be displayed in a separate window beneath the main chart.

Key concepts
  • The indicator calculates a directional volatility measure for both upward and downward movements based on price changes.
  • The volatility is determined using the difference between the closing price and the high/low prices, smoothed with exponential moving averages (EMA).
  • The indicator generates two lines: one for the Long volatility (representing upward price movement) and another for the Short volatility (representing downward price movement).
Calculation
  • The algorithm starts by calculating the differences between the closing price and low price (for Long) and between the high price and the closing price (for Short) for each bar.
  • These differences are smoothed using an Exponential Moving Average over the specified period.
  • Then, the standard deviation of the smoothed values is calculated using a Simple Moving Average for volatility.
  • Finally, the volatility is adjusted by multiplying the standard deviation with the Deviation parameter, and the values are stored in the Long[] and Short[] buffers.
  • Final values are divided by Point to adjust them to the market's price scale.
This MQL4 code, in essence, computes volatility by analyzing price variations derived from high, low, and close values, which are then smoothed using Exponential Moving Averages. It employs standard deviation for scaling purposes and displays two distinct lines that represent directional volatility in a separate window.
All files in topic