Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 8/12/2009(UTC) Posts: 1
|
Dear all
Here attached code base in Mql4 Language : and also try to convert myself as follows in bold letter.
kindly help us to convert in metastock.
/+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 //---- extern int Length=5; extern int Method=3; extern int Smoothing=1; extern int Filter=5; extern bool Steady =false; //---- double VQ[]; double SumVQ[]; double DIR[]; double UpBuffer[]; double DnBuffer[]; //+------------------------------------------------------------------+ int init() { IndicatorBuffers(5); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,UpBuffer); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,DnBuffer); SetIndexBuffer(2,SumVQ); SetIndexBuffer(3,VQ); SetIndexBuffer(4,DIR); //---- if (Length < 2) Length=2; if (Method < 0) Method=0; if (Method > 3) Method=3; if (Smoothing < 0) Smoothing=0; if (Filter < 0) Filter=0; //---- string short_name="VQ | "+ Length + " , " + Method + " , " + Smoothing + " , " + Filter + " | "; IndicatorShortName(short_name); SetIndexEmptyValue(0, 0.0); SetIndexEmptyValue(1, 0.0); SetIndexEmptyValue(2, 0.0); SetIndexEmptyValue(3, 0.0); return(0); } //+------------------------------------------------------------------+ int start() { double MH=0, ML=0, MO=0, MC=0, MC1=0; int i, j, limit, counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; //---- if(counted_bars<1) i=Bars-Length-1; else i=Bars-counted_bars; if(counted_bars<1) { j=Bars-Length-1; SumVQ[j + 1]=Close[j + 1]; } while(i>=0) { MH=iMA(NULL,0,Length,0,Method,PRICE_HIGH,i); ML=iMA(NULL,0,Length,0,Method,PRICE_LOW,i); MO=iMA(NULL,0,Length,0,Method,PRICE_OPEN,i); MC=iMA(NULL,0,Length,0,Method,PRICE_CLOSE,i); MC1=iMA(NULL,0,Length,0,Method,PRICE_CLOSE,i+Smoothing); if (Steady==true) { MC=iMA(NULL,0,Length,0,Method,PRICE_MEDIAN,i); MC1=iMA(NULL,0,Length,0,Method,PRICE_MEDIAN,i+Smoothing); } if((MH - ML)>0) VQ=MathAbs(((MC - MC1)/MathMax(MH - ML, MathMax(MH - MC1, MC1 - ML)) + (MC - MO)/(MH - ML)) * 0.5) * ((MC - MC1 + (MC - MO)) * 0.5); SumVQ=SumVQ[i + 1] + VQ; if (Filter > 0) if (MathAbs(SumVQ - SumVQ[i + 1]) < Filter * Point) SumVQ=SumVQ[i + 1]; i--; } if(counted_bars<1) limit=Bars-Length-1; else limit=Bars-counted_bars; for(i=limit-1; i>=0; i--) { if (SumVQ > SumVQ[i+1]) DIR=1; if (SumVQ < SumVQ[i+1]) DIR=-1; if (SumVQ== SumVQ[i+1]) DIR=DIR[i + 1]; if (DIR > 0) { UpBuffer=High; DnBuffer=Low; } else if (DIR < 0) { DnBuffer=High; UpBuffer=Low; } Alert("i=",i,"\n VQ=","\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); } //---- return(0); }
THIS IS MY TRY : -
mh:=Mov(H,5,TIMESERIES);
ml:=Mov(L,5,TIMESERIES);
mop:=Mov(O,5,TIMESERIES);
mc:=Mov(C,5,TIMESERIES);
mc1:=Mov(Ref(C,-1),5,TIMESERIES);
VQI:=Abs(((MC - MC1)/Max(MH - ML,Max(MH - MC1, MC1 - ML)) + (MC - MOp)/(MH - ML)) * 0.5) * ((MC - MC1 + (MC - MOp)) * 0.5);
If(MH-ML>0, VQI=VQI,VQI); SVQI:=Ref(VQI,-1)+VQI; If(Abs(SVQI - Ref(SVQI,-1)<5*.05), SVQI=Ref(SVQI,-1),SVQI)>0;
Thanks,
|