//+------------------------------------------------------------------+ //| ZPF.mq4 | //| Copyright © 2010 Festival | //| festival | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010 Festival" #property link "festival" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 //---- input parameters extern int ZPF_Period=12; //---- buffers double ExtGreenBuffer[]; double ExtRedBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators string sShortName="ZPF("+ZPF_Period+")"; IndicatorShortName(sShortName); SetIndexLabel(0,sShortName); //---- SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtGreenBuffer); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtRedBuffer); SetIndexDrawBegin(0,ZPF_Period*2); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int SMA_Fast=ZPF_Period, SMA_Slow=ZPF_Period*2, limit,SumVolume,c,i,z; double SumFastClose,SumSlowClose; //---- if(Bars<=SMA_Slow) return(0); int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(counted_bars==0) limit-=1+MathMax(SMA_Slow,SMA_Fast); //---- for(c=0; c<(SMA_Fast-1); c++) { SumVolume+=Volume[c]; SumFastClose+=Close[c]; } //---- SumSlowClose=SumFastClose; //---- for(z=c; z<(SMA_Slow-1); z++) SumSlowClose+=Close[z]; //---- double SumZPF; //---- for(i=0; i