Indicators Used
0
Views
0
Downloads
0
Favorites
Trix log
//+------------------------------------------------------------------+
//| Trix of log of a price.mq4 |
//| |
//+------------------------------------------------------------------+
#property copyright "copyleft mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DimGray
#property indicator_color2 DarkOrange
#property indicator_style1 STYLE_DOT
//
//
//
//
//
extern int TrixPeriod = 9;
extern int TrixPrice = PRICE_CLOSE;
//
//
//
//
//
double TrixBuffer[];
double ZeroBuffer[];
double EmaBuffer1[];
double EmaBuffer2[];
double EmaBuffer3[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0,ZeroBuffer);
SetIndexBuffer(1,TrixBuffer);
SetIndexBuffer(2,EmaBuffer1);
SetIndexBuffer(3,EmaBuffer2);
SetIndexBuffer(4,EmaBuffer3);
IndicatorShortName("Trix ("+TrixPeriod+")");
return(0);
}
//
//
//
//
//
int start()
{
double alpha = 2.0/(1.0+TrixPeriod);
int counted_bars=IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = Bars-counted_bars;
//
//
//
//
//
for(int i=limit; i>=0; i--)
{
double price = MathLog(iMA(NULL,0,1,0,MODE_SMA,TrixPrice,i));
EmaBuffer1[i] = EmaBuffer1[i+1]+alpha*(price -EmaBuffer1[i+1]);
EmaBuffer2[i] = EmaBuffer2[i+1]+alpha*(EmaBuffer1[i]-EmaBuffer2[i+1]);
EmaBuffer3[i] = EmaBuffer3[i+1]+alpha*(EmaBuffer2[i]-EmaBuffer3[i+1]);
TrixBuffer[i] = (EmaBuffer3[i]-EmaBuffer3[i+1])*10000;
ZeroBuffer[i] = 0;
}
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
---