This script is designed as a sophisticated technical analysis tool for the MetaTrader platform. Its primary purpose is to provide traders with a multi-timeframe visualization of momentum and trend dynamics by combining several classic trading indicators into one unified display.
Core Functionality
The indicator acts as a "bridge." It allows you to view data from a higher time frame (such as an hourly chart) while simultaneously looking at a lower time frame (such as a 15-minute chart). This helps traders identify the broader market trend without losing sight of the immediate price action.
Key Components & Logic
The tool processes and displays several specific types of data:
- Momentum Tracking (MACD): The script calculates the Moving Average Convergence Divergence (MACD), which measures the strength, direction, and duration of a price trend. It highlights whether the market is accelerating or slowing down.
- Signal Smoothing: It incorporates a "Signal" line that helps filter out market noise, making it easier to identify reliable entry and exit points based on where momentum shifts.
- Custom Moving Averages: By utilizing specific "Fast" and "Slow" moving averages, the logic calculates the distance between short-term price action and long-term averages to determine trend direction.
- Visual Representation: The script organizes this data into different visual formats:
- Lines: Used to track smooth trends and continuous movements over time.
- Histograms: Used to provide a clear, vertical representation of momentum volume, making it easy to see at a glance when the market is gaining strength or losing steam.
How it Works for the Trader
Instead of manually switching between different charts to see what the "big picture" looks like, this script automatically pulls that higher-level data and overlays it onto your current view. It uses customizable settings—such as the specific speeds of the moving averages—allowing you to tailor the sensitivity of the signals to match your specific trading style.
In summary, it is a comprehensive trend-analysis dashboard that synchronizes multiple layers of market data into a single window for more informed decision-making.
//+-----------------------------------------------------------------------+
//| MTF_MACD_OsMA_L |
//| Copyright © 2007, SOK |
//| http://SOK.LiteForex.net |
//| www.metaquotes.net/ mtf / www.forex-tsd.com ik |
//+-----------------------------------------------------------------------+
#property copyright "Copyright © 2007, SOK"
#property link "http://sok.liteforex.net"
//----
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 LimeGreen
#property indicator_color2 Magenta
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Brown
#property indicator_width1 2
#property indicator_width2 2
//----
extern int TimeFrame=0;
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalSMA = 9;
extern int AplyingPrice = 0;
double ExtMapBuffer0[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer0);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer1);
//--
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, ExtMapBuffer2);
SetIndexStyle(3, DRAW_HISTOGRAM);
SetIndexBuffer(3, ExtMapBuffer3);
SetIndexStyle(4, DRAW_LINE);
SetIndexBuffer(4, ExtMapBuffer4);
//--
IndicatorShortName("MTF_OsMACD[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "]TF ("+TimeFrame+")");
//--
SetIndexLabel(0,"MTF_OsMACD,OsMA[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "]TF ("+TimeFrame+")");
SetIndexLabel(1,"MTF_OsMACD,OsMA[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "] TF ("+TimeFrame+")");
SetIndexLabel(2,"MTF_OsMACD,MACD[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "]TF ("+TimeFrame+")");
SetIndexLabel(3,"MTF_OsMACD,MACD[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "] TF ("+TimeFrame+")");
SetIndexLabel(3,"MTF_OsMACD,Signal,[" + FastEMA + ", " + SlowEMA + ", " +
SignalSMA + "] TF ("+TimeFrame+")");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator start function |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,shift,limit,y=0,counted_bars=IndicatorCounted();
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++;}
ExtMapBuffer0[i] = iCustom(NULL, TimeFrame, "MACD_OsMA_M",FastEMA, SlowEMA, SignalSMA,
AplyingPrice, 0,y);
ExtMapBuffer1[i] = iCustom(NULL, TimeFrame, "MACD_OsMA_M",FastEMA, SlowEMA, SignalSMA,
AplyingPrice, 1,y);
ExtMapBuffer2[i] = iCustom(NULL, TimeFrame, "MACD_OsMA_M",FastEMA, SlowEMA, SignalSMA,
AplyingPrice, 3,y);
ExtMapBuffer3[i] = iCustom(NULL, TimeFrame, "MACD_OsMA_M",FastEMA, SlowEMA, SignalSMA,
AplyingPrice, 4,y);
ExtMapBuffer4[i] = iCustom(NULL, TimeFrame, "MACD_OsMA_M",FastEMA, SlowEMA, SignalSMA,
AplyingPrice, 6,y);
}
return(0);
}
//+------------------------------------------------------------------+
Comments