//+------------------------------------------------------------------+ //| TEMA_RLH | //| Copyright © 2006, Robert Hill | //| http://www.metaquotes.net/ | //| | //| Based on the formula developed by Patrick Mulloy | //| | //| It can be used in place of EMA or to smooth other indicators. | //| | //| TEMA = 3 * EMA - 3 * (EMA of EMA) + EMA of EMA of EMA | //| | //| Red is EMA, Green is EMA of EMA, Yellow is Ema of Ema of Ema | //| Aqua is TEMA | //| | //+------------------------------------------------------------------+ //mod2009fxtsd tdcd (tema-dema)trix #property copyright "Copyright © 2006, Robert Hill " #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 DodgerBlue #property indicator_width1 1 #property indicator_width2 1 //---- extern int EMA1_Period =9; extern int EMA2_Period =13; //extern int SigLperiod =9; extern bool trixCD = true; //---- buffer double Ema11[]; double Ema12[]; double Ema13[]; double Ema21[]; double Ema22[]; double Ema23[]; double trix1[]; double trix2[]; //double txsln[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(8); //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexDrawBegin(0,EMA2_Period); SetIndexDrawBegin(1,EMA2_Period); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping SetIndexBuffer(7,Ema11); SetIndexBuffer(6,Ema12); SetIndexBuffer(5,Ema13); SetIndexBuffer(4,Ema21); SetIndexBuffer(3,Ema22); SetIndexBuffer(2,Ema23); SetIndexBuffer(1,trix1); SetIndexBuffer(0,trix2); //---- name for DataWindow and indicator subwindow label IndicatorShortName("trix ( "+EMA1_Period+", "+EMA2_Period+" )"); // Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i]; SetIndexLabel(0,"trix2"); SetIndexLabel(1,"trix1 "); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int i, limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>=0; i--) Ema11[i]=iMA(NULL,0,EMA1_Period,0,MODE_EMA,PRICE_CLOSE,i); for(i=limit; i >=0; i--) Ema12[i]=iMAOnArray(Ema11,Bars,EMA1_Period,0,MODE_EMA,i); for(i=limit; i >=0; i--) Ema13[i]=iMAOnArray(Ema12,Bars,EMA1_Period,0,MODE_EMA,i); for(i=limit; i>=0; i--) Ema21[i]=iMA(NULL,0,EMA2_Period,0,MODE_EMA,PRICE_CLOSE,i); for(i=limit; i >=0; i--) Ema22[i]=iMAOnArray(Ema21,Bars,EMA2_Period,0,MODE_EMA,i); for(i=limit; i >=0; i--) Ema23[i]=iMAOnArray(Ema22,Bars,EMA2_Period,0,MODE_EMA,i); for(i=limit; i >=0; i--) if (Ema23[i+1]!=0) { trix2[i]= (Ema23[i]-Ema23[i+1])/Ema23[i+1]; if (trixCD) double t2= trix2[i];else t2=0.0; } for(i=limit; i >=0; i--) if (Ema13[i+1]!=0) trix1[i]= (Ema13[i]-Ema13[i+1])/Ema13[i+1]-t2; //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: