Author: Copyright � 2007, MetaQuotes Software Corp.
#MTF NMO

This tool is designed to provide traders with a "Multi-Timeframe" (MTF) perspective, allowing you to visualize data from a larger time horizon directly on your current trading chart. Essentially, it acts as a bridge that pulls information from a higher timeframe—such as the Daily or Hourly view—and overlays it onto the smaller, more granular chart you are currently using.

Core Functionality

The primary logic of this script is to synchronize data across different scales of time. While most indicators only show you what is happening in the immediate present (the current candle), this script looks "upward" at a larger timeframe that you specify. By doing this, it helps traders identify broader trends and major movements that might be hidden when looking only at small price fluctuations.

How It Works

  • Timeframe Selection: You can choose specific timeframes (ranging from 1-minute intervals up to monthly views). The script then creates a dedicated visual map based on that selection.
  • Data Retrieval: The script automatically communicates with an underlying technical indicator (specifically the "NMA3"). It fetches four distinct data points from that external source and pulls them onto your current screen.
  • Visual Smoothing: Because a larger timeframe contains many smaller candles, the script performs a specific calculation to ensure the lines appear smooth and continuous. It maps the "history" of the larger timeframe to match the "ticks" of your current chart.
  • Real-Time Alignment (Step Logic): To prevent the data from looking jagged or disconnected, the script includes a specialized logic for when you are viewing a very small timeframe. If the higher timeframe hasn't "closed" yet, the script holds the last known value steady across all your current candles. This ensures the visual lines remain stable and readable until the next official update from the larger timeframe occurs.

Summary for the Trader

Instead of having to constantly switch back and forth between different tabs or windows to see the "big picture," this tool allows you to keep your eyes on one chart. It provides a multi-layered view where the higher-level trends are automatically blended into your current workspace, helping you stay aligned with the primary market direction while executing trades on smaller price movements.

15 Views
0 Downloads
0 Favorites
#MTF NMO
//+------------------------------------------------------------------+
//|                                                     #MTF_NMA.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
// MTF version coded by Chrisstoff
// Using Keris2112, CodersGuru, Raff and Igorad codes

#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_buffers 4
#property indicator_separate_window
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Green
#property indicator_color4 Yellow

extern int TimeFrame=60;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  SetIndexStyle (0,DRAW_LINE);
  SetIndexStyle (1,DRAW_LINE);
  SetIndexStyle (2,DRAW_LINE);
  SetIndexStyle (3, DRAW_LINE);

  SetIndexBuffer (0, ExtMapBuffer1);
  SetIndexBuffer (1, ExtMapBuffer2);
  SetIndexBuffer (2, ExtMapBuffer3);
  SetIndexBuffer (3, ExtMapBuffer4);

   switch(TimeFrame)
   {
     case 1 : string TimeFrameStr="Period_M1"; break;
     case 5 : TimeFrameStr="Period_M5"; break;
     case 15 : TimeFrameStr="Period_M15"; break;
     case 30 : TimeFrameStr="Period_M30"; break;
     case 60 : TimeFrameStr="Period_H1"; break;
     case 240 : TimeFrameStr="Period_H4"; break;
     case 1440 : TimeFrameStr="Period_D1"; break;
     case 10080 : TimeFrameStr="Period_W1"; break;
     case 43200 : TimeFrameStr="Period_MN1"; break;
     default : TimeFrameStr="Current Timeframe";
   } 
  
  string short_name = "MTF NMA";
  IndicatorShortName (short_name+" "+TimeFrameStr);
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars+TimeFrame/Period();
    
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
   
   ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"NMA3",0,y); 
   ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"NMA3",1,y); 
   ExtMapBuffer3[i]=iCustom(NULL,TimeFrame,"NMA3",2,y); 
   ExtMapBuffer4[i]=iCustom(NULL,TimeFrame,"NMA3",3,y);  
   }
//----
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
 /************************************************ by Raff   
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  

   ExtMapBuffer1[i]=ExtMapBuffer1[0]; 
   ExtMapBuffer2[i]=ExtMapBuffer2[0]; 
   ExtMapBuffer3[i]=ExtMapBuffer3[0]; 
   ExtMapBuffer4[i]=ExtMapBuffer4[0]; 

//----
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments