Price Data Components
Indicators Used
0
Views
0
Downloads
0
Favorites
dex_HeLMA_v2.0
//+------------------------------------------------------------------+
//| dex_HeLMA v2.mq4 |
//| Copyright © 2007, akadex |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, akadex"
#property link "Shambala"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Gray
#property indicator_color2 Gray
#property indicator_color3 Aqua
#property indicator_color4 Red
extern string a="Ñòåïåíü ôèëüòðàöèè";
extern int FiltrPeriod=6;
int fs,ai,bi,k,Points;
double zz[],ha[],la[],sa[],DIR[],UpBuffer[],DnBuffer[];
double P,R1,R5,R10,R20,RAvg,currday,di,hm,lm;
int init()
{
IndicatorBuffers(6);
SetIndexBuffer(0,ha);
SetIndexStyle (0,0,2,1);
SetIndexBuffer(1,la);
SetIndexStyle (1,0,2,1);
SetIndexBuffer(2,UpBuffer);
SetIndexStyle (2,0,0,2);
SetIndexBuffer(3,DnBuffer);
SetIndexStyle (3,0,0,2);
SetIndexBuffer(4,sa);
SetIndexBuffer(5,DIR);
return(0);
}
int start()
{
int i,n;
int counted_bars=IndicatorCounted();
if (counted_bars<0) {Print("Indicator Error (Counted bars < 0)!" ); return(-1); }
if (Bars<100) {Print("Indicator Error (Bars < 100)!" ); return(-1); }
int cbi=Bars-2;
if (counted_bars>2) {cbi=Bars-counted_bars-1; }
for (i=cbi; i>=0; i--)
{
currday=i*Period()/PERIOD_D1;
R1 = (iHigh(NULL,PERIOD_D1,currday+1)-iLow(NULL,PERIOD_D1,currday+1))/Point;
for(k=1;k<=5;k++) R5 = R5 + (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;
for(k=1;k<=10;k++) R10 = R10 + (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;
for(k=1;k<=20;k++) R20 = R20 + (iHigh(NULL,PERIOD_D1,currday+k)-iLow(NULL,PERIOD_D1,currday+k))/Point;
R5 = R5/5;
R10 = R10/10;
R20 = R20/20;
Points = NormalizeDouble((R5+R10+R20+R1)/4,0);
if (Points!=0) di=Points*Point;
Comment("\nØèðèíà êàíàëà òðåíäà: "+Points+" ïóíêòîâ.");
if (i>Bars-1) {hm=High[i]; lm=hm-di; ai=i; bi=i+1; fs=0;}
if (High[i]-Low[i]>=di)
{
if ((High[i]+Low[i])/2>=(ha[i+1]+la[i+1])/2)
{
hm=High[i]; lm=hm-di; ai=i; fs=1;
}
else
{
lm=Low[i]; hm=lm+di; bi=i; fs=2;
}
}
else
if (High[i]>hm)
{
hm=High[i]; lm=hm-di; ai=i; fs=1;
}
else
if (Low[i]<lm)
{
lm=Low[i]; hm=lm+di; bi=i; fs=2;
}
ha[i]=hm;
la[i]=lm;
sa[i]=(ha[i]+la[i])/2;
if (i==0)
{
if (ai!=0 || bi!=0)
{
for (n=0; n<=ai+1; n++) if (ha[n]>ha[n+1]) {ai=n; break;}
for (n=0; n<=bi+1; n++) if (la[n]<la[n+1]) {bi=n; break;}
}
}
}
for (i=cbi; i>=0; i--)
{
DIR[i] = DIR[i + 1];
if (sa[i] - sa[i + 1] > 0 && (iMA(NULL,0,FiltrPeriod,0,MODE_EMA,PRICE_CLOSE,i) > iMA(NULL,0,FiltrPeriod,0,MODE_EMA,PRICE_CLOSE,i+1))) DIR[i] = 1;
if (sa[i + 1] - sa[i] > 0 && (iMA(NULL,0,FiltrPeriod,0,MODE_EMA,PRICE_CLOSE,i) < iMA(NULL,0,FiltrPeriod,0,MODE_EMA,PRICE_CLOSE,i+1))) DIR[i] = -1;
if (DIR[i] > 0)
{
UpBuffer[i] = sa[i];
if (DIR[i + 1] < 0) UpBuffer[i + 1] = sa[i + 1];
DnBuffer[i] = EMPTY_VALUE;
}
else
{
if (DIR[i] < 0)
{
DnBuffer[i] = sa[i];
if (DIR[i + 1] > 0) DnBuffer[i + 1] = sa[i + 1];
UpBuffer[i] = EMPTY_VALUE;
}
}
}
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
---