//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//---- 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[];
double Array[1000];
int Deep=120;
int Index=0, i, Z=0;
double Current=0, tmp;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
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
for(i=0;i<Deep;i++)
{
Array[i]=Bid;
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int fill()
{
tmp=Bid;
if (Current==tmp) {return(1);}
if (tmp!=Current)
{
Array[0]=tmp;//-Current;
Current=tmp;
}
for(i=0;i<Deep;i++)
{
ExtBuffer0[i]=Array[i];
}
return(0);
}
//-------------------------------------------------------------------------------------------------
//-- Shift ----------------------------------------------------------------------------------------
int shift()
{
for (i=1;i<Deep;i++)
{
Array[i]=Array[i-1];
}
return(0);
}
//-------------------------------------------------------------------------------------------------
int start()
{
if (Current==0) {Current=Bid;}
fill();
shift();
return(0);
}
Comments