//+------------------------------------------------------------------+
//| Copyright © 2012, Khlystov Vladimir |
//| http://cmillion.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, cmillion@narod.ru"
#property link "http://cmillion.narod.ru"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3
extern int channel =12; // øèðèíà "ðàáî÷åãî êàíàëà" â ïóíêòàõ (â ïðåäñòàâëåíèè ñ 5-þ çíàêàìè ïîñëå çàïÿòîé)
extern int Q = 6; // ÷èñëî ïîñëåäîâàòåëüíûõ ïåðåñå÷åíèé ïðîòèâîïîëîæíûõ ñòîðîí "ðàáî÷åãî êàíàëà"
double SignalBufferRed[];
double SignalBufferBlue[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_ARROW,0,3);
SetIndexArrow(0,233);
SetIndexStyle(1,DRAW_ARROW,0,3);
SetIndexArrow(1,234);
SetIndexBuffer(0,SignalBufferBlue);
SetIndexBuffer(1,SignalBufferRed);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit--;
for(int j=limit; j>=0; j--)
{
bool NoSell=false,NoBuy=false;
int q=0;
int i=j;
double GN[2][10];
ArrayInitialize(GN,0);
while(i<limit-1)
{
i++;
if(Low[i]<=Close[j]-channel*2*Point || High[i]>=Close[j]+channel*Point) NoBuy=true;
if(Low[i]<=Close[j]-channel*Point || High[i]>=Close[j]+channel*2*Point) NoSell=true;
if(NoBuy && NoSell) break;
if(NoBuy)
{
if(High[i]>=Close[j]+channel*Point)
{
if(q==0 || q==2 || q==4 || q==6 || q==8 || q==10) {GN[0][q]=Time[i]; GN[1][q]=Close[j]+channel*Point; q++; i++;}
}
if(Low[i]<=Close[j])
{
if(q==1 || q==3 || q==5 || q==7 || q==9 || q==11) {GN[0][q]=Time[i]; GN[1][q]=Close[j]; q++; i++;}
}
}
if(NoSell)
{
if(Low[i]<=Close[j]-channel*Point)
{
if(q==0 || q==2 || q==4 || q==6 || q==8 || q==10) {GN[0][q]=Time[i]; GN[1][q]=Close[j]-channel*Point; q++; i++;}
}
if(High[i]>=Close[j])
{
if(q==1 || q==3 || q==5 || q==7 || q==9 || q==11) {GN[0][q]=Time[i]; GN[1][q]=Close[j]; q++; i++;}
}
}
if(q>=Q || q>10)
{
if(NoSell) SignalBufferBlue[j]=Close[j];
if(NoBuy) SignalBufferRed[j]=Close[j];
for(int n=0; n<q; n++) Text(StringConcatenate(n," ",TimeToStr(Time[j],TIME_DATE|TIME_MINUTES)),Red,GN[0][n],GN[1][n],n+1,0);
Trend(StringConcatenate(TimeToStr(Time[j],TIME_DATE|TIME_MINUTES)," 1Channel"),Red,GN[0][q-1],Close[j],Time[j],Close[j]);
Trend(StringConcatenate(TimeToStr(Time[j],TIME_DATE|TIME_MINUTES)," 2Channel"),Red,GN[0][q-1],GN[1][0],Time[j],GN[1][0]);
break;
}
}
}
return(0);
}
//+------------------------------------------------------------------+
void Text(string name,color COLOR,datetime T1,double Price,string Name,int ANGLE)
{
ObjectDelete(name);
ObjectCreate(name,OBJ_TEXT,0,T1,Price,0,0,0,0);
ObjectSet(name,OBJPROP_ANGLE,ANGLE);
ObjectSetText(name,Name,10,"Arial",COLOR);
}
//+------------------------------------------------------------------+
void Trend(string name,color COLOR,datetime T1,double P1,datetime T2,double P2)
{
ObjectDelete(name);
ObjectCreate(name,OBJ_TREND,0,T1,P1,T2,P2,0,0);
ObjectSet(name,OBJPROP_STYLE,0);
ObjectSet(name,OBJPROP_WIDTH,0);
ObjectSet(name,OBJPROP_RAY,false);
ObjectSet(name,OBJPROP_COLOR,COLOR);
}
//+------------------------------------------------------------------+
Comments