Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
trender_color_mtf
//+------------------------------------------------------------------+
//| trender.mq4 |
//| Copyright © 2010, Yury Zinoviev |
//| zinoviev.yury@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Yury Zinoviev"
#property link "zinoviev.yury@gmail.com"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Yellow
//---- buffers
double g1[],g2[],g3[];
//inputs
extern double tf=0;
extern int ma_type=1;
extern int ma_price=0;
extern int ma_start=10;
extern int ma_end=175;
extern int ma_step=5;
extern int flat=100;
int dg;
double r;
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
SetIndexBuffer(0,g1);
SetIndexLabel(0,"UPtrend hysto " + tf);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
SetIndexBuffer(1,g2);
SetIndexLabel(1,"DNtrend hysto " + tf);
SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,2);
SetIndexBuffer(2,g3);
SetIndexLabel(2,"FLTtrend hysto " + tf);
SetLevelValue(0,0);
SetLevelValue(0,flat);
SetLevelValue(1,(-1*flat));
IndicatorShortName("trend hystogramm");
ArrayInitialize(g1,0);
ArrayInitialize(g2,0);
ArrayInitialize(g3,0);
dg=mult(Symbol());
if(tf!=0)r=tf/Period();else r=1;
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int i,j,k;
int counted_bars;
double ma,ma2,matotal;
string sy=Symbol();
double pnt=MarketInfo(sy,MODE_POINT);
counted_bars=IndicatorCounted();
i=Bars-counted_bars-1;
ma=iMA(sy,tf,ma_start,0,ma_type,ma_price,MathFloor(i/r));
while(i>=0)
{
k=ma_start; matotal=0;
int ii=MathFloor(i/r);
ma=iMA(sy,tf,k,0,ma_type,ma_price,ii);
int upcheck=0,dncheck=0;
while(k<ma_end)
{
k+=ma_step;
ma2=iMA(sy,tf,k,0,ma_type,ma_price,ii);
if(ma-ma2<0)dncheck--;
if(ma2-ma<0)upcheck--;
matotal+=(ma-ma2);
ma=ma2;
}
g1[i]=0;g2[i]=0;g3[i]=0;
if(upcheck<0 && dncheck<0)g3[i]=matotal/pnt/dg;
else if(upcheck<0)g1[i]=matotal/pnt/dg; else g2[i]=matotal/pnt/dg;
//Comment(matotal/pnt+"\n"+ma2);
i--;
}
return(0);
}
//+------------------------------------------------------------------+
int mult(string symb)
{
int x = 1;
//if(!AutoDigits) return(x);
int v=int(MarketInfo(symb,MODE_DIGITS));
switch (v)
{
case 2: x=1; break;
case 4: x=1; break;
case 3: x=10; break;
case 5: x=10; break;
default : x=1;
}
return(x);
}
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
---