Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
ma_TemaDemaTrixCD_rlh
//+------------------------------------------------------------------+
//| 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 temadematrix cd osma
#property copyright "Copyright © 2006, Robert Hill "
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 DodgerBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
//----
extern int EMA_Period =9;
extern bool tdOsma = false; // tdosma\dematrix
//---- buffer
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Dema[];
double Tema[];
double dematrix[];
double tematrix[];
double tdcd[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(8);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0,EMA_Period);
SetIndexDrawBegin(1,EMA_Period);
SetIndexDrawBegin(2,EMA_Period);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
if(!SetIndexBuffer(7,Ema) &&
!SetIndexBuffer(6,EmaOfEma) &&
!SetIndexBuffer(5,EmaOfEmaOfEma) &&
!SetIndexBuffer(4,Dema)&&
!SetIndexBuffer(3,Tema)&&
!SetIndexBuffer(2,dematrix)&&
!SetIndexBuffer(1,tematrix)&&
!SetIndexBuffer(0,tdcd))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("TDCD TD trix ("+EMA_Period+") ");
// Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];
SetIndexLabel(0,"tdcd ");
SetIndexLabel(1,"tematrix ");
SetIndexLabel(2,"tdosma/dematrix");
//---- 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--)
Ema[i]=iMA(NULL,0,EMA_Period,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit; i >=0; i--)
EmaOfEma[i]=iMAOnArray(Ema,Bars,EMA_Period,0,MODE_EMA,i);
for(i=limit; i >=0; i--)
EmaOfEmaOfEma[i]=iMAOnArray(EmaOfEma,Bars,EMA_Period,0,MODE_EMA,i);
//==========
for(i=limit; i >=0; i--)
Dema[i]=2 * Ema[i] - EmaOfEma[i];
for(i=limit; i >=0; i--)if (Dema[i]||Tema[i]!=0)
{
Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];
tdcd [i]=10*(Tema[i]-Dema[i])/Dema[i]*3;
}
if (!tdOsma) {
for(i=limit; i >=0; i--) if (EmaOfEma[i+1]!=0)
dematrix[i] =100*(EmaOfEma[i]-EmaOfEma[i+1])/EmaOfEma[i+1];
}
else
for(i=limit; i >=0; i--) if (EmaOfEmaOfEma[i]!=0)
dematrix[i] =10*(EmaOfEma[i]-EmaOfEmaOfEma[i])/EmaOfEmaOfEma[i];
for(i=limit; i >=0; i--) if (EmaOfEmaOfEma[i+1]!=0)
tematrix[i] =100*(EmaOfEmaOfEma[i]-EmaOfEmaOfEma[i+1])/EmaOfEmaOfEma[i+1];
//----
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
---