X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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 Files

    Comment


    • #3
      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 Files

      Comment


      • #4
        VPCI - metatrader 4 version ...

        Here as a vpci indicator converted to metatrader 4 (with the addition of colors (as in this modified tradestation version : https://www.forex-tsd.com/tradestati...tml#post482331)

        Attached Files

        Comment


        • #5
          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.

          Comment

          Working...
          X