//+------------------------------------------------------------------+
//| ZZ.mq4 |
//| Copyright © 2012, MetaQuotes Software Corp. |
//| _http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//indikatoriaus zz kintamieji
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
extern int Bars_count=240; //Is kiek baru skaiciuosime
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function
//+------------------------------------------------------------------+
int start()
{
//----
if( !NewBar() ) return(0);
double zz_arr[10000],zz_arr_Abs[10000];
double preZz=0;
int i,ii;
int handle;
handle=FileOpen("my_file.csv",FILE_CSV|FILE_WRITE,";");
for(i=0;i<=Bars_count;i++)
{
double zz = iCustom(NULL,0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
if(zz!=0)
{
if(preZz==0)
{
preZz=zz
;continue;
}
zz_arr[ii]=zz-preZz;
preZz=zz;
ii++;
Print(zz_arr[ii-1]/Point, " ii = ", ii - 1);
zz_arr_Abs[ii-1]=MathAbs(zz_arr[ii-1]);
if(handle>0)
{
FileWrite(handle, zz_arr_Abs[ii-1]);
}
Print(" ",zz_arr_Abs[ii-1]/Point, " ii = ", ii - 1);
}
}
FileClose(handle);
ArrayResize(zz_arr,ii);
Print("-------------------------------------------------");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Iaia?o?aiea iiaiai aa?a
//+------------------------------------------------------------------+
bool NewBar()
{
//----
static datetime NewTime; // A?aiy oaeouaai aa?a
bool NewBar=false; // Iiaiai aa?a iao
if( NewTime!=Time[0] )
{
NewTime=Time[0]; // Oaia?u a?aiy oaeia
NewBar=true; // Iieiaeny iiaue aa?
}
//----
return(NewBar);
}
//+------------------------------------------------------------------+