ВСЕ такие УМНЫЕ, только в столовую строем не ходите.
//+------------------------------------------------------------------+
//| Filter CCI.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Silver
#property indicator_width1 3
#property indicator_level1 100
#property indicator_level2 0
#property indicator_level3 -100
#property indicator_levelcolor Gray
extern double CCI=14;
extern double c1= 1;
extern double c2= 1;
extern double c3= 1;
extern color ClrUp = Lime; //Выше уровня
extern color ClrDn = Red; // Ниже уровня
extern color ClrNeUp = RoyalBlue; //Нейтральный выше нуля
extern color ClrNeDn = Gold; //Нейтральный ниже нуля
extern int HistWidth=2; // Толщина гистограммы
extern double Level=100;
int p=6;
double BufNe[];
double CCI1,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,max,min;
double BufUp[];
double BufDn[];
double BufNeUp[];
double BufNeDn[];
datetime bt=0;
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0,BufNe);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(1,BufUp);
SetIndexBuffer(2,BufDn);
SetIndexBuffer(3,BufNeUp);
SetIndexBuffer(4,BufNeDn);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,HistWidth,ClrUp);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,HistWidth,ClrDn);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,HistWidth,ClrNeUp);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,HistWidth,ClrNeDn);
string short_name="Filter CCI реал"+"("+CCI+") ";
IndicatorShortName(short_name);
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int pos=Bars-counted_bars;
int limit=Bars;
if(pos>limit)
{
pos=limit;
}
double dResult1;
int i;
double a[1];
while(pos>=0)
{
ArrayInitialize(a,EMPTY_VALUE);
ArrayResize(a,0);
for(i=5; i<p+5; i++)
{
int size_a=ArraySize(a);
ArrayResize(a,size_a+1);
a[size_a]=iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+i)*c1
+iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-1))*c2-iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+i)*c3
+iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-2))*c2-iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-1))*c3
+iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-3))*c2-iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-2))*c3
+iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-4))*c2-iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-3))*c3
+iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-5))*c2-iCCI(NULL,0,CCI,PRICE_TYPICAL,pos+(i-4))*c3;
}
double a_max = a[ArrayMaximum(a)];
double a_min = a[ArrayMinimum(a)];
max = a_max;
min = a_min;
dResult1=(max+min);
BufNe[pos]=dResult1;
if(BufNe[pos]<-Level)
{
BufDn[pos]=BufNe[pos];
BufNeDn[pos]=-Level;
}
if(BufNe[pos]>=-Level && BufNe[pos]<0)
BufNeDn[pos]=BufNe[pos];
if(BufNe[pos]>Level)
{
BufUp[pos]=BufNe[pos];
BufNeUp[pos]=Level;
}
if(BufNe[pos]<=Level && BufNe[pos]>0)
BufNeUp[pos]=BufNe[pos];
pos--;
}
if (bt==Time[0]) return(0);
if (BufNe[1]>Level && BufNe[2]<=Level) {Alert(Symbol()," Выход из зоны ",Level);bt=Time[0];}
if (BufNe[1]<-Level && BufNe[2]>=-Level) {Alert(Symbol()," Выход из зоны -",Level);bt=Time[0];}
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Andrey1979.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.mункцql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.mункцql5.com"
#property version "1.00"
#property strict
extern string ind_name = "Filter CCI";
extern double CCI=14;
extern double c1= 1;
extern double c2= 1;
extern double c3= 1;
extern ENUM_TIMEFRAMES TF = PERIOD_CURRENT;
extern int Shift = 1; // бар индикатора
//extern string ind_name = "Filter CCI real alert";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
ObjectsDeleteAll();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
double filtr_CCI = iCustom(NULL,TF,ind_name,CCI,c1,c2,c3,0,Shift);
DrawLABEL("filtr CCI",StringConcatenate("filtr CCI = ",DoubleToString(filtr_CCI,2)),5,35,Color(filtr_CCI<0,clrRed,clrGreen),ANCHOR_RIGHT);
}
//+-------------------------------------------------------------------+
//| |
//+-------------------------------------------------------------------+
color Color(bool P,color a,color b)
{
if (P) return(a);
else return(b);
}
//+-------------------------------------------------------------------+
//| |
//+-------------------------------------------------------------------+
void DrawLABEL(string name, string Name, int X, int Y, color clr,ENUM_ANCHOR_POINT align=ANCHOR_RIGHT)
{
if (ObjectFind(name)==-1)
{
ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
ObjectSet(name, OBJPROP_CORNER, 1);
ObjectSet(name, OBJPROP_XDISTANCE, X);
ObjectSet(name, OBJPROP_YDISTANCE, Y);
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
ObjectSetInteger(0,name,OBJPROP_ANCHOR,align);
}
ObjectSetText(name,Name,12,"Arial",clr);
}
//--------------------------------------------------------------------
Andrey1979