This tool is designed to help traders visualize market trends by overlaying data from different timeframes onto their current chart. Essentially, it acts as a "bridge" that allows you to see high-level market movements without having to constantly switch back and forth between different viewing modes.
Core Functionality
The primary purpose of this script is to display specific moving average data from a higher timeframe (for example, looking at Daily trends while staying on a 15-minute chart) directly within a separate window. By doing this, it helps traders identify the "big picture" momentum while they are making granular decisions on smaller price movements.
How the Logic Works
- Multi-Timeframe Synchronization: The script takes data from a different period—which you can choose in the settings—and maps it accurately to the current time shown on your screen. It ensures that the information you see corresponds correctly to the current moment in time.
- Dual Data Tracking: It tracks two distinct lines simultaneously (represented in Red and Blue). These lines represent the specific outputs of a "Mirror" moving average calculation from another timeframe.
- Dynamic Translation: The script includes a built-in translator that automatically identifies which timeframe you have selected (such as M15, H1, Daily, etc.) and labels the indicator clearly so you always know which timeframe's data you are viewing.
- Validation: To ensure accuracy, the tool includes a safety check. It verifies that the timeframe you want to view is equal to or greater than your current chart timeframe, preventing logical errors in the data visualization.
Practical Use for Traders
By using this logic, a trader can see if the broader market trend aligns with the immediate price action. If the high-level "Mirror" lines are moving in one direction while the current price is moving in another, it provides a visual cue about potential trend reversals or significant resistance levels that might not be visible on a smaller timeframe alone.
#property copyright "Kalenzo"
#property link "contact@fxservice.eu"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_color2 Blue
#property indicator_width2 1
extern double MovingPeriod = 20;
extern double MovingShift = 0;
extern int TimeFrame = 0;
double tab1[];
double tab2[];
int limit;
int i;
int ii;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if(TimeFrame!=0 && TimeFrame<Period()) Alert("TF SHOULD BE >= CURRENT");
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(0,tab1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(1,tab2);
IndicatorShortName("MA_Mirror MTF "+ tfTranslator(TimeFrame)+" by Kalenzo");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
limit = (Bars-counted_bars)-1;
for(i=limit; i>=0;i--)
{
int ibs = iBarShift(Symbol(),TimeFrame,Time[i]);
tab1[i] = iCustom(Symbol(),TimeFrame,"MA_Mirror",MovingPeriod,MovingShift,0,ibs);
tab2[i] = iCustom(Symbol(),TimeFrame,"MA_Mirror",MovingPeriod,MovingShift,1,ibs);
}
//----
return(0);
}
//+------------------------------------------------------------------+
string tfTranslator(int tf)
{
if(tf == 0) tf = Period();
switch(tf)
{
case PERIOD_M1: return("M1");
case PERIOD_M5: return("M5");
case PERIOD_M15: return("M15");
case PERIOD_M30: return("M30");
case PERIOD_H1: return("H1");
case PERIOD_H4: return("H4");
case PERIOD_D1: return("Daily");
case PERIOD_W1: return("Weekly");
case PERIOD_MN1: return("Monthly");
default: return("UNRECOGNIZED");
}
}
Comments