atr_filter

This tool is designed as a visual filter for traders who want to understand the underlying volatility of a financial market. Rather than looking at price movement alone, it analyzes how much the price "swings" over a specific period to help smooth out market noise.

How the Logic Works

The script operates in two distinct stages to transform raw market data into a readable trend line:

1. Measuring Market Volatility (ATR) First, the tool looks at the Average True Range (ATR). This is a standard technical metric that calculates the average range of price movement over a set number of candles (defaulted to 34). Instead of telling you which direction the price is going, it tells you how much "distance" the price is traveling. High values indicate a turbulent market, while low values indicate a calmer one.

2. Smoothing the Data (Moving Average) Because raw volatility data can be jumpy and difficult to read, the script takes those results and applies a Moving Average calculation to them. By using a specific smoothing method (Smooth Moving Average), it filters out the minor "blips" and spikes, leaving behind a cleaner line that represents the consistent trend of the market's volatility.

What This Means for You

By viewing this indicator in a separate window on your chart, you are seeing a visual representation of the market's "heartbeat."

  • The Result: You get a continuous line that shows you whether the market's activity level is expanding or contracting over time.
  • The Benefit: This helps traders identify periods of high instability versus periods of consolidation, allowing for better-informed decisions on when the market is moving with strength and when it is simply reacting to minor fluctuations.
Indicators Used
Indicator of the average true rangeMoving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
atr_filter
//+------------------------------------------------------------------+
//|                                                   ATR_Filter.mq4 |
//+------------------------------------------------------------------+
//|                                                   ATR_Filter.mq4 |
//|                          Copyright 2014, Toptahlil Software Corp |
//|                                      Emial : Toptahlil@yahoo.com |
//+------------------------------------------------------------------+
#property description "feedbacks: https://login.mql5.com/en/users/toptahlil/feedbacks"
#property copyright  "post a job for me: http://www.mql5.com/en/job/new?prefered=toptahlil"
#property link      "Emial : Toptahlil@yahoo.com"
#property description      "Skype ID : Toptahlil"
#property description      "MQL5  ID : Toptahlil"
#property version   "1.0"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red


extern int ATR_Period=34;
extern int MA_Period=34;
extern  ENUM_MA_METHOD MA_Method =MODE_SMMA;
extern int MA_Shift=0;
double B1[], B2[], B3[];

//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

//---- drawing settings
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(0,B1);
   SetIndexBuffer(1,B2);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- indicator short name
   IndicatorShortName("ATR_Filter");
   ArraySetAsSeries(B1,true);
   ArraySetAsSeries(B2,true);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   int    pos=Bars-2;
   int i;   
   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
   for(i=0;i<Bars;i++)
      {
      B1[i] = iATR(Symbol(),Period(),ATR_Period,i);
      }
   for(i=0;i<Bars;i++)
      {
      
      B2[i]= iMAOnArray(B1,0,MA_Period,MA_Shift,MA_Method,i);
      }  
   return(0);
   }

//+------------------------------------------------------------------+

Comments