WIchimokuChikou
Download scriptThis technical tool is designed for traders using the MetaTrader platform to visualize specific components of the Ichimoku Cloud, a popular Japanesecharting technique used to identify trends and potential reversal points. Specifically, this script focuses on plotting the "Chikou Span" (also known as the Lagging Span), which provides a historical perspective by projecting past price data into the current chart area.
Core Functionality
The primary purpose of this script is to display two distinct versions of the Chikou Span simultaneously, allowing users to compare different time horizons or sensitivity levels on a single screen. It automates the calculation of these lines so that they appear accurately based on the mathematical requirements of the Ichimoku system.
Key Logic Components
- Dual Visualization Modes: The script includes a toggle system (ViewType) that allows you to choose how much information you want displayed. Depending on your selection, the tool can show a single standard line, a second secondary line, or both simultaneously.
- Dynamic Calculation Parameters: The logic utilizes two different sets of "periods" (numerical values used to calculate averages).
- The first set uses standard settings to provide a baseline view of recent price action relative to the past.
- The second set uses significantly larger numbers, which creates a "slower" line that reflects broader, long-term market trends.
- Safety Buffers: To ensure the chart remains clean and readable, the script contains built-in logic that prevents these lines from appearing in areas where there isn't enough historical data to make a valid calculation. It essentially tells the software: "If we don't have enough past candles to calculate this accurately, do not draw anything."
- Visual Distinction: The script distinguishes between the two types of lines using different colors (White and Yellow) and labels them clearly in the data window, making it easy for a trader to identify which line represents short-term momentum versus long-term trends.
How it Benefits the User
By providing both the standard and an extended Chikou Span on one chart, this tool helps traders see "the big picture." It allows you to observe how current price action relates not just to very recent history, but to deeper historical cycles, helping to confirm whether a current move is part of a minor fluctuation or a major trend shift.
//+------------------------------------------------------------------+
//| WIchimokuChikou.mq4 |
//| Copyright 2010.11.25 M.Sasaki |
//| http://youtarou.blogzine.jp |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010.11.25 M.Sasaki"
#property link "http://youtarou.blogzine.jp"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Yellow
// buffers ichimoku
double buffChikou[];
double buffChikou2[];
// parameters ichimoku
extern int tenkan_k = 9;
extern int kijun_k = 26;
extern int senkou_k = 52;
extern int tenkan_k2 = 51;
extern int kijun_k2 = 101;
extern int senkou_k2 = 151;
// View option
extern int ViewType = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Set Buffers
SetIndexBuffer(0, buffChikou);
SetIndexBuffer(1, buffChikou2);
// Set Style
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
// Set Label
SetIndexLabel(0, "Chikou");
SetIndexLabel(1, "Chikou 2");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars;
for(int i=limit-1; i>=0; i--)
{
// Ichimoku
if( ViewType == 1 || ViewType == 3 )
{
if( i >= kijun_k ){
buffChikou[i] = iIchimoku(NULL, 0, tenkan_k, kijun_k, senkou_k, MODE_CHINKOUSPAN, i);
}else
buffChikou[i] = EMPTY_VALUE;
}
else
buffChikou[i] = EMPTY_VALUE;
}
for(i = limit-1; i>=0; i--)
{
// Ichimoku 2
if( ViewType == 2 || ViewType == 3 )
{
if( i >= kijun_k2 ){
buffChikou2[i] = iIchimoku(NULL, 0, tenkan_k2, kijun_k2, senkou_k2, MODE_CHINKOUSPAN, i);
}else
buffChikou2[i] = EMPTY_VALUE;
}
else
buffChikou2[i] = EMPTY_VALUE;
}
return(0);
}
//+------------------------------------------------------------------+
Comments