Hello guys,
i have found a VPCI indicator for tradestation and tried to code it for MT4, because i couldn't find a similar version. I took another VPCI (MT4) and just change a bit. i'm not that good at programming. Seems like it works but my MT4 version does not look like the tradesation version.
Here is my Code (MT4):
And the tradestation codeCode:#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Yellow extern int period=5, LongTermPeriod=20, double VPCI[]; double VPCISmooth[]; int init() { string short_name="VPCI"; SetIndexBuffer(0,VPCI); SetIndexStyle(0,DRAW_LINE); SetIndexLabel(0,"VPCI"); IndicatorShortName(short_name+"("+period+","+LongTermPeriod+")"); return(0); } int start() { int counted_bars=IndicatorCounted(); int limit=Bars-counted_bars; double VolumeSum1,VolumeSum2,VWMA1,VWMA2,VPR,VM,VolPriSum1,VolPriSum2,VP; for(int i=0;i<limit;i++) { VolumeSum1=0; for (int l=i;l<i+period;l++) { VolumeSum1+=Volume[l]; } for (l=i;l<i+LongTermPeriod;l++) { VolumeSum2+=Volume[l]; } for (l=i;l<i+period;l++) { VolPriSum1+=Volume[l]*Close[l]; } for (l=i;l<i+LongTermPeriod;l++) { VolPriSum2+=Volume[l]*Close[l]; } if (VolumeSum1>0) VWMA1 = VolPriSum1/VolumeSum1; if (VolumeSum2>0) VWMA2 = VolPriSum2/VolumeSum2; VP = VWMA2 - iMA(NULL,0,LongTermPeriod,0,0,0,i); VPR = VWMA1/ iMA(NULL,0,period,0,0,3,i); VM = (VolumeSum1/period)/(VolumeSum2/LongTermPeriod); VPCI[i]=VP * VPR * VM; } return(0); }
You can find a picture of it here: h**p://www.traderslaboratory.com/forums/attachments/56/5912d1207587090-volume-price-action-momentum-indicator-vpmo-vs-vpci-2008-04-07_124855.gifCode:inputs: Price( Close ), Length1( 5 ), Length2( 20 ), VPCIAvgLen( 20 ) ; variables: VolValue( 0 ), VolumeSum1( 0 ), VolumeSum2( 0 ), VWMA1( 0 ), VWMA2( 0 ), VP( 0 ), VPR( 0 ), VM( 0 ), VPCI( 0 ), AvgVPCI( 0 ) ; if BarType >= 2 then { not tick/minute data } VolValue = Volume else VolValue = Ticks ; VolumeSum1 = Summation( VolValue, Length1 ) ; if VolumeSum1 > 0 then VWMA1 = Summation( Price * VolValue , Length1 ) / VolumeSum1 ; VolumeSum2 = Summation( VolValue, Length2 ) ; if VolumeSum2 > 0 then VWMA2 = Summation( Price * VolValue , Length2 ) / VolumeSum2 ; VP = VWMA2 - Average( Price, Length2 ) ; VPR = VWMA1 / Average( Low, Length1 ) ; VM = Average( VolValue, Length1 ) / Average( VolValue, Length2 ) ; VPCI = VP * VPR * VM ; AvgVPCI = Average( VPCI, VPCIAvgLen ) ; Plot1( VPCI, "VPCI" ) ; Plot2( AvgVPCI, "VPCISmooth" ) ; Plot3( 0, "Zero" ) ;
And here another one with the code under it: h**p://www.traders.com/Documentation/FEEDbk_docs/2007/07/TradersTips/TradersTips.html#tradestation
I don't added the MA on it, don't know how to do it. If someone has the time it would be nice.
But more important where is my mistake?
THX
Joe



1Likes
LinkBack URL
About LinkBacks





Reply With Quote
Bookmarks