Like Tree2Likes
  • 2 Post By mladen

Thread: VPCI Indicator. What's wrong? (Tradestation to MT4)



  1. #1
    JoeMcCool is offline Junior Member
    Join Date
    Feb 2011
    Posts
    12
    Points
    137
    Credits
    238
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow

    VPCI Indicator. What's wrong? (Tradestation to MT4)

    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):
    Code:
    #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);
    }
    And the tradestation code

    Code:
    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" ) ;
    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.gif

    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

  2. #2
    Join Date
    Oct 2006
    Posts
    24,288
    Points
    28,810
    Credits
    442,660
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    114
    Following
    0
    Follow
    For now just posting this to add picture directly (so it is visible right away) and a link to description (to help all interested in in it : it is a TASC July 2007 description of it Traders Tips - July 2007 )
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	vpmo vs vpci 2008-04-07_124855.gif 
Views:	83 
Size:	20.9 KB 
ID:	149006  
    "An error does not become a mistake until you refuse to correct it ... tradcode site , tradcode on facebook page and my facebook page ...

  3. #3
    Join Date
    Oct 2006
    Posts
    24,288
    Points
    28,810
    Credits
    442,660
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    114
    Following
    0
    Follow
    Was curios what will it look like on metatrader real data (and "volumes")
    It actually seems to be interesting on shorter time frames (this is a 15 minute metatrader data used for example)
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	vpci.gif 
Views:	99 
Size:	33.6 KB 
ID:	149007  
    "An error does not become a mistake until you refuse to correct it ... tradcode site , tradcode on facebook page and my facebook page ...

  4. #4
    Join Date
    Oct 2006
    Posts
    24,288
    Points
    28,810
    Credits
    442,660
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    114
    Following
    0
    Follow

    VPCI - metatrader 4 version ...

    Here as a vpci indicator converted to metatrader 4 (with the addition of colors (as in this modified tradestation version : http://www.forex-tsd.com/tradestatio...tml#post482331)
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	vpci.gif 
Views:	171 
Size:	31.4 KB 
ID:	149012  
    Attached Files
    AtApi and timetech111 like this.
    "An error does not become a mistake until you refuse to correct it ... tradcode site , tradcode on facebook page and my facebook page ...

  5. #5
    JoeMcCool is offline Junior Member
    Join Date
    Feb 2011
    Posts
    12
    Points
    137
    Credits
    238
    Post Thanks / Like
    vBActivity - Stats
    vBActivity - Bars
    Follows
    0
    Following
    0
    Follow
    Thank you mladen,
    excellent work. i should have ask earlier, so i would not have spend so much time at my "beginner" code.

    I agree, it looks better in smaller timeframes but also not bad in higher. It could be helpfull, maybe in combination with other indicators or different settings.



» Rankings

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can someone convert indicator from Tradestation to MT4?
    By dasio in forum MetaTrader Programming
    Replies: 1
    Last Post: 12-24-2012, 08:09 AM
  2. TTF+MW Indicator - Any idea what's wrong?
    By disavowed in forum Metatrader 4
    Replies: 5
    Last Post: 02-12-2008, 08:04 AM
  3. What's wrong? Please go through it
    By cobby in forum Metatrader 4
    Replies: 1
    Last Post: 08-09-2007, 10:11 PM
  4. What is wrong here ????
    By junglelion in forum Metatrader 4
    Replies: 6
    Last Post: 06-24-2007, 06:27 PM
  5. What's wrong with this EA ?
    By rjay in forum Metatrader 4
    Replies: 1
    Last Post: 12-16-2006, 12:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •