Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
EMAdensity
//+------------------------------------------------------------------+
//| EMAdensity.mq4 |
//| niva |
//| forex-tsd |
//+------------------------------------------------------------------+
#property copyright "niva"
#property link "forex-tsd"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
double ExtMapBuffer1 [];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
string short_name = "EMA lines desity!";
IndicatorShortName(short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double ema1, ema2, ema3, ema4, ema5;
double mean, variance, result;
if (counted_bars < 0) return(-1);
if (counted_bars >0) counted_bars --;
int pos=Bars-counted_bars;
//----
while(pos>=0)
{
ema1=iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,pos);
ema2=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,pos);
ema3=iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,pos);
ema4=iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,pos);
ema5=iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,pos);
mean = (ema1 +ema2+ema3+ema4+ema5)/5;
variance = (square(ema1-mean)+square(ema2-mean)+square(ema3-mean)+square(ema4-mean)+square(ema5-mean))/5;
result = 100*variance;
ExtMapBuffer1[pos]=result;
pos--;
}
//----
return(0);
}
double square(double number){
double result;
result=number*number;
return(result);
}
//+------------------------------------------------------------------+
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
---