Friday, August 8, 2025

1. Introduction

Fractals are one of the classic tools introduced by legendary trader Bill Williams. These simple yet powerful markers are used to identify local swing highs and lows in price action. When used correctly, Fractals can help traders pinpoint reversal areas or breakout setups.

However, Fractals plotted on lower timeframes are often prone to noise and false signals. This is where the concept of multi-timeframe analysis becomes important.

The Fractals Multi-Timeframe Indicator for MT5 allows traders to overlay fractal signals from a higher timeframe directly onto the current chart. This provides cleaner, more reliable market structure references — without needing to constantly switch timeframes.

The Fractals Multi-Timeframe Indicator for MT5 (Fractals_MTF) Indicator for MetaTrader 5 provides directional signals from all 21 standard timeframes, ranging from M1 to MN1.

For each timeframe, it displays a directional arrow object (`OBJ_ARROW`) using Wingdings character 108:

🟢 Green arrow = upward ADX signal
🔴 Red arrow = downward ADX signal

After gathering these signals, the indicator calculates a consensus summary using a unique logic:
If the number of **up** signals is greater than **down + 1**, the indicator plots a larger **Wingdings 217** upward arrow * If the number of **down** signals is greater than **up + 1**, it plots a larger **Wingdings 218** downward arrow

This enables traders to view a high-confidence trend direction based on multi-timeframe Fractals indicator analysis directly on the main chart.

2. About This Indicator

The Fractals Multi-Timeframe Indicator for MT5 (Fractals_MTF) utilizes a template and displays a panel on the chart. Its function, operation, and usage are identical to the On Balance Volume Multi-Timeframe Indicator for MT5 (OBV_MTF) as detailed in the previous article. For a comprehensive guide on creating a multi-timeframe indicator, you can refer to the following resources: On Balance Volume Multi-Timeframe Indicator for MT5

3. Visual Example

Here is a sample chart showing the indicator in action:

NZDUSDH1_FRA_MTF

4. Key Features:

✅ 21-Timeframe Fractals Scanning
✅ Wingdings Arrows Overlay (per timeframe)
✅ Summary Arrow with Up/Down Consensus Calculation
✅ Color Customization for Each Signal
✅ Built-in Alerts (pop-up, email, mobile)
✅ Graphical Interface Panel for Timeframe Switching (via `OnChartEvent`)

Inputs and Parameters

| Input | Description |
| --------------- | ------------------------------------------ |
| `ArrowUp` | Color of up signal arrow |
| `ArrowDn` | Color of down signal arrow |
| `NTArrow` | Color of neutral arrow (default) |
| `f_model` | Font type for arrows (usually "Wingdings") |
| `alerts` | Enable/disable alert popups |
| `UseEmailAlert` | Enable email alerts |
| `UseSendnotify` | Enable push notification alerts |

Why Multi-Timeframe Fractals Matters?

Fractals are powerful in identifying **waves of price movement strength** but lack responsiveness in **trend consistency** across multiple timeframes. This custom Fractals_MTF indicator solved this:

📈 Confirm trading signals across all timeframes
⚠️ Avoid sideways or weak markets using visual confirmation
🚨 Detect strong breakouts supported by multiple timeframe trend directions

Using **all 21 timeframes** (from M1 to MN1) ensures broad trend consistency in your decision-making process.

5. Technical Overview: How the Indicator Works

Timeframe Management


   //---
   virtual void      Fractals_MTF_Config(void)
     {
      //--
      ENUM_TIMEFRAMES TFId[] = {PERIOD_M1, PERIOD_M2, ..., PERIOD_MN1};
      tfxar=ArraySize(TFIx);  // total 21 timeframes
      ArrayResize(TFId,tfxar,tfxar);
      ArrayCopy(TFId,TFIx,0,0,WHOLE_ARRAY);
      //--
      for(int x=0; x<tfxar; x++)
        hFRA[x]=iFractals(Symbol(),TFId[x]); // Handle of iFractals Indicator on each timeframe
      //--
      DeletedFRAObject();
      FRAMovementCalculation(25);
      PositionCore();
      //--
      if(display)
         DrawFRAObject();
      //---
     }
   //---
/*
Handles for all timeframe-specific Fractals  indicators are stored in `hFRA[]` and initialized inside `OnInit()` using `iFractals()` for each timeframe.
*/

Signal Extraction Logic

Each timeframe is scanned using:


   //---
   int FRADirectionScan(const ENUM_TIMEFRAMES stf,int shift) // Scan iFractals Direction
     {
      //--
      int ret=0;
      int rise=1,
          down=-1;
      //--
      int br=fbar;
      double res=0.0;
      UpdatePrice(stf);
      //--
      double FRAUp[];
      double FRADw[];
      ArrayResize(FRAUp,br,br);
      ArrayResize(FRADw,br,br);
      //--
      int xx=TFIndexArray(stf);
      CopyBuffer(hFRA[xx],0,0,br,FRAUp);
      CopyBuffer(hFRA[xx],1,0,br,FRADw);
      //--
      ArraySetAsSeries(FRAUp,true);
      ArraySetAsSeries(FRADw,true);
      //--
      int fup=br-1,
          fdw=br-1;
      //--
      for(int x=br-1; x>=0; x--)
        {
          if(FRAUp[x]!=EMPTY_VALUE) fup=x;
          if(FRADw[x]!=EMPTY_VALUE) fdw=x;
        }
      //--
      if(fdw<fup && fdw>shift) ret=rise; //
      if(fup<fdw && fup>shift) ret=down; // 
      //--
      return(ret);
      //---
     } //-end FRADirectionScan()
   //---

Consensus Calculation Logic.


   //---
   void FRAMovementCalculation(int barCnt) // Scan the direction of iFractals on each timeframe
     {
      //--
      ArrayResize(PowerMove,barCnt,barCnt);
      ArraySetAsSeries(PowerMove,true);
      //--
      for(int i=barCnt-1; i>=0; i--)
        {
         up=0;
         dw=0;
         //--
         for(int x=0; x<tfxar; x++)
           {
            Arwcolor[x]=NTArrow;
            PowerMove[i]=0.0;
            int PPM=FRADirectionScan(TFId[x],0);
            if(PPM>0)
              {
               up++;
               Arwcolor[x]=ArrowUp;
              }
            if(PPM<0)
              {
               dw++;
               Arwcolor[x]=ArrowDn;
              }
            if(x==tfxar-1)
              {
               if(up>dw+1)
                 {
                  PowerMove[i]=1.0;
                  TColor=ArrowUp;
                  curAlert=1;
                 }
               if(dw>up+1)
                 {
                  PowerMove[i]=-1.0;
                  TColor=ArrowDn;
                  curAlert=-1;
                 }
              }
           }
        }
      //--
      return;
      //---
     } //-end FRAMovementCalculation()
   //---
/*
This logic ensures that only dominant directional consensus (not slight differences) triggers a clear summary signal.
*/

Dynamic Timeframe Panel (OnChartEvent)

The indicator creates a clickable panel on the chart containing labels for all 21 timeframes. When a label (e.g., "H4") is clicked, the internal reference timeframe for analysis is updated.

This makes it easy for the user to interact with the indicator dynamically.


//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
//--- handling CHARTEVENT_CLICK event ("Clicking the chart")
   ResetLastError();
