Author: Copyright � 2004, MetaQuotes Software Corp.
MTF MA

This tool is designed to help traders visualize long-term market trends by projecting high-level data onto their current trading screen. Its primary purpose is to simplify complex information by "translating" price movements from a larger timeframe (such as daily or weekly charts) into the smaller timeframe you are currently viewing.

Core Functionality

The script functions by calculating a Moving Average—a common technical indicator used to smooth out price fluctuations and identify the overall direction of a market. However, instead of looking only at the immediate prices on your current screen, this tool looks "ahead" at a much broader perspective.

Key Features & Logic

  • Multi-Timeframe Integration: The primary strength of this script is its ability to bridge different time scales. For example, if you are analyzing fast-paced minute-by-minute price movements, this tool can simultaneously display the trend of a 24-hour daily period. This allows you to see "the big picture" without constantly switching back and forth between different windows.
  • Customizable Smoothing: You can adjust how the tool interprets these large-scale trends. By changing the "Period," you determine how many previous data points are used to calculate the average, allowing for a balance between reacting quickly to new data or focusing on very stable, long-term trends.
  • Dynamic Labeling: To keep your workspace organized, the script automatically identifies itself based on the timeframe it is pulling from. It provides clear labels so you can instantly distinguish between different types of historical data being displayed on your chart.
  • Visual Consistency: The results are plotted as a continuous line on your main chart window. This provides a smooth visual path that helps traders identify whether the broader market sentiment is bullish, bearish, or neutral relative to their current trading position.

How It Benefits the User

By using this logic, a trader can avoid the common mistake of "getting lost in the noise." It ensures that every trade made on a small scale is aligned with the dominant trend of the larger market, providing a layer of context and confirmation that standard indicators might miss.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
MTF MA
//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                               by Hartono Setiono |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//---- input parameters
extern int MAPeriod=34;
extern int MATimeFrame=1440;
extern int MAMethod=1;
extern int MAShift=0;
extern int MAAppliedPrice=0;

//---- buffers
double MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(0,DRAW_LINE);

//---- name for DataWindow and indicator subwindow label
   switch(MATimeFrame)
   {
      case 1 : short_name="Period_M1"; break;
      case 5 : short_name="Period_M5"; break;
      case 15 : short_name="Period_M15"; break;
      case 30 : short_name="Period_M30"; break;
      case 60 : short_name="Period_H1"; break;
      case 240 : short_name="Period_H4"; break;
      case 1440 : short_name="Period_D1"; break;
      case 10080 : short_name="Period_W1"; break;
      case 43200 : short_name="Period_MN1"; break;
      default : {short_name="Current Timeframe"; MATimeFrame=0;}
   }
   short_name="MTF_MA("+short_name+", "+MAPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name+" - actual");
   SetIndexDrawBegin(0,MAPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
      y = iBarShift(NULL,MATimeFrame,Time[i]); 
      MABuffer[i]=iMA(NULL,MATimeFrame,MAPeriod,MAShift,MAMethod,MAAppliedPrice,y); 
   }
   return(0);
  
}

Comments