Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Cronex Taichi Bars
//+------------------------------------------------------------------+
//| 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
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---