This script is designed as a technical analysis tool for the MetaTrader 4 platform, specifically created to identify market trends and potential price movements using a specialized variation of the "Taichi" logic. It translates complex Japanese Ichimoku cloud calculations into a visual signal system that helps traders determine whether the current market momentum is bullish, bearish, or neutral.
Core Logic Overview
The script functions by gathering multiple layers of data from the Ichimoku indicator—a popular trend-following system—and blending them to create a custom "Taichi" baseline. Instead of looking at these components individually, the script averages four specific Ichimoku variables: the Tenkan-sen, Kijun-sen, Senkou Span A, and Senkou Span B.
By averaging these four elements, the tool produces a smoother, more balanced representation of the market's price action, filtering out some of the "noise" typically found in standard technical indicators.
Trend Identification System
The script performs three primary calculations to determine the market state:
- Baseline Generation: It calculates the average Taichi value and compares it against a secondary moving average (the Signal line) and a third, slower-moving average (the SSignal line).
- Trend Detection: The tool evaluates the relationship between these lines to assign one of three states:
- Bullish (Up): When the Taichi baseline is above the Signal line, and the Signal line is also positioned above the secondary reference points, the script identifies an upward trend.
- Bearish (Down): Conversely, if the Taichi baseline falls below the Signal line while the Signal line remains below its reference point, a downward trend is identified.
- Neutral/Equilibrium: If neither of the above conditions is met, the script identifies a state of equilibrium or consolidation.
Visual Representation and Notifications
To make this data easy for a user to read at a glance, the script provides three distinct visual elements:
- Color-Coded Histograms: The indicator uses specific colors (Dark Green, Maroon, and Dark Goldenrod) to represent different market conditions visually in a separate window. This allows traders to see "blocks" of trend history instantly.
- Automated Alerts: The script can be configured to send real-time notifications. When the logic detects a shift from neutral to bullish or bearish, it can trigger an on-screen alert or a specific sound file.
- Dynamic Context: The script automatically identifies the current timeframe (e.g., M15, H1, D1) and includes this information in its alerts, ensuring the trader knows exactly which chart context the signal is originating from.
In summary, this tool acts as a filter that simplifies high-level Ichimoku data into clear, color-coded signals, helping traders stay informed about the prevailing market direction without needing to manually interpret multiple overlapping lines.
//+------------------------------------------------------------------+
//| Cronex Taichi Bars.mq4 |
//| Adapted by CJA |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Cronex Taichi.mq4 |
//| Copyright © 2007, Cronex. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Cronex"
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color5 DarkGreen
#property indicator_color6 Maroon
#property indicator_color7 DarkGoldenrod
#property indicator_width5 2
#property indicator_width6 2
#property indicator_width7 2
//---- indicator parameters
extern int Tenkan=9;
extern int Kijun=26;
extern int Senkou=52;
extern int FlatSE=7;
extern bool AlertON = false;
extern bool SoundON = false;
extern string SoundFile_UP = "Alert";
extern string SoundFile_DN = "Alert2";
//---- indicator buffers
double TaichiBuffer[];
double TaichiForBuffer[];//
double SignalBuffer[];
double SSignalBuffer[];
double UpBuffer[];
double DnBuffer[];
double EqBuffer[];
double trend2;
int TimeFrame;
string TF;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
SetIndexStyle(3,DRAW_NONE);
// SetIndexDrawBegin(1,SignalSMA);
IndicatorDigits(Digits+1);
//---- indicator buffers mapping
SetIndexBuffer(0,TaichiBuffer);
SetIndexBuffer(1,SignalBuffer);
SetIndexBuffer(2,SSignalBuffer);
SetIndexBuffer(3,TaichiForBuffer);
SetIndexShift(3,Kijun);
// SetIndexDrawBegin(3,Kijun);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Cronex Taichi Bars");
SetIndexLabel(0,"");
SetIndexLabel(1,"");
SetIndexLabel(2,"");
SetIndexLabel(3,"");
SetIndexStyle(4,DRAW_HISTOGRAM);
SetIndexStyle(5,DRAW_HISTOGRAM);
SetIndexStyle(6,DRAW_HISTOGRAM);
SetIndexBuffer(4,UpBuffer);
SetIndexBuffer(5,DnBuffer);
SetIndexBuffer(6,EqBuffer);
SetIndexLabel(4,"");
SetIndexLabel(5,"");
SetIndexLabel(6,"");
switch(TimeFrame)
{
case 1: TF=" M1"; break;
case 5: TF=" M5"; break;
case 15: TF=" M15"; break;
case 30: TF=" M30"; break;
case 60: TF=" H1"; break;
case 240: TF=" H4"; break;
case 1440: TF=" D1"; break;
case 10080: TF=" W1"; break;
case 43200: TF=" MN1"; break;
default: {TimeFrame = Period(); init(); return(0);}
}
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Cronex Taichi |
//+------------------------------------------------------------------+
int start()
{
double TenkanSen,KijunSen,SenkouSpanA,SenkouSpanB,ChinkouSpan;
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=-Kijun; i<limit; i++)
{
TenkanSen = iIchimoku(NULL,0,Tenkan,Kijun,Senkou,MODE_TENKANSEN,i);
KijunSen = iIchimoku(NULL,0,Tenkan,Kijun,Senkou,MODE_KIJUNSEN,i);
SenkouSpanA = iIchimoku(NULL,0,Tenkan,Kijun,Senkou,MODE_SENKOUSPANA,i);
SenkouSpanB = iIchimoku(NULL,0,Tenkan,Kijun,Senkou,MODE_SENKOUSPANB,i);
ChinkouSpan = iIchimoku(NULL,0,Tenkan,Kijun,Senkou,MODE_CHINKOUSPAN,i);
if (i>=0)
{
TaichiBuffer[i]=(TenkanSen+KijunSen+SenkouSpanA+SenkouSpanB)/4;
TaichiForBuffer[i+Kijun]=(SenkouSpanA+SenkouSpanB)/2;
}
else TaichiForBuffer[i+Kijun]=(SenkouSpanA+SenkouSpanB)/2;
}
//========================== signal line counted ================
for(i=0; i<limit; i++)
{
SignalBuffer[i]=iMAOnArray(TaichiBuffer,Bars,Kijun,0,MODE_LWMA,i);
SSignalBuffer[i]=iMAOnArray(TaichiBuffer,Bars,Senkou,0,MODE_LWMA,i);
//========================== Flat line counted ================
if(MathAbs(((TaichiBuffer[i]-SignalBuffer[i])+(TaichiBuffer[i]- SSignalBuffer[i])+(SignalBuffer[i]-SSignalBuffer[i]))/3)<FlatSE*Point)
{
}
if((TaichiBuffer[i]>SignalBuffer[i])&&(SignalBuffer[i]>TaichiForBuffer[i+Kijun])){trend2=1;}
else if((TaichiBuffer[i]<SignalBuffer[i])&&(SignalBuffer[i]<TaichiForBuffer[i+Kijun])){trend2=-1;}
else {trend2=2;}
if (trend2==1)
{
UpBuffer[i]=1;
EqBuffer[i]=0;
DnBuffer[i]=0;
}
if (trend2==2)
{
UpBuffer[i]=0;
EqBuffer[i]=1;
DnBuffer[i]=0;
}
if (trend2==-1)
{
UpBuffer[i]=0;
EqBuffer[i]=0;
DnBuffer[i]=1;
}}
double Price = iMA(NULL,PERIOD_M1,1,0,MODE_SMA,PRICE_CLOSE,0);
static datetime timeprev;
if(timeprev==Time[0]) {
return(0);
} else if (timeprev==0) {
timeprev=Time[0];
return(0);
} else {
timeprev=Time[0];
if (trend2==1)
if(AlertON){Alert(Symbol()+""+TF+" : Taichi Bars X UP @ "+DoubleToStr(Price,Digits));}
if (SoundON) PlaySound (SoundFile_UP);
if (trend2==-1)
if(AlertON){Alert(Symbol()+""+TF+" : Taichi Bars X DOWN @ "+DoubleToStr(Price,Digits));}
if (SoundON) PlaySound (SoundFile_DN);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments