//+---------------------------------------------------------------------+
//| _Levels.mq4 |
//| Copyright © InVest0r 2010 |
//+---------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red //0
#property indicator_color2 Blue //1
#property indicator_color3 Red //2
#property indicator_color4 Blue //3
#property indicator_color5 Gray //4
#property indicator_color6 Gray //5
#property indicator_color7 White //6
#property indicator_color8 White //7
extern int nobs =900,
Level1 =14,
Level2 =8,
Level3 =50;
double levelup1[999],leveldn1[999],
levelup2[999],leveldn2[999],
levelup3[999],leveldn3[999];
double level1,level2,level3;
double trdn[], trup[];
double up[],dn[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init() {
SetIndexBuffer(0,dn);
SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
SetIndexArrow(0,238);
SetIndexBuffer(1,up);
SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
SetIndexArrow(1,236);
SetIndexBuffer(2,trdn);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(3,trup);
SetIndexStyle(3,DRAW_LINE);
// SetIndexBuffer(4,levelup2);
// SetIndexStyle(4,DRAW_LINE);
// SetIndexBuffer(5,leveldn2);
// SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(6,levelup3);
SetIndexStyle(6,DRAW_LINE,0,2);
SetIndexBuffer(7,leveldn3);
SetIndexStyle(7,DRAW_LINE,0,2);
SetIndexShift(4,2);
SetIndexShift(5,2);
return(0); }
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
ObjectsDeleteAll(0);
Comment("");
return(0); }
//------------------------------------------------------------------------
int start() {
level1=2.0/(1+Level1);
for(int i=nobs; i>=0; i--) {
if(iHigh(NULL,0,i)>levelup1[i+1]) levelup1[i]=iHigh(NULL,0,i);
else levelup1[i]=level1*iHigh(NULL,0,i)+(1-level1)*levelup1[i+1];
if(iLow(NULL,0,i)<leveldn1[i+1]) leveldn1[i]=iLow(NULL,0,i);
else leveldn1[i]=level1*iLow(NULL,0,i)+(1-level1)*leveldn1[i+1];
levelup2[i]=High[Highest(NULL,0,MODE_HIGH,Level2,i)];
leveldn2[i]=Low[Lowest (NULL,0,MODE_LOW ,Level2,i)];
levelup3[i]=High[Highest(NULL,0,MODE_HIGH,Level3,i)];
leveldn3[i]=Low[Lowest (NULL,0,MODE_LOW ,Level3,i)]; }
for(i=0; i<nobs; i++){
if (levelup1[i]<levelup1[i+1]) {trdn[i]=levelup1[i]; }
if (leveldn1[i]>leveldn1[i+1]) {trup[i]=leveldn1[i]; }
if (levelup1[i]<levelup2[i] && iHigh(NULL,0,i+1)==levelup2[i+1]) {
ObjectCreate(Time[i]+Symbol()+"dn",OBJ_ARROW,0,Time[i],levelup1[i]);
ObjectSet(Time[i]+Symbol()+"dn",OBJPROP_ARROWCODE,238);
ObjectSet(Time[i]+Symbol()+"dn",OBJPROP_COLOR,Red);}
if (leveldn1[i]>leveldn2[i] && iLow(NULL,0,i+1)==leveldn2[i+1]) {
ObjectCreate(Time[i]+Symbol()+"up",OBJ_ARROW,0,Time[i],leveldn1[i]);
ObjectSet(Time[i]+Symbol()+"up",OBJPROP_ARROWCODE,236);
ObjectSet(Time[i]+Symbol()+"up",OBJPROP_COLOR,Lime);}
}
return(0); }
//---------------------------------------------------------------------------------------------------------------
Comments