Navigation´╝ÜHome > Content >

TikTak.mq4

Time: 2014-11-21 | Download file:TikTak.mq4

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Red
#property  indicator_color2  Green
#property  indicator_color3  Blue
//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   IndicatorDigits(2);
   SetIndexDrawBegin(0,0);
   SetIndexDrawBegin(1,0);
   SetIndexDrawBegin(2,0);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("TT");
   SetIndexLabel(0,NULL);
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }

extern double Lots = 0.1;
extern int    Deep = 50;
       double Array[1000];
       int    Index=0, i, Z=0;
       double Current=0, tmp;
       double Up=0, Down=0;
       int    Uc=0, Dc=0;
       double Su=0, Sd=0, K=0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int fill()

{
 tmp=Bid;
 if (Current==tmp) {return(1);}
// Comment("Current=",Current," Bid=",Bid);
 if (tmp!=Current)
  {
   Array[Index]=tmp-Current;
   Current=tmp;
   Index++;
  }
 return(0);
}
//-------------------------------------------------------------------------------------------------

//-- Shift ----------------------------------------------------------------------------------------
int shift()

{
 for (i=1;i0) 
    {
     Up=Up+Array[i];
     Uc++;
    }
   if (Array[i]<0)
    {
     Down=Down+Array[i];
     Dc++;
    }
  }
 Su=Up/Point/Uc;
 Sd=Down/Point/Dc;
 K=MathAbs(Su/Sd);
 ExtBuffer0[Z]=Su;
 ExtBuffer1[Z]=Sd;
 ExtBuffer2[Z]=K;
 Z++;
 return(0);
}
//-------------------------------------------------------------------------------------------------

int start()
  {
   if (Current==0) {Current=Bid;}
   if (Index0) counted_bars--;
   limit=Bars-counted_bars;
   //---- macd counted in the 1-st additional buffer
   for(int i=0; i=0; i--)
     {
      current=ExtBuffer3[i]-ExtBuffer4[i];
      prev=ExtBuffer3[i+1]-ExtBuffer4[i+1];
      if(current>prev) up=true;
      if(current        

Recommend