2ZZ+Signal_

Author: Copyright � 2008, HomeSoft-Tartan Corp.
2ZZ+Signal_
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
2ZZ+Signal_
//+------------------------------------------------------------------+
//|                                                   2ZZ+Signal.mq4 |
//|                          Copyright © 2008, HomeSoft-Tartan Corp. |
//|                                              spiky@transkeino.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, HomeSoft-Tartan Corp."
#property link      "spiky@transkeino.ru"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Magenta
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Aqua
#property indicator_color6 Gold

//---- indicator parameters
extern int    SnakeRange   = 3; 
extern int    FilterPeriod = 21; 
extern double MartFiltr    = 2.0;
extern int    PriceConst   = 6;
//+------------------------------------------------------------------+
extern string ZZ="ZZS";
extern int    LDepth=20;
extern int    BDepth=30;
extern int    Deviation=5;
extern int    Backstep=3;
extern int    kb=1;
extern int    nBars=500;

double BZZBuff[],LZZBuff[],StartBuff[],StopBuff[],UpBuff[],DnBuff[],ssrone,ssrnul,bzz,lzz,ibzz,ilzz,bbzz,llzz,zz,zzold,sd,zzb,lzold;
int shift,zzbar,i,fs,fb,pr,k,ns,nb,bbar;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,BZZBuff);
   SetIndexBuffer(1,LZZBuff);
   SetIndexBuffer(2,StartBuff);
   SetIndexBuffer(3,StopBuff);  
   SetIndexBuffer(4,UpBuff); 
   SetIndexBuffer(5,DnBuff);   
    
   SetIndexStyle(0,DRAW_SECTION,EMPTY,2,Magenta);
   SetIndexStyle(1,DRAW_SECTION,STYLE_DOT,0,Red);   
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID,2,Lime);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID,2,Red);
   SetIndexStyle(4,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(4,241); 
   SetIndexStyle(5,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(5,242);
   
   SetIndexEmptyValue(0,0.0);  
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);  
   SetIndexEmptyValue(3,0.0); 
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0);
   
if (Period()==5) sd=1;  
if (Period()==15) sd=3;  
if (Period()==30) sd=5;   
if (Period()==60) sd=10;
if (Period()==240) sd=15;  
if (Period()==1440) sd=20;
if (Period()>1440) sd=25;
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----

   if (Period()<5) {Comment("\n","  Ðàáîòàòü ìîæíî íà ÒÔ=M5 è âûøå. Ñìåíèòå ÒÔ!");return(0);}

  for (shift=nBars;shift>=0;shift--)
   {   
   if (bzz!=0 && lzz!=0 && bzz!=zzold && lzz!=zzold && bzz==lzz) zzold=bzz;
   
       bzz=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,shift+1);
       bbzz=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,shift);  
       BZZBuff[shift]=bbzz; 
   if (lzz!=0 && lzold!=lzz) lzold=lzz; 
       lzz=iCustom(NULL,0,ZZ,LDepth,Deviation,Backstep,nBars,0,shift+1);
       llzz=iCustom(NULL,0,ZZ,LDepth,Deviation,Backstep,nBars,0,shift);
       LZZBuff[shift]=llzz;
         
       ssrone=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift+1);
       ssrnul=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift);   
       
  for (i=1;i<nBars;i++)
   {
       zzb=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,i);
   if (zzb!=0) {bbar=i;break;}         
   }
   if (bzz!=0 && lzz!=0) k=0;     
      
   if (k==0) 
   {   k=1; 
   if (bzz!=zzold && zzold>bzz) {fb=1;fs=0;nb=0;zzbar=shift+1;}
   if (bzz!=zzold && zzold<bzz) {fs=1;fb=0;ns=0;zzbar=shift+1;}
   }
   
   if (fs==1 && ssrone>ssrnul && ssrone>0 && ns==0 && bbar>=kb && Close[shift]<=zzold-3*sd*Point && Close[shift]<Open[shift])  
   {    
        ns=1;DnBuff[shift]=High[shift]+2*sd*Point; if (DnBuff[shift+1]!=0) DnBuff[shift+1]=0;
   }
   
   if (fb==1 && ssrone<ssrnul && ssrone<0 && nb==0 && bbar>=kb && Close[shift]>=zzold+3*sd*Point && Close[shift]>Open[shift]) 
   { 
        nb=1;UpBuff[shift]=Low[shift]-2*sd*Point; if (UpBuff[shift+1]!=0) UpBuff[shift+1]=0;
   }

   if (fb==1 && k==1 && lzold==zzold)
   {   
  for (i=zzbar;i>=zzbar-10;i--) 
   {   
   if (i>3) {StartBuff[i+1]=zzold+3*sd*Point;StopBuff[i+1]=zzold-sd*Point;}
   } 
       Comment("\n"," Ïîêóïàé ïî ñèãíàëó ïðè öåíå îò ",zzb+3*sd*Point," ïîñëå çàêðûòèÿ áàðà");
       StopBuff[i]=0;StartBuff[i]=0; 
   }  
        
   if (fs==1 && k==1 && lzold==zzold)
   {
  for (i=zzbar;i>=zzbar-10;i--) 
   {
   if (i>3) {StartBuff[i+1]=zzold-3*sd*Point;StopBuff[i+1]=zzold+sd*Point;}//zzold-zzb
   }
       Comment("\n"," Ïðîäàâàé ïî ñèãíàëó ïðè öåíå îò ",zzb-3*sd*Point," ïîñäå çàêðûòèÿ áàðà"); 
       StopBuff[i]=0;StartBuff[i]=0;   
   }
   
  for (i=zzbar+1;i<zzbar+nBars;i++) {StartBuff[i]=0;StopBuff[i]=0;} //????
   
   if ((fb==1 && Ask>zzold+3*sd*Point && ssrone<=ssrnul && ssrnul>0) || (fs==1 && Bid<zzold-3*sd*Point && ssrone>=ssrnul && ssrnul<0))
   {
       Comment("\n","  Ìîæåøü òîðãîâàòü íà ñâîé ñòðàõ è ðèñê!  Íî!!!",
               "\n","  Ïðîäàæà âîçìîæíà=",fs,"  Ïîêóïêà âîçìîæíà=",fb);StopBuff[i]=0;StartBuff[i]=0;
   }            
   }           
   //----
   return(0);
   }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---