Author: Copyright � 2010, basisforex@gmail.com
MA_Support

This technical indicator is designed to provide traders with a comprehensive visual overview of market trends across multiple timeframes simultaneously on a single chart. Instead of requiring a user to switch back and forth between different minutes, hours, and days to analyze price action, this tool aggregates that data into one view.

Core Functionality

The primary purpose of the script is to calculate and display "Moving Averages" (a common method used to smooth out price fluctuations) for eight different timeframes at once:

  • 1-Minute (M1)
  • 5-Minutes (M5)
  • 15-Minutes (M15)
  • 30-Minutes (M30)
  • 1-Hour (H1)
  • 4-Hours (H4)
  • Daily (D1)
  • Monthly (Mn)

How It Works

The tool functions by pulling historical data from all these different timeframes and projecting them onto your current active chart. Specifically:

  • Multi-Timeframe Synchronization: It calculates the average price for each timeframe (from 1 minute to monthly) and maps them as distinct lines. This allows you to see if short-term price movements are aligning with broader, long-term trends.
  • Visual Differentiation: Each timeframe is assigned a unique color and label. This ensures that even though there are many lines on the screen, you can easily distinguish between a 1-hour trend and a Daily trend based on their specific colors.
  • Timeframe Constraint: The script includes a built-in validation check. It is specifically configured to operate most effectively when your main chart is set to the 1-Minute (M1) timeframe. If you attempt to run it on other periods, the tool will notify you via an on-screen message that the incorrect period is selected.
  • Dynamic Calculation: The script automatically handles the math required to scale the time data. For example, it adjusts the calculation for a 4-hour average so that it aligns correctly with the 1-minute bars you are currently viewing, ensuring the lines appear smooth and accurate.

Practical Use

By using this indicator, a trader can instantly see "confluence." If the lines for the M5, H1, and D1 timeframes are all moving in the same direction, it suggests a very strong trend is in place across all levels of market activity. Conversely, if the lines are crossing each other frequently, it may indicate a period of high volatility or indecision in the market.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
MA_Support
/*------------------------------------------------------------------+
 |                                                   MA_Support.mq4 |
 |                                                 Copyright © 2010 |
 |                                             basisforex@gmail.com |
 +------------------------------------------------------------------*/
#property copyright "Copyright © 2010, basisforex@gmail.com"
#property link      "basisforex@gmail.com"
//----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 White
#property indicator_color2 Yellow
#property indicator_color3 Orange
#property indicator_color4 Red
#property indicator_color5 Brown
#property indicator_color6 Green
#property indicator_color7 Blue
#property indicator_color8 Black
//----
extern int M1Period  = 13;
extern int M5Period  = 13;
extern int M15Period = 13;
extern int M30Period  = 13;
extern int H1Period  = 13;
extern int H4Period  = 13;
extern int D1Period  = 13;
extern int MnPeriod  = 13;
extern int MaShift   = 0;
extern int MODE_Ma   = 3;
extern int PRICE_Ma  = 6;
//----
double M1Buffer[];
double M5Buffer[];
double M15Buffer[];
double M30Buffer[];
double H1Buffer[];
double H4Buffer[];
double D1Buffer[];
double MnBuffer[];
//+------------------------------------------------------------------+
int init()
 {
   SetIndexShift(0, MaShift);
   SetIndexShift(1, MaShift);
   SetIndexShift(2, MaShift);
   SetIndexShift(3, MaShift);
   SetIndexShift(4, MaShift);
   SetIndexShift(5, MaShift);
   SetIndexShift(6, MaShift);
   SetIndexShift(7, MaShift);
//----
   SetIndexBuffer(0, M1Buffer);
   SetIndexBuffer(1, M5Buffer);
   SetIndexBuffer(2, M15Buffer);
   SetIndexBuffer(3, M30Buffer);
   SetIndexBuffer(4, H1Buffer);
   SetIndexBuffer(5, H4Buffer);
   SetIndexBuffer(6, D1Buffer);
   SetIndexBuffer(7, MnBuffer);
//----
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexStyle(6, DRAW_LINE);
   SetIndexStyle(7, DRAW_LINE);
//----
   SetIndexLabel(0, "M1");
   SetIndexLabel(1, "M5");
   SetIndexLabel(2, "M15");
   SetIndexLabel(3, "M30");
   SetIndexLabel(4, "H1");
   SetIndexLabel(5, "H4");
   SetIndexLabel(6, "D1");
   SetIndexLabel(7, "Mn");
//----
   return(0);
 }
//+------------------------------------------------------------------+
int start()
 {
   Comment("                                                                                                                                              HAPPY BIRTHDAY, DIMA!");  
   if (Period() != 1)
    {
		Comment("Not a right Period!!! It should be M5");
		return(0);	
	 }
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   for(int i = 0; i < limit; i++)
    {
      M1Buffer[i]  = iMA(NULL, PERIOD_M1, M1Period, 0, MODE_Ma, PRICE_Ma, i);
      M5Buffer[i]  = iMA(NULL, PERIOD_M5, M5Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_M5);
      M15Buffer[i] = iMA(NULL, PERIOD_M15, M15Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_M15);
      M30Buffer[i] = iMA(NULL, PERIOD_M30, M30Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_M30);
      H1Buffer[i]  = iMA(NULL, PERIOD_H1, M30Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_H1);
      H4Buffer[i]  = iMA(NULL, PERIOD_H4, H1Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_H4);
      D1Buffer[i]  = iMA(NULL, PERIOD_D1, D1Period, 0, MODE_Ma, PRICE_Ma, i / PERIOD_D1);
      MnBuffer[i]  = iMA(NULL, PERIOD_MN1, MnPeriod, 0, MODE_Ma, PRICE_Ma, i / PERIOD_MN1);
    }  
   //-----
   return(0);
 }
//+------------------------------------------------------------------+

Comments