Announcement

Collapse
No announcement yet.

VWAP Premium/Discount Indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VWAP Premium/Discount Indicator

    Hey folks,
    I've been banging my head against a wall trying to figure this out. All I need is a non-price study that tracks whether the last price is above or below vwap as a percentage. Values should only be greater then -100% or less than 100%. I would prefer the data to be tracked as a line.

    VWAP Premium/Discount=(last price - vwap) / vwap

    Type of Study:non price

    Thanks,

    Colton
    Last edited by colton; 08-11-2010, 07:54 PM.

  • #2
    Here's the code I currently have. it doesn't seem to work maybe you guys can figure it out.

    // VWAP Study function preMain() { setPriceStudy(true); setStudyTitle("VWAP"); setCursorLabelName("VWAP"); setDefaultBarFgColor(Color.purple); setDefaultBarThickness(0); setPlotType(PLOTTYPE_SQUAREWAVE,0); BarCount=0; BarAvgPrice=0; CumVolume=0; CumPriceTimesVolume=0; } function main() { nState = getBarState(); var vTime = getValue("rawtime"); if (vTime != null) { var vFirstIndex = getFirstBarIndexOfDay( vTime ); } if (getCurrentBarIndex()==0) { // debugPrintln ("First Bar Index: " + vFirstIndex); i=vFirstIndex; while (i<=0) { // debugPrintln ("i: " + i); vHi=getValue("High",i); vLo=getValue("Low",i); vVol=getValue("Volume",i); vLast=getValue("rawtime",i); BarAvgPrice=(vHi+vLo)/2; CumPriceTimesVolume=CumPriceTimesVolume+(BarAvgPri ce*vVol); CumVolume=CumVolume+vVol; vVWAP=CumPriceTimesVolume/CumVolume; // debugPrintln ("BarAvgPrice: " + BarAvgPrice); // debugPrintln ("vVol: " + vVol); // debugPrintln ("CumPriceTimesVolume: " + CumPriceTimesVolume); // debugPrintln ("CumVolume: " + CumVolume); // debugPrintIn("vVWAP: " + vVWAP); i++; } vVDP=((vLast-vVWAP)/(vVWAP)); // Draw the vVDP line drawLineRelative(vFirstIndex,vVDP,0,vVDP,PS_SOLID, 3, Color.RGB(0,0,0),0); return (vVDP); } }

    Comment


    • #3
      Hi colton,

      I added your fomula to a VWAP efs I found via a forum search:
      FWIW if you use "php" instead of "quote" for your efs code folks won't have to recreate it.

      See attached.

      Note: the output of this version of VWAP does not match the "amVWAP2.efs" written by Alex Montenegro found at: http://share.esignal.com/groupconten...FS2&groupid=10

      If you prefer the "amVWAP2.efs" plot you can make the necessary modifications to it to get the % results you are looking for.

      Wayne
      Attached Files
      Last edited by waynecd; 08-21-2010, 05:37 AM.

      Comment


      • #4
        I made some changes to another efs I found. It is a much better VWAP plot with user selectable Premium Discount or VWAP plots.

        See attached.

        Wayne
        Attached Files

        Comment

        Working...
        X