Ichi_Tenkan_Kijun_MTF
Download scriptThis script is designed to provide traders with a high-level overview of market trends by utilizing two core components of the Ichimoku Cloud technical analysis system: the Tenkan-sen and the Kijun-sen.
Core Functionality
The primary purpose of this tool is "Multi-Timeframe" (MTF) analysis. While most standard indicators only show data based on the specific chart timeframe you are currently viewing (e.g., a 5-minute chart), this script allows you to overlay data from much larger timeframes—such as Hourly, Daily, or Weekly charts—directly onto your current smaller timeframe. This helps traders see the "big picture" trends without having to constantly switch back and forth between different windows.
How the Logic Works
The script performs several key operations to translate complex data into visual lines on your screen:
- Timeframe Synchronization: The tool takes a larger time period (which you choose in the settings) and calculates where its price points sit relative to your current view. It then maps those high-level values onto your immediate chart, ensuring the lines move smoothly and align correctly with the current price action.
- Dynamic Calculation: It specifically pulls the Tenkan-sen (a shorter-term trend line) and the Kijun-sen (a medium-term trend line). By calculating these from a higher timeframe, it filters out "market noise" and highlights the dominant momentum of the market.
- Visual Offsetting: The script includes logic to handle "shifts." Depending on your preference, it can place the lines exactly where they occur in time or shift them forward/backward to ensure they align perfectly with the historical bars on your chart.
- Labeling and Identification: To ensure the chart remains readable, the script automatically generates custom labels. It identifies each line by its specific settings (the number of periods used) and clearly states which timeframe the data is being pulled from (e.g., "H1" for Hourly or "D1" for Daily).
Practical Use for Traders
By using this logic, a trader can identify if the current price movement aligns with the broader market trend. For example, even if the price looks volatile on a 1-minute chart, these lines will reveal whether the underlying daily trend is bullish (upward) or bearish (downward), providing a more stable foundation for making trading decisions.
//+------------------------------------------------------------------+
//| Tenkan Kijun mtf |
//+------------------------------------------------------------------+
//2008forextsd ki
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Maroon
#property indicator_color2 Blue
#property indicator_width2 2
extern int Tenkan=9;
extern int Kijun=26;
extern int Tenkan_Shift=0;
extern int Kijun_Shift =0;
extern bool TKShiftToZero =true;
extern int TimeFrame=0;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------
int init()
{
SetIndexBuffer (0,ExtMapBuffer1); SetIndexBuffer (1,ExtMapBuffer2);
SetIndexStyle (0,DRAW_LINE); SetIndexStyle (1,DRAW_LINE);
SetIndexDrawBegin (0,Kijun); SetIndexDrawBegin (1,Kijun);
TimeFrame =MathMax(TimeFrame, Period());
if (TKShiftToZero)
{
SetIndexShift (0,0); SetIndexShift (1,0);
}
else
{
SetIndexShift (0,Tenkan_Shift*TimeFrame/Period());
SetIndexShift (1,Kijun_Shift*TimeFrame/Period());
}
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1"; break;
case 5 : TimeFrameStr="M5"; break;
case 15 : TimeFrameStr="M15"; break;
case 30 : TimeFrameStr="M30"; break;
case 60 : TimeFrameStr="H1"; break;
case 240 : TimeFrameStr="H4"; break;
case 1440 : TimeFrameStr="D1"; break;
case 10080 : TimeFrameStr="W1"; break;
case 43200 : TimeFrameStr="MN"; break;
default : TimeFrameStr="TF0";
}
SetIndexLabel(0,"Tenkan ("+Tenkan+") "+TimeFrameStr +" ");
SetIndexLabel(1,"Kijun ("+Kijun+") "+TimeFrameStr +" ");
IndicatorShortName("Ichi Tenkan Kijun ("+Tenkan+","+Kijun+") ["+TimeFrameStr +"]");
return(0);
}
//+----------
int start()
{
datetime TimeArray[];
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
int i,y,limit,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
limit = MathMax (limit,TimeFrame/Period());
for(i=0,y=0; i<limit; i++)
{
if (Time[i]<TimeArray[y]) y++;
ExtMapBuffer1[i] = iIchimoku(NULL, TimeFrame, Tenkan, Kijun, 52, MODE_TENKANSEN, y);
ExtMapBuffer2[i] = iIchimoku(NULL, TimeFrame, Tenkan, Kijun, 52, MODE_KIJUNSEN, y);
}
return(0);
}
//+-----------
Comments