//--
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      //--- if "X" button is click
      if(sparam=="X")
        {
         mi.DeletedFRAObject();
         //--- unpress the button
         ObjectSetInteger(mi.CI,"X",OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,"X",OBJPROP_ZORDER,0);
         //--
         mi.display=false;
         ObjectDelete(mi.CI,"X");
         mi.DisplayPanelButton();
        }
      //--- if "cstar" button is click
      if(sparam==mi.cstar)
        {
         mi.DeletedFRAObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.cstar,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.cstar,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         if(mi.corpos==mi.posbot) ObjectDelete(mi.CI,mi.arbot);
         if(mi.corpos==mi.postop) ObjectDelete(mi.CI,mi.artop);
         mi.DrawFRAObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if "artop" button is click
      if(sparam==mi.artop)
        {
         mi.DeletedFRAObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.artop,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.artop,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         ObjectDelete(mi.CI,mi.artop);
         mi.PanelPosChange(mi.postop);
         //--
         ObjectDelete(mi.CI,"X");
         mi.DisplayButtonClick("arbot");
         mi.DrawFRAObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if "arbot" button is click
      if(sparam==mi.arbot)
        {
         mi.DeletedFRAObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.arbot,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.arbot,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         ObjectDelete(mi.CI,mi.arbot);
         mi.PanelPosChange(mi.posbot);
         //--
         ObjectDelete(mi.CI,"X");
         mi.DisplayButtonClick("artop");
         mi.DrawFRAObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if TF button is click
      //--
      if(sparam==mi.TFSc[0])
        {
         mi.ChangeChartSymbol(mi.TFSc[0],mi.TFId[0]);
        }
      //--
      if(sparam==mi.TFSc[1])
        {
         mi.ChangeChartSymbol(mi.TFSc[1],mi.TFId[1]);
        }
      //--
      if(sparam==mi.TFSc[2])
        {
         mi.ChangeChartSymbol(mi.TFSc[2],mi.TFId[2]);
        }
      //--
      if(sparam==mi.TFSc[3])
        {
         mi.ChangeChartSymbol(mi.TFSc[3],mi.TFId[3]);
        }
      //--
      if(sparam==mi.TFSc[4])
        {
         mi.ChangeChartSymbol(mi.TFSc[4],mi.TFId[4]);
        }
      //--
      if(sparam==mi.TFSc[5])
        {
         mi.ChangeChartSymbol(mi.TFSc[5],mi.TFId[5]);
        }
      //--
      if(sparam==mi.TFSc[6])
        {
         mi.ChangeChartSymbol(mi.TFSc[6],mi.TFId[6]);
        }
      //--
      if(sparam==mi.TFSc[7])
        {
         mi.ChangeChartSymbol(mi.TFSc[7],mi.TFId[7]);
        }
      //--
      if(sparam==mi.TFSc[8])
        {
         mi.ChangeChartSymbol(mi.TFSc[8],mi.TFId[8]);
        }
      //--
      if(sparam==mi.TFSc[9])
        {
         mi.ChangeChartSymbol(mi.TFSc[9],mi.TFId[9]);
        }
      //--
      if(sparam==mi.TFSc[10])
        {
         mi.ChangeChartSymbol(mi.TFSc[10],mi.TFId[10]);
        }
      //--
      if(sparam==mi.TFSc[11])
        {
         mi.ChangeChartSymbol(mi.TFSc[11],mi.TFId[11]);
        }
      //--
      if(sparam==mi.TFSc[12])
        {
         mi.ChangeChartSymbol(mi.TFSc[12],mi.TFId[12]);
        }
      //--
      if(sparam==mi.TFSc[13])
        {
         mi.ChangeChartSymbol(mi.TFSc[13],mi.TFId[13]);
        }
      //--
      if(sparam==mi.TFSc[14])
        {
         mi.ChangeChartSymbol(mi.TFSc[14],mi.TFId[14]);
        }
      //--
      if(sparam==mi.TFSc[15])
        {
         mi.ChangeChartSymbol(mi.TFSc[15],mi.TFId[15]);
        }
      //--
      if(sparam==mi.TFSc[16])
        {
         mi.ChangeChartSymbol(mi.TFSc[16],mi.TFId[16]);
        }
      //--
      if(sparam==mi.TFSc[17])
        {
         mi.ChangeChartSymbol(mi.TFSc[17],mi.TFId[17]);
        }
      //--
      if(sparam==mi.TFSc[18])
        {
         mi.ChangeChartSymbol(mi.TFSc[18],mi.TFId[18]);
        }
      //--
      if(sparam==mi.TFSc[19])
        {
         mi.ChangeChartSymbol(mi.TFSc[19],mi.TFId[19]);
        }
      //--
      if(sparam==mi.TFSc[20])
        {
         mi.ChangeChartSymbol(mi.TFSc[20],mi.TFId[20]);
        }
      //--
     }
//---
  } //-end OnChartEvent()
//---------//

How to Use

1. **Attach to Any Chart** (e.g., EURUSD H1)
2. **Adjust the Inputs**
3. **Observe Directional Arrows** per timeframe on your chart
4. **Watch Summary Signal Arrow** (center chart)
5. **Click Timeframe Labels** to change timeframe view instantly

6. Advantages and Limitations

Advantages:
- Adds structure to noisy lower timeframes
- Visual confirmation of support/resistance
- Doesn’t repaint once the fractal bar closes

⚠️ Limitations:
- Fractals do **repaint** until the full pattern forms (2 candles after center)
- May lag in fast-moving markets
- This limitation is overcome by using the multi-timeframe Fractal indicator.

7. Final Thoughts

The Fractals Multi-Timeframe Indicator for MT5 brings an edge to traders who rely on market structure. Whether you trade breakouts, reversals, or trends — having higher timeframe swing points in sight makes your chart more informative and actionable.

The Fractals Multi-Timeframe Indicator for MT5 offers a complete solution for traders who want to understand trend strength across all timeframes simultaneously. Using a unique formula that scans and weighs up/down movement across 21 timeframes, it delivers a summary arrow signal that simplifies complex data into an actionable visual and removes the multi-timeframe Fractal indicator limitation.

With features like dynamic chart interaction, visual arrows, alerts, and a lightweight design, this tool is ideal for discretionary and algorithmic traders alike.

Try it in your next trading session — and gain a clearer view of what the big players are watching.

We hope that this article and the Fractals_MTF or Fractals Multi-Timeframe Indicator for MT5 program will be useful for traders in learning and generating new ideas for trading, who can ultimately make money from home by trading forex.

Thanks for reading this article.

Please download the Fractals_MTF indicator: Fractals Multi-Timeframe Indicator for MT5

If you are subscribed to my YouTube Channel, and would like to receive the source program of this article, please send a request via the Contact Us form page, and I will send it to your email, source code: Fractals Multi-Timeframe Indicator for MT5

Don't forget to stop by and subscribe to Forex Home Experts YouTube Channel:

YouTube Channel: @ForexHomeExperts

YouTube Playlist: @ForexHomeExperts YouTube Playlist

Thursday, August 7, 2025

Introduction

The Average Directional Movement Index Multi-Timeframe (ADX MTF) Indicator for MetaTrader 5 provides directional signals from all 21 standard timeframes, ranging from M1 to MN1.

For each timeframe, it displays a directional arrow object (`OBJ_ARROW`) using Wingdings character 108:

🟢 Green arrow = upward ADX signal
🔴 Red arrow = downward ADX signal

After gathering these signals, the indicator calculates a consensus summary using a unique logic:
If the number of **up** signals is greater than **down + 1**, the indicator plots a larger **Wingdings 217** upward arrow * If the number of **down** signals is greater than **up + 1**, it plots a larger **Wingdings 218** downward arrow

This enables traders to view a high-confidence trend direction based on multi-timeframe ADX analysis directly on the main chart.

🔁 Note: All multi-timeframe indicators developed by Forex Home Expert use this exact signal logic structure.

The Average Directional Movement Index Multi-Timeframe indicator for MT5 (ADX_MTF) utilizes a template and displays a panel on the chart. Its function, operation, and usage are identical to the Strength of Price Movement Multi Timeframe indicator (SPM_MTF) as detailed in the previous article. For a comprehensive guide on creating a multi-timeframe indicator, you can refer to the following resources: Strength of Price Movement Multi Timeframe indicator for MT5

Average Directional Movement Index Multi-Timeframe indicator for MT5

Key Features:

✅ 21-Timeframe Directional ADX Scanning
✅ Wingdings Arrows Overlay (per timeframe)
✅ Summary Arrow with Up/Down Consensus Calculation
✅ Color Customization for Each Signal
✅ Built-in Alerts (pop-up, email, mobile)
✅ Graphical Interface Panel for Timeframe Switching (via `OnChartEvent`)

Inputs and Parameters

| Input | Description | | --------------- | ------------------------------------------ |
| `BarCalc` | Bars used for ADX signal scan |
| `ArrowUp` | Color of up signal arrow |
| `ArrowDn` | Color of down signal arrow |
| `NTArrow` | Color of neutral arrow (default) |
| `f_model` | Font type for arrows (usually "Wingdings") |
| `alerts` | Enable/disable alert popups |
| `UseEmailAlert` | Enable email alerts |
| `UseSendnotify` | Enable push notification alerts |

Why Multi-Timeframe ADX Matters?

The ADX is powerful for identifying **trend strength** but lacks insight into **trend consistency** across timeframes. This custom ADX_MTF indicator solves that:

📈 Confirm short-term trades with long-term trend backing
⚠️ Avoid sideways or weak markets using visual confirmation
🚨 Detect powerful breakouts supported by multiple timeframe trends

Using **all 21 timeframes** (from M1 to MN1) ensures broad trend consistency in your decision-making process.

Technical Overview: How the Indicator Works

Timeframe Management

The indicator prepares and manages handles for all standard MT5 timeframes:


ENUM_TIMEFRAMES TFId[] = {PERIOD_M1, PERIOD_M2, ..., PERIOD_MN1};
int tfxar = ArraySize(TFId);  // total 21 timeframes
/* Handles for all timeframe-specific ADX indicators are stored in `hADXp[]` and initialized inside `OnInit()` using `iADX()` for each timeframe. */

Signal Extraction Logic

Each timeframe is scanned using:


   //---
   int ADXDirectionScan(const ENUM_TIMEFRAMES stf,int shift) // Scan ADX Direction
     {
      //--
      int ret=0;
      int rise=1,
          down=-1;
      //--
      int br=shift+2;
      double res=0.0;
      UpdatePrice(stf);
      //--
      double ADXp[];
      ArrayResize(ADXp,br,br);
      ArraySetAsSeries(ADXp,true);
      //--
      int xx=TFIndexArray(stf);
      CopyBuffer(hADXp[xx],1,0,br,ADXp); // We will use ADX indicator buffer for DI+
      //--
      if(ADXp[shift]&gt;ADXp[shift+1]) ret=rise;
      if(ADXp[shift]&lt;ADXp[shift+1]) ret=down;
      //--
      return(ret);
      //---
     } //-end ADXDirectionScan()
   //---
   
/*
This compares DI+ values (buffer 1) to detect rising or falling strength.
*/

Consensus Calculation Logic.


   //---
   void ADXMovementCalculation(int barCnt) // Scan the direction of iADX on each timeframe
     {
      //--
      ArrayResize(PowerMove,barCnt,barCnt);
      ArraySetAsSeries(PowerMove,true);
      //--
      for(int i=barCnt-1; i>=0; i--)
        {
         up=0;
         dw=0;
         //--
         for(int x=0; x<tfxar; x++)
           {
            Arwcolor[x]=NTArrow;
            PowerMove[i]=0.0;
            int PPM=ADXDirectionScan(TFId[x],0);
            if(PPM>0)
              {
               up++;
               Arwcolor[x]=ArrowUp;
              }
            if(PPM<0)
              {
               dw++;
               Arwcolor[x]=ArrowDn;
              }
            if(x==tfxar-1)
              {
               if(up>dw+1)
                 {
                  PowerMove[i]=1.0;
                  TColor=ArrowUp;
                  curAlert=1;
                 }
               if(dw>up+1)
                 {
                  PowerMove[i]=-1.0;
                  TColor=ArrowDn;
                  curAlert=-1;
                 }
              }
           }
        }
      //--
      return;
      //---
     } //-end ADXMovementCalculation()
   //---

/*
This logic ensures that only dominant directional consensus (not slight differences) triggers a clear summary signal.
*/

Dynamic Timeframe Panel (OnChartEvent)

The indicator creates a clickable panel on the chart containing labels for all 21 timeframes. When a label (e.g., "H4") is clicked, the internal reference timeframe for analysis is updated.

This makes it easy for the user to interact with the indicator dynamically.


void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
//--- handling CHARTEVENT_CLICK event ("Clicking the chart")
   ResetLastError();
//--
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      //--- if "X" button is click
      if(sparam=="X")
        {
         mi.DeletedADXObject();
         //--- unpress the button
         ObjectSetInteger(mi.CI,"X",OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,"X",OBJPROP_ZORDER,0);
         //--
         mi.display=false;
         ObjectDelete(mi.CI,"X");
         mi.DisplayPanelButton();
        }
      //--- if "cstar" button is click
      if(sparam==mi.cstar)
        {
         mi.DeletedADXObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.cstar,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.cstar,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         if(mi.corpos==mi.posbot) ObjectDelete(mi.CI,mi.arbot);
         if(mi.corpos==mi.postop) ObjectDelete(mi.CI,mi.artop);
         mi.DrawADXObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if "artop" button is click
      if(sparam==mi.artop)
        {
         mi.DeletedADXObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.artop,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.artop,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         ObjectDelete(mi.CI,mi.artop);
         mi.PanelPosChange(mi.postop);
         //--
         ObjectDelete(mi.CI,"X");
         mi.DisplayButtonClick("arbot");
         mi.DrawADXObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if "arbot" button is click
      if(sparam==mi.arbot)
        {
         mi.DeletedADXObject();
         mi.DisplayPanelButton();
         //--- unpress the button
         ObjectSetInteger(mi.CI,mi.arbot,OBJPROP_STATE,false);
         ObjectSetInteger(mi.CI,mi.arbot,OBJPROP_ZORDER,0);
         if(!mi.display)
            mi.display=true;
         ObjectDelete(mi.CI,mi.arbot);
         mi.PanelPosChange(mi.posbot);
         //--
         ObjectDelete(mi.CI,"X");
         mi.DisplayButtonClick("artop");
         mi.DrawADXObject();
         //--
         ChartRedraw(mi.CI);
        }
      //--- if TF button is click
      //--
      if(sparam==mi.TFSc[0])
        {
         mi.ChangeChartSymbol(mi.TFSc[0],mi.TFId[0]);
        }
      //--
      if(sparam==mi.TFSc[1])
        {
         mi.ChangeChartSymbol(mi.TFSc[1],mi.TFId[1]);
        }
      //--
      if(sparam==mi.TFSc[2])
        {
         mi.ChangeChartSymbol(mi.TFSc[2],mi.TFId[2]);
        }
      //--
      if(sparam==mi.TFSc[3])
        {
         mi.ChangeChartSymbol(mi.TFSc[3],mi.TFId[3]);
        }
      //--
      if(sparam==mi.TFSc[4])
        {
         mi.ChangeChartSymbol(mi.TFSc[4],mi.TFId[4]);
        }
      //--
      if(sparam==mi.TFSc[5])
        {
         mi.ChangeChartSymbol(mi.TFSc[5],mi.TFId[5]);
        }
      //--
      if(sparam==mi.TFSc[6])
        {
         mi.ChangeChartSymbol(mi.TFSc[6],mi.TFId[6]);
        }
      //--
      if(sparam==mi.TFSc[7])
        {
         mi.ChangeChartSymbol(mi.TFSc[7],mi.TFId[7]);
        }
      //--
      if(sparam==mi.TFSc[8])
        {
         mi.ChangeChartSymbol(mi.TFSc[8],mi.TFId[8]);
        }
      //--
      if(sparam==mi.TFSc[9])
        {
         mi.ChangeChartSymbol(mi.TFSc[9],mi.TFId[9]);
        }
      //--
      if(sparam==mi.TFSc[10])
        {
         mi.ChangeChartSymbol(mi.TFSc[10],mi.TFId[10]);
        }
      //--
      if(sparam==mi.TFSc[11])
        {
         mi.ChangeChartSymbol(mi.TFSc[11],mi.TFId[11]);
        }
      //--
      if(sparam==mi.TFSc[12])
        {
         mi.ChangeChartSymbol(mi.TFSc[12],mi.TFId[12]);
        }
      //--
      if(sparam==mi.TFSc[13])
        {
         mi.ChangeChartSymbol(mi.TFSc[13],mi.TFId[13]);
        }
      //--
      if(sparam==mi.TFSc[14])
        {
         mi.ChangeChartSymbol(mi.TFSc[14],mi.TFId[14]);
        }
      //--
      if(sparam==mi.TFSc[15])
        {
         mi.ChangeChartSymbol(mi.TFSc[15],mi.TFId[15]);
        }
      //--
      if(sparam==mi.TFSc[16])
        {
         mi.ChangeChartSymbol(mi.TFSc[16],mi.TFId[16]);
        }
      //--
      if(sparam==mi.TFSc[17])
        {
         mi.ChangeChartSymbol(mi.TFSc[17],mi.TFId[17]);
        }
      //--
      if(sparam==mi.TFSc[18])
        {
         mi.ChangeChartSymbol(mi.TFSc[18],mi.TFId[18]);
        }
      //--
      if(sparam==mi.TFSc[19])
        {
         mi.ChangeChartSymbol(mi.TFSc[19],mi.TFId[19]);
        }
      //--
      if(sparam==mi.TFSc[20])
        {
         mi.ChangeChartSymbol(mi.TFSc[20],mi.TFId[20]);
        }
      //--
     }
//---
  } //-end OnChartEvent()
//---------//

How to Use

1. **Attach to Any Chart** (e.g., EURUSD H1)
2. **Adjust the Inputs**
3. **Observe Directional Arrows** per timeframe on your chart
4. **Watch Summary Signal Arrow** (center chart)
5. **Click Timeframe Labels** to change timeframe view instantly

Frequently Asked Questions (FAQ)

**Q1: What makes this ADX MTF indicator different from the built-in ADX in MetaTrader 5?**
**A1:** The built-in ADX only analyzes the current chart timeframe. This ADX MTF indicator scans and displays directional strength across **21 timeframes**, giving you a full-spectrum view of the market’s trend dynamics. It also features consensus-based summary signals and interactive controls.

**Q2: What do the green and red arrows mean on the chart?**
**A2:**
**Green arrow** (Wingdings 108): Indicates that ADX is rising (positive DI > previous value) on that specific timeframe
**Red arrow** (Wingdings 108): Indicates ADX is falling (trend weakening)
The **large green (217)** or **red (218)** summary arrow shows dominant direction when more than one timeframe agrees

**Q3: How is the final summary signal calculated?**
**A3:** The indicator loops through all timeframes and counts up and down signals.
** If `up > down + 1`, it plots a large **up arrow** (Wingdings 217)
** If `down > up + 1`, it plots a **down arrow** (Wingdings 218)
** If neither, no summary arrow is drawn

**Q4: Can I change the timeframe used for analysis dynamically?**
**A4:** Yes. The indicator includes an interactive panel with all 21 timeframes (M1 to MN1). Just click on any label (like “H4” or “D1”) to switch the analysis source without reattaching the indicator. This is handled via the `OnChartEvent()` function in MQL5.

**Q5: Is this indicator repainting?**
**A5:** No. The indicator uses `CopyBuffer()` with proper indexing and does **not repaint** past signals. All calculations are based on closed candles and historical values.

**Q6: What symbols or assets can I use this on?**
**A6:** This indicator works with all MT5 instruments:
* Forex pairs (e.g., EURUSD, GBPJPY)
* Indices (e.g., DAX, S&P 500)
* Commodities (e.g., gold, oil)
* Crypto (e.g., BTCUSD)

**Q7: Does this indicator send alerts?**
**A7:** Yes. It supports:
* Popup alerts
* Email alerts
* Push notifications
These can be toggled on/off in the input settings.

**Q8: Can this be used inside Expert Advisors (EAs)?**
**A8:** While this is a custom visual indicator, its signal logic can be adapted into EAs. You may extract the consensus signal via `PowerMove[]` or implement a similar formula directly in your EA code.

**Q9: Can I use this for scalping or only for swing trading?**
**A9:** It’s suitable for **both**. Scalpers can confirm short-term moves with higher timeframe trends. Swing traders benefit from trend strength alignment across D1, H4, etc.

**Q10: Do I need to install any external libraries to use it?**
**A10:** No. Just download the `.ex5` file, place it in `MQL5/Indicators`, and run.

Conclusion

The **ADX Multi-Timeframe Indicator for MT5** offers a complete solution for traders who want to understand trend strength across all timeframes simultaneously. Using a unique formula that scans and weighs up/down movement across 21 timeframes, it delivers a summary arrow signal that simplifies complex data into an actionable visual.

With features like dynamic chart interaction, visual arrows, alerts, and a lightweight design, this tool is ideal for discretionary and algorithmic traders alike.

We hope that this article and the ADX_MTF or Average Directional Movement Index Multi-Timeframe Indicator for MT5 program will be useful for traders in learning and generating new ideas for trading, who can ultimately make money from home by trading forex.

Thanks for reading this article.

Please download the ADX_MTF indicator: Average Directional Movement Index Multi-Timeframe Indicator

If you are subscribed to my YouTube Channel, and would like to receive the source program of this article, please send a request via the Contact Us form page, and I will send it to your email, source code: Average Directional Movement Index Multi-Timeframe Indicator for MT5

Don't forget to stop by and subscribe to Forex Home Experts YouTube Channel:

YouTube Channel: @ForexHomeExperts

YouTube Playlist: @ForexHomeExperts YouTube Playlist

Friday, January 24, 2025

In this article, I will discuss the creation of the On Balance Volume Multi Timeframe indicator for MT5. This indicator will calculate the comparison of OBV movements in percentage terms across 21 different timeframes, ranging from M1 to MN1.

The On Balance Volume Multi-Timeframe indicator for MT5 (OBV_MTF) utilizes a template and displays a panel on the chart. Its function, operation, and usage are identical to the Strength of Price Movement Multi Timeframe indicator (SPM_MTF) as detailed in the previous article. For a comprehensive guide on creating a multi-timeframe indicator, you can refer to the following resources: Strength of Price Movement Multi Timeframe indicator for MT5

Introduction of On-Balance Volume Multi-Time Frame (OBV_MTF) Indicator

The primary function of the On-Balance Volume Multi-Time Frame (OBV_MTF) indicator is to enhance the traditional On-Balance Volume (OBV) indicator by incorporating analysis across multiple time frames. This approach offers a more comprehensive view of market trends and volume dynamics.

USDCHFH1_OBV_MTF

Key Components and Functions:

  • 1. Volume Analysis: The OBV_MTF indicator utilizes trading volume as a critical parameter. By adding the volume on up days and subtracting the volume on down days, it creates a cumulative total that helps identify the strength of price movements.
  • 2. Multi-Time Frame Analysis: Unlike the traditional OBV, which operates on a single time frame, the OBV_MTF indicator aggregates volume data from multiple time frames. This broader perspective allows traders to detect longer-term trends that might be overlooked when only considering one time frame.
  • 3. Trend Confirmation: The OBV_MTF indicator aids in confirming trends by comparing OBV values across different time frames. A rising OBV across multiple time frames typically indicates strong buying pressure, while a falling OBV suggests selling pressure.
  • 4. Divergence Detection: The OBV_MTF indicator can identify divergences between price movements and volume. For instance, if prices are rising but OBV is falling across multiple time frames, it could signal a potential reversal.
  • 5. Customizable Parameters: This indicator often includes customizable settings, allowing traders to adjust time frames and other parameters to fit their trading strategies and preferences.
  • 6. Visual Representation: The OBV_MTF indicator provides visual cues, such as arrows and colors, to highlight significant changes in volume and trends, making it easier for traders to interpret the data.
  • 7. Buffering and Storage: It maintains buffers for open, high, low, close prices, and tickvolume data. It also keeps track of time and various display settings to ensure accurate and timely updates.

Before explaining the differences between the SPM_MTF indicator and the OBV_MTF indicator, it is important to note that all functions for running this multi-timeframe indicator are managed by the class program for the MTF indicator, which is contained in the MTF_Indi class.

Class for MTF indicator:


//+------------------------------------------------------------------+
//| class for MTF indicator                                          |
//+------------------------------------------------------------------+
class MTF_Indi
  {
   //---
   public:
   //--
   int               fbar;
   int               star,
                     tstar,
                     bstar;
   int               TNamex,
                     TNamexn,
                     TNamey1,
                     TNamey2,
                     TNamey3,
                     TNamey1n,
                     TNamey2n,
                     TNamey3n;
   int               tfxar;
   int               up,dw;
   int               tfhalf;
   int               maxbar;
   int               ttlbars;
   int               scaleX,
                     scaleA,
                     scaleY,
                     horizL1,
                     horizL2,
                     horizL3,
                     horizL4,
                     horizL5,
                     horizL6,
                     vertiL1,
                     vertiL2,
                     vertiL3,
                     vertiL4,
                     vertiL5,
                     vertiL6,
                     offsetX,
                     offsetY,
                     fontSize,
                     windchar,
                     windsize;
   int               corx,
                     cory,
                     txttf;
   int               curmin,
                     prvmin;
   int               corpos;
   int               pospos,
                     postop,
                     posbot;
   int               curAlert;
   int               prvAlert;
   //--
   long              CI;
   string            posisi,
                     sigpos,
                     indname,
                     msgText,
                     ObjName;
   string            cstar,
                     artop,
                     arbot;
   string            hName1,
                     hName2,
                     hName3;
   string            font_mode;
   bool              display;
   double            OPEN[],
                     HIGH[],
                     LOW[],
                     CLOSE[];
   long              VOLUME[];
   datetime          TIME[];
   datetime          cbartime;
   //--
   int               year,  // Year
                     mon,   // Month
                     day,   // Day
                     hour,  // Hour
                     min,   // Minutes
                     sec,   // Seconds
                     dow,   // Day of week (0-Sunday, 1-Monday, ... ,6-Saturday)
                     doy;   // Day number of the year (January 1st is assigned the number value of zero)
   //---- buffers
   double            PowerMove[];
   string            TFSc[];
   color             Arwcolor[];
   color             TColor;
   ENUM_TIMEFRAMES   TFId[];
   ENUM_BASE_CORNER  bcor;
   ENUM_ANCHOR_POINT ancp;
   //---
   //---
   //- Constructor
                     MTF_Indi(void):
                     year(0),
                     mon(1),
                     day(2),
                     hour(3),
                     min(4),
                     sec(5),
                     dow(6),
                     doy(7),
                     fbar(125),
                     star(181),
                     maxbar(3),
                     pospos(0),
                     postop(0),
                     posbot(1),
                     tstar(217),
                     bstar(218),
                     tfhalf(11),
                     scaleX(35),
                     scaleA(36),
                     scaleY(50),
                     offsetY(18),
                     offsetX(120),
                     fontSize(7),
                     cbartime(0),
                     posisi(""),
                     sigpos(""),
                     msgText(""),
                     curAlert(0),
                     prvAlert(0),
                     ttlbars(125),
                     windsize(12),
                     windchar(108),
                     CI(ChartID()),
                     display(false),
                     ObjName("OBV_"),
                     font_mode(FontsModel(f_model)),
                     cstar(CharToString((uchar)star)),
                     artop(CharToString((uchar)tstar)),
                     arbot(CharToString((uchar)bstar)),
                     indname(MQLInfoString(MQL_PROGRAM_NAME))
     {
     }
   //---
   //- Destructor
                    ~MTF_Indi(void)
     {
     }
   //---

Code Explanation of the MTF_Indi Class:

  • Class Definition:
    • The MTF_Indi class is designed to handle the Multi-Time Frame (MTF) indicator for trading analysis. This class encapsulates various properties and methods that are essential for analyzing and displaying trading data across multiple time frames.
  • Public Members:
    • The class defines numerous public member variables for storing values such as chart coordinates, alert settings, font details, and indicator data buffers. These variables are used throughout the class methods to perform various indicator functions.
  • Key Components and Functions:
    • 1. Public Data Members:
      • fbar: An integer representing the function bar for analysis.
      • star, tstar, bstar: Integers representing specific chart arrow or markers.
      • TNamex, TNamexn, TNamey1, TNamey2, TNamey3, TNamey1n, TNamey2n, TNamey3n: Integers for naming conventions and chart positions.
      • tfxar: An integer for time frame-related calculations.
      • up, dw: Integers for tracking upward and downward movements.
      • tfhalf: An integer representing the midpoint of a time frame.
      • maxbar: An integer for the maximum number of bars considered.
      • ttlbars: An integer for the total number of bars.
      • scaleX, scaleA, scaleY: Integers for scaling the chart in different dimensions.
      • horizL1, horizL2, horizL3, horizL4, horizL5, horizL6: Integers for horizontal line positions.
      • vertiL1, vertiL2, vertiL3, vertiL4, vertiL5, vertiL6: Integers for vertical line positions.
      • offsetX, offsetY: Integers for positional offsets.
      • fontSize: An integer for the font size used in chart displays.
      • windchar, windsize: Integers related to window characteristics.
      • corx, cory: Integers for x and y coordinates.
      • txttf: An integer for text time frame.
    • 2. Time and Alert Variables:
      • curmin, prvmin: Integers for current and previous minutes.
      • corpos: An integer for core position.
      • pospos, postop, posbot: Integers for positional tracking.
      • curAlert, prvAlert: Integers for current and previous alert states.
      • year, mon, day, hour, min, sec, dow, doy: Integers representing date and time components.
    • 3. String Members:
      • posisi, sigpos, indname, msgText, ObjName, cstar, artop, arbot, hName1, hName2, hName3, font_mode: Strings for various naming conventions, messages, and display texts.
    • 4. Boolean Member:
      • display: A boolean flag indicating whether the display is active.
    • 5. Data Buffers:
      • OPEN[], HIGH[], LOW[], CLOSE[]: Arrays for storing open, high, low, and close prices.
      • VOLUME[]: An array for storing trading volume data.
      • TIME[]: An array for storing time data.
      • cbartime: A datetime variable for bar time tracking.
      • PowerMove[]: An array for storing calculated power move values.
      • TFSc[]: An array for storing time frame string components.
      • Arwcolor[]: An array for storing arrow colors.
      • TColor: A variable for text color.
    • 6. Enumerations:
      • TFId[]: An array of enumeration type ENUM_TIMEFRAMES for different time frames.
      • bcor: An enumeration of type ENUM_BASE_CORNER for base corner positions.
      • ancp: An enumeration of type ENUM_ANCHOR_POINT for anchor points.
    • 7. Constructor: The constructor initializes the member variables with default values, ensuring that the indicator is set up correctly when instantiated.
      • MTF_Indi(void): The constructor initializes the class members with default values.
    • 8. Destructor: The destructor is defined but currently does not perform any specific actions.
      • ~MTF_Indi(void): The destructor is provided to clean up resources when the object is destroyed.

    As I explained above, the differences between the On Balance Volume Multi-Timeframe indicator (OBV_MTF) and the Strength of Price Movement Multi Timeframe indicator (SPM_MTF) lie in two key functions:

    1. UpdatePrice(ENUM_TIMEFRAMES xtf):

    • In the SPM_MTF indicator program, the UpdatePrice(ENUM_TIMEFRAMES xtf) function does not perform a TickVolume update because it is not necessary.

    2. OBVDirectionScan(const ENUM_TIMEFRAMES stf, int shift):

    • The SPM_MTF indicator program uses the PriceStrengthScan(const ENUM_TIMEFRAMES stf, int shift) function, which scans the price and compares the current bar's price to the previous bar's price in percentage terms.
    • Conversely, the OBV_MTF indicator scans the movement of the OBV value on the current bar and compares it with the OBV value on the previous bar in percentage terms.

    Additionally, the value of the On Balance Volume indicator in the OBV_MTF indicator is not obtained using the Indicator Handle. Instead, the structure and code of the On Balance Volume indicator only use the closing price plus or minus TickVolume, allowing the OBV indicator code to be easily written directly into the OBVDirectionScan() function.

    Explanation of the UpdatePrice() Function in the SPM_MTF Indicator.

    The UpdatePrice() function in the Strength of Price Movement Multi Timeframe (SPM_MTF) indicator is designed to update price data across various timeframes. Below is a detailed breakdown of each step within this function:

    
       //---
       void              UpdatePrice(ENUM_TIMEFRAMES xtf)
         {
          //-- Clear existing arrays
          ArrayFree(OPEN);
          ArrayFree(HIGH);
          ArrayFree(LOW);
          ArrayFree(CLOSE);
          ArrayFree(TIME);
          //-- Resize arrays
          ArrayResize(OPEN,maxbar,maxbar);
          ArrayResize(HIGH,maxbar,maxbar);
          ArrayResize(LOW,maxbar,maxbar);
          ArrayResize(CLOSE,maxbar,maxbar);
          ArrayResize(TIME,maxbar,maxbar);
          //-- Set arrays as series
          ArraySetAsSeries(OPEN,true);
          ArraySetAsSeries(HIGH,true);
          ArraySetAsSeries(LOW,true);
          ArraySetAsSeries(CLOSE,true);
          ArraySetAsSeries(TIME,true);
          //-- Initialize arrays
          ArrayInitialize(OPEN,0.0);
          ArrayInitialize(HIGH,0.0);
          ArrayInitialize(LOW,0.0);
          ArrayInitialize(CLOSE,0.0);
          ArrayInitialize(TIME,0);
          //-- Calculate the number of bars based on the timeframe
          int barx=PeriodSeconds(xtf)/60*maxbar;
          RefreshPrice(PERIOD_M1,maxbar);
          RefreshPrice(xtf,barx);
          //-- Copy price data from the specified symbol and timeframe
          int co=CopyOpen(Symbol(),xtf,0,maxbar,OPEN);
          int ch=CopyHigh(Symbol(),xtf,0,maxbar,HIGH);
          int cl=CopyLow(Symbol(),xtf,0,maxbar,LOW);
          int cc=CopyClose(Symbol(),xtf,0,maxbar,CLOSE);
          int ct=CopyTime(Symbol(),xtf,0,maxbar,TIME);
          //--
          return;
          //---
         } //-end UpdatePrice()
       //---
    

    Steps in the UpdatePrice() Function in the SPM_MTF Indicator:

    • 1. Clear Existing Arrays:
      • The ArrayFree() function is used to clear the existing data in the OPEN, HIGH, LOW, CLOSE, and TIME arrays.
    • 2. Resize Arrays:
      • ArrayResize() function adjusts the size of these arrays based on the maximum number of bars (maxbar).
    • 3, Set Arrays as Series:
      • ArraySetAsSeries() sets the arrays as series, meaning that the most recent element is at index 0.
    • 4. Initialize Arrays:
      • ArrayInitialize() initializes the array values. The initial values are set to 0.0 for prices and 0 for time.
    • 5. Calculate the Number of Bars:
      • int barx = PeriodSeconds(xtf) / 60 * maxbar; calculates the number of bars required based on the specified timeframe (xtf).
    • 6. Refresh Price Data:
      • RefreshPrice(PERIOD_M1, maxbar); and RefreshPrice(xtf, barx); refresh the price data for the M1 timeframe and the specified timeframe.
    • 7. Copy Price Data:
      • CopyOpen(), CopyHigh(), CopyLow(), CopyClose(), and CopyTime() functions copy the open, high, low, close, and time data into their respective arrays.

    This function helps update and manage price data for further analysis across multiple timeframes without the need for TickVolume updates, as they are not relevant to the SPM_MTF indicator.

    Explanation of the UpdatePrice() Function in the OBV_MTF Indicator.

    The UpdatePrice() function in the On Balance Volume Multi-Timeframe (OBV_MTF) indicator is designed to update price and TickVolume data across various timeframes. Below is a detailed breakdown of each step within this function:

    
       //---
       void              UpdatePrice(ENUM_TIMEFRAMES xtf)
         {
          maxbar=fbar;
          //-- Clear existing arrays
          ArrayFree(OPEN);
          ArrayFree(HIGH);
          ArrayFree(LOW);
          ArrayFree(CLOSE);
          ArrayFree(TIME);
          ArrayFree(VOLUME);
          //-- Resize arrays
          ArrayResize(OPEN,maxbar,maxbar);
          ArrayResize(HIGH,maxbar,maxbar);
          ArrayResize(LOW,maxbar,maxbar);
          ArrayResize(CLOSE,maxbar,maxbar);
          ArrayResize(TIME,maxbar,maxbar);
          ArrayResize(VOLUME,maxbar,maxbar);
          //-- Set arrays as series
          ArraySetAsSeries(OPEN,true);
          ArraySetAsSeries(HIGH,true);
          ArraySetAsSeries(LOW,true);
          ArraySetAsSeries(CLOSE,true);
          ArraySetAsSeries(TIME,true);
          ArraySetAsSeries(VOLUME,true);
          //-- Initialize arrays
          ArrayInitialize(OPEN,0.0);
          ArrayInitialize(HIGH,0.0);
          ArrayInitialize(LOW,0.0);
          ArrayInitialize(CLOSE,0.0);
          ArrayInitialize(TIME,0);
          ArrayInitialize(VOLUME,0);
          //-- Calculate the number of bars based on the timeframe
          int barx=PeriodSeconds(xtf)/60*maxbar;
          RefreshPrice(PERIOD_M1,maxbar);
          RefreshPrice(xtf,barx);
          //-- Copy price and TickVolume data from the specified symbol and timeframe
          int co=CopyOpen(Symbol(),xtf,0,maxbar,OPEN);
          int ch=CopyHigh(Symbol(),xtf,0,maxbar,HIGH);
          int cl=CopyLow(Symbol(),xtf,0,maxbar,LOW);
          int cc=CopyClose(Symbol(),xtf,0,maxbar,CLOSE);
          int ct=CopyTime(Symbol(),xtf,0,maxbar,TIME);
          int cv=CopyTickVolume(Symbol(),xtf,0,maxbar,VOLUME);
          //--
          return;
          //---
         } //-end UpdatePrice()
       //---
    

    Steps in the UpdatePrice() Function in the OBV_MTF Indicator:

    • 1. Set Maximum Bars:
      • maxbar = fbar; sets the maximum number of bars to be processed.
    • 2. Clear Existing Arrays:
      • The ArrayFree() function is used to clear the existing data in the OPEN, HIGH, LOW, CLOSE, TIME, and VOLUME arrays.
    • 3. Resize Arrays:
      • ArrayResize() adjusts the size of these arrays based on the maximum number of bars (maxbar).
    • 4. Set Arrays as Series:
      • ArraySetAsSeries() sets the arrays as series, meaning that the most recent element is at index 0.
    • 5. Initialize Arrays:
      • ArrayInitialize() initializes the array values. The initial values are set to 0.0 for prices and TickVolume, and 0 for time.
    • 6. Calculate the Number of Bars:
      • int barx = PeriodSeconds(xtf) / 60 * maxbar; calculates the number of bars required based on the specified timeframe (xtf).
    • 7. Refresh Price Data:
      • RefreshPrice(PERIOD_M1, maxbar); and RefreshPrice(xtf, barx); refresh the price data for the M1 timeframe and the specified timeframe.
    • 8. Copy Price and TickVolume Data:
      • CopyOpen(), CopyHigh(), CopyLow(), CopyClose(), CopyTime(), and CopyTickVolume() is functions copy the open, high, low, close, time, and TickVolume data into their respective arrays.

    Explanation of the PriceStrengthScan() Function in the SPM_MTF Indicator.

    The PriceStrengthScan() function in the Strength of Price Movement Multi Timeframe (SPM_MTF) indicator is designed to scan and compare price data to determine the direction of price movement in percentage terms. Below is a detailed breakdown of each step within this function:

    
    //---
       int               PriceStrengthScan(const ENUM_TIMEFRAMES stf,int shift) // Price Bar Direction in percent
         {
          //-- Initialize return value and direction indicators
          int ret=0;
          int rise=1,
              down=-1;
          //-- Set the number of bars to be scanned
          int br=shift+2;
          double res=0.0;
          double move=0.0;
          //-- Update price data for the specified timeframe
          UpdatePrice(stf);
          //-- Declare and resize the close price array
          double CL[];
          ArrayResize(CL,br,br);
          ArraySetAsSeries(CL,true);
          //-- Populate the close price array with data
          for(int x=br-1; x>=shift; x--)
             CL[x]=CLOSE[x];
          //-- Get the current and previous close prices
          double close_now  = CL[shift];
          double close_prev = CL[shift+1];
          //-- Calculate the percentage change in close prices
          if((close_now==0 || close_now==EMPTY_VALUE) || (close_prev==0 || close_prev==EMPTY_VALUE))
             res=0.0;
          else
             res=NormalizeDouble((close_now / close_prev * 100) - 100,3);
          //-- Adjust the result for percentage comparison
          res=NormalizeDouble(res*100,3); // because its value less than 1 then multiplied with 100.
          //-- Determine the direction of price movement
          if(res>move)
             ret=rise;
          if(res<move)
             ret=down;
          //--
          return(ret);
          //---
         } //-end PriceStrengthScan()
       //---
    

    Steps in the PriceStrengthScan() Function in the SPM_MTF Indicator:

    • 1. Initialization:
      • Initialize the return value (ret) to 0.
      • Define constants for rising and falling prices (rise and down).
    • 2. Set the Number of Bars to Scan:
      • Calculate the number of bars to scan (br) based on the shift parameter.
    • 3. Update Price Data:
      • Call the UpdatePrice(stf) function to update the price data for the specified timeframe (stf).
    • 4.Declare and Resize the Close Price Array:
      • Declare the CL array to store close prices.
      • Resize the CL array to accommodate the number of bars (br) and set it as a series.
    • 5. Populate the Close Price Array:
      • Use a loop to populate the CL array with close prices from the CLOSE array.
    • 6. Get the Current and Previous Close Prices:
      • Retrieve the current close price (close_now) and the previous close price (close_prev) from the CL array.
    • 7. Calculate the Percentage Change in Close Prices:
      • If either close_now or close_prev is 0 or empty, set res to 0.0.
      • Otherwise, calculate the percentage change in close prices and normalize the result.
    • 8. Adjust the Result for Percentage Comparison:
      • Multiply the result by 100 to adjust for percentage comparison.
    • 9. Determine the Direction of Price Movement:
      • Compare the result (res) with move to determine if the price is rising or falling.
      • Set the return value (ret) accordingly.

    This function helps determine the direction and strength of price movement by analyzing the percentage change in close prices across different timeframes.

    Explanation of the OBVDirectionScan() Function in the OBV_MTF Indicator.

    The OBVDirectionScan() function in the On Balance Volume Multi-Timeframe (OBV_MTF) indicator is designed to scan and compare the OBV values to determine the direction of OBV movement in percentage terms. Below is a detailed breakdown of each step within this function:

    
    //---
       int               OBVDirectionScan(const ENUM_TIMEFRAMES stf,int shift) // Scan OBV Direction
         {
          //-- Initialize return value and direction indicators
          int ret=0;
          int rise=1,
              down=-1;
          //-- Set the number of bars to be scanned
          int br=shift+2;
          double res=0.0;
          double move=0.0;
          //-- Update price data for the specified timeframe
          UpdatePrice(stf);
          //-- Declare and resize the OBV array
          double OBV[];
          ArrayResize(OBV,br,br);
          ArraySetAsSeries(OBV,true);
          //-- Retrieve volume and close prices
          double vol=(double)VOLUME[shift];
          double prev_close=CLOSE[shift+1];
          double curr_close=CLOSE[shift];
          //--- Fill OBV Buffer
          if(curr_close<prev_close)
             OBV[shift]=OBV[shift+1]-vol;
          else
            {
             if(curr_close>prev_close)
                OBV[shift]=OBV[shift+1]+vol;
             else
                OBV[shift]=OBV[shift+1];
            }
          //-- Get the current and previous OBV values
          double close_now  = OBV[shift];
          double close_prev = OBV[shift+1];
          //-- Calculate the percentage change in OBV values
          if((close_now==0 || close_now==EMPTY_VALUE) || (close_prev==0 || close_prev==EMPTY_VALUE))
             res=0.0;
          else
             res=NormalizeDouble((close_now / close_prev * 100) - 100,3);
          //-- Adjust the result for percentage comparison
          res=NormalizeDouble(res*100,3); // because its value less than 1 then multiplied with 100.
          //-- Determine the direction of OBV movement
          if(res>move)
             ret=rise;
          if(res<move)
             ret=down;
          //--
          return(ret);
          //---
         } //-end OBVDirectionScan()
       //---
    

    Steps in the OBVDirectionScan() Function in the OBV_MTF Indicator:

    • 1. Initialization:
      • Initialize the return value (ret) to 0.
      • Define constants for rising and falling OBV (rise and down).
    • 2. Set the Number of Bars to Scan:
      • Calculate the number of bars to scan (br) based on the shift parameter.
    • 3. Update Price Data:
      • Call the UpdatePrice(stf) function to update the price data for the specified timeframe (stf).
    • 4. Declare and Resize the OBV Array:
      • Declare the OBV array to store OBV values.
      • Resize the OBV array to accommodate the number of bars (br) and set it as a series.
    • 5. Retrieve Volume and Close Prices:
      • Get the volume (vol), previous close price (prev_close), and current close price (curr_close) from their respective arrays.
    • 6. Fill OBV Buffer:
      • Calculate the OBV value for the current bar based on the comparison of curr_close and prev_close.
      • Update the OBV array with the calculated OBV value.
    • 7. Get the Current and Previous OBV Values:
      • Retrieve the current OBV value (close_now) and the previous OBV value (close_prev) from the OBV array.
    • 8. Calculate the Percentage Change in OBV Values:
      • If either close_now or close_prev is 0 or empty, set res to 0.0.
      • Otherwise, calculate the percentage change in OBV values and normalize the result.
    • 9. Adjust the Result for Percentage Comparison:
      • Multiply the result by 100 to adjust for percentage comparison.
    • 10. Determine the Direction of OBV Movement:
      • Compare the result (res) with move to determine if the OBV is rising or falling.
      • Set the return value (ret) accordingly.

    This function helps determine the direction and strength of OBV movement by analyzing the percentage change in OBV values across different timeframes.

    The On Balance Volume Multi-Timeframe (OBV_MTF) indicator is designed for MetaTrader 5 (MT5). It calculates the strength of price movement as a percentage on each timeframe bar, assisting traders in analyzing market trends and making informed trading decisions.

    Key Functions of the OBV_MTF Indicator:

    • 1. Displays Multiple Timeframes: Allows traders to view various timeframes on a single chart, enhancing their ability to analyze market movements effectively.
    • 2. Identifies Market Trends: By viewing the indicator across multiple timeframes, traders can more easily identify both larger and smaller market trends.
    • 3. Supports Trading Decisions: Assists traders in making informed decisions on entering or exiting trades based on observed market conditions across different timeframes.

    Detailed Breakdown of Functions:

    • 1. OBV_MTF_Config(): Configures the multi-timeframe settings and prepares the indicator for use.
    • 2. PositionCore(): Sets up core position settings for the indicator elements on the chart.
    • 3. DrawOBVObject(): Draws various elements of the indicator on the chart.
    • 4. PanelPosChange(int inpos): Changes the panel position based on the input position value.
    • 5. UpdatePrice(ENUM_TIMEFRAMES xtf): Updates price data, including TickVolume arrays, for a given timeframe.
    • 6. RefreshPrice(ENUM_TIMEFRAMES xtf, int bars): Refreshes price data for a given timeframe and a specified number of bars.
    • 7. OBVDirectionScan(const ENUM_TIMEFRAMES stf, int shift): Scans and calculates the direction of the OBV indicator value in percentage terms.
    • 8. OBVMovementCalculation(int barCnt): Scans the direction of OBV indicator value for each timeframe, calculates how much it has moved up or down, and compares them to determine the signal strength.
    • 9. ThisTime(const int reqmode): Retrieves current time information based on the requested mode.
    • 10. Do_Alerts(string msg): Generates various types of alerts (print, alert, email, and notification) based on the provided message.
    • 11. FontsModel(int mode): Returns the font name based on the input mode.
    • 12. ChangeChartSymbol(string tf_name, ENUM_TIMEFRAMES stf): Changes the chart symbol and timeframe based on the input parameters.
    • 13. DisplayPanelButton(): Displays panel buttons on the chart.
    • 14. DisplayButtonClick(string actreq): Handles the creation and display of various buttons on the chart.
    • 15. DeletedOBVObject(): Deletes all objects related to the OBV_MTF indicator from the chart.
    • 16. strTF(ENUM_TIMEFRAMES period): Converts timeframe enumerations to string representations.
    • 17. getUninitReasonText(int reasonCode): Provides descriptive reasons for the uninitialization of the Expert Advisor (EA) based on the given reason code.
    • 18. WS(int width): Calculates the width scaling factor for buttons based on screen DPI.
    • 19. CreateButtonClick(): Creates a clickable button on the chart with specified properties.
    • 20. CreateArrowLabel(): Creates an arrow label on the chart with specified properties.
    • 21. CreateButtonTemplate(): Creates a rectangular button on the chart with specified properties.

    Main Functions of the Program:

    • 1. OnInit(): Initializes the custom indicator, configuring indicator buffers and setting indicator properties.
    • 2. OnDeinit(const int reason): Deinitializes the custom indicator, cleans up indicator objects, and prints the reason for deinitialization.
    • 3. OnCalculate(): Handles the main calculations for the indicator on every price tick, including scanning price strength and generating alerts.
    • 4. OnChartEvent(): Handles chart events, particularly button clicks, to manage the indicator's display and settings.

    Summary

    The OBV_MTF indicator is a comprehensive tool that provides traders with valuable insights into price movements across multiple timeframes. Its various functions ensure an enhanced trading experience by configuring, updating, and displaying the indicator's elements effectively. This helps traders identify market trends and make well-informed trading decisions.

    We hope that this article and the OBV_MTF or On Balance Volume Multi Timeframe indicator for MT5 program will be useful for traders in learning and generating new ideas, who can ultimately make money from home by trading forex.

    Thanks for reading this article.

    Please download the OBV_MTF indicator: On Balance Volume Multi Timeframe indicator

    If you are subscribed to my YouTube Channel, and would like to receive the source program of this article, please send a request via the Contact Us form page, and I will send it to your email, source code: On Balance Volume Multi Timeframe indicator

    Don't forget to stop by and subscribe to Forex Home Experts YouTube Channel:

    YouTube Channel: @ForexHomeExperts

    YouTube Playlist: @ForexHomeExperts YouTube Playlist

Featured Post

How to create a simple Multi-Currency Expert Advisor using MQL5 with Zigzag and RSI Indicators Signal

Introduction The Expert Advisor discussed in this article is a multi-currency trading robot that uses the Zigzag and RSI indicators. It fol...