The bold green line is actually the +2 standard deviation line. The second (or middle) green line is the vwap line. The reason you are confused is because you have yet to update the preMain settings to properly label and format the three lines. Also the jagged affect of the top line is due to the square wave plot type that is currently being applied. For more specifics on the available preMain settings, please see the preMain Functions folder in the EFS2 Function Reference in the EFS Knowledgebase (see link at bottom of this post).
Jason K.
Project Manager eSignal - an Interactive Data company
The bold green line is actually the +2 standard deviation line. The second (or middle) green line is the vwap line. The reason you are confused is because you have yet to update the preMain settings to properly label and format the three lines. Also the jagged affect of the top line is due to the square wave plot type that is currently being applied. For more specifics on the available preMain settings, please see the preMain Functions folder in the EFS2 Function Reference in the EFS Knowledgebase (see link at bottom of this post).
Hi Jason
Thanks, thats worked well, but its highlighted another problem: In main() there's the following line:
xStdDev = dsLib.dsStdDev(20,xVWAP);
That sets a 20-day period for the calculation of the SD, however the whole pupose of altering the script with the latest pieces of code was to get the SD calculated afresh from each market open. That line is forcing a 20-day period. I tried removing it, but then got a script error, so could u tell me what to do with that one? If you look at my last post - the chart graphic there is updated and will show what i mean
Thanks, thats worked well, but its highlighted another problem: In main() there's the following line:
xStdDev = dsLib.dsStdDev(20,xVWAP);
That line was part of the first solution I suggested and should be deleted.
The error you get though is caused by this line var nStdDev = xStdDev.getValue(0);
which should also be deleted. Once you have done that remove || nStdDev == null
from the following line of code if(nVWAP==null || nStdDev == null) return;
Lastly to complete cleaning up residual code left over from the first solution you should also remove the following two lines var dsLib = addLibrary("dsFunctions.efsLib");
var xStdDev = null
which are not required
Alex
Originally posted by Alexis C. Montenegro Les
That line was part of the first solution I suggested and should be deleted. The error you get is caused by this line var nStdDev = xStdDev.getValue(0);
which should also be deleted. Once you have done that remove || nStdDev == null
from the following line of code if(nVWAP==null || nStdDev == null) return;
Lastly to complete cleaning up residual code left over from the first solution you should also remove the following two lines var dsLib = addLibrary("dsFunctions.efsLib");
var xStdDev = null
which are not required
Alex
Alex
I did as you said, and then got another syntax error regarding line 77, viz:
xStdDev = dsLib.dsStdDev(20,xVWAP);
I commented this out, and now seems ok, but could you confirm this as well. I updated the chart graphic posted below, which reflects the change.
Originally posted by Alexis C. Montenegro Les
That is the line you asked about in your prior message (see quote below) to which I replied saying it should be deleted
Alex
Oops yes, quite right. Many thanks for your and Jason's efforts with this one. I suggest, if you've not done so already that the original VWAP study and this VWAP study with SD's, is made available to others. Perhaps on this board under the Volume section.
Les
I would love a copy of the amvwap.efs w/std. dev. lines if it could be posted somewhere.
To contribute to the .efs library, here is the code for a small .efs I had programed called X Day Hi/Lo. It plots any number of previous day am and/or pm hi/lo's. The am/pm cutoff times are user controlled, and colors and line widths are customizable. If someone could post it in an appropriate folder I would be appreciative. Thanks. Happy Holidays! Steve
//External Variables
var grID = 0;
var nBarCounter = 0;
var nDays = 0;
var nOffset = 0;
var nThick = 0;
var nTime = 0;
var nDisplay = 0;
var aData = null;
var vSymbol = null;
var aFPArray = new Array();
var bDone = false;
var bDrawn = false;
var bInitialized = false;
//== PreMain function required by eSignal to set things up
function preMain() {
var x;
//return the bar time as elapsed minutes
function getTime( nOffset ) {
return( (getHour(-nOffset)*60) + getMinute(-nOffset) );
}
function scan( nDays, nCutoff, aArray ) {
var x=0;
var nH1 = -999999999999.0;
var nL1 = 999999999999.0;
var nH2 = -999999999999.0;
var nL2 = 999999999999.0;
var nTotDays = 1;
var nThisDay;
var nOffset = 0;
var nObj = null;
var xTime = getValue( "rawtime", 0 );
if ( xTime==null ) return( null );
//get offset back to first bar of today
if ( xTime != null ) {
nOffset = getFirstBarIndexOfDay( xTime );
}
if ( nOffset==null ) return( null );
nOffset--;
//walk back through time
x=nOffset;
while( true ) {
nThisDay = getDay(x);
//error, so get out
if ( nThisDay==null ) return( null );
nTime = getTime( Math.abs( x ) );
//get h/l from afternoon
if ( nTime>=nCutoff ) {
nH1 = Math.max( nH1, high(x) );
nL1 = Math.min( nL1, low(x) );
}
//get h/l from morning
else if ( nTime<nCutoff ) {
nH2 = Math.max( nH2, high(x) );
nL2 = Math.min( nL2, low(x) );
}
x--;
//moving into a new day
if ( getDay(x) != nThisDay ) {
nObj = new Object();
nObj.AMH = nH2;
nObj.AML = nL2;
nObj.PMH = nH1;
nObj.PML = nL1;
aArray[nTotDays-1] = nObj;
nObj = null;
//collected enough days, get out
nTotDays++;
if ( nTotDays>nDays ) {
break;
}
I have learned and was able to add the plot types for the lines and changed the colors of each line to meet my needs... However... there is a new problem. The stdDev lines are not plotted in the correct locations.
I consulted with a colleague who uses the vwap with stdDev's. He doesnt use esignal but is somewhat versed in java and other code. It seems that the calx for the stdDev is wrong. Here is our conversation:
"
<jp> Remember that the 1st Stdev has to be weighted by volume
<jp> so how does he compute nSTdDev
<Nereus> i don't know
<jp> all I need to see is the class for nSTDev
<Nereus>ok... here it is...
function StdDev(length, price) {
if (getCurrentBarCount()<length){
return;
}
var sumX = 0;
var sumY = 0;
for (var i=0; i<length; i++) {
sumX += price.getValue(-i);
sumY += (price.getValue(-i)*price.getValue(-i));
}
> var meanX = (sumX/length);
var stddev = Math.sqrt((sumY/length)-(meanX*meanX));
return stddev;
}
<Nereus> is that it?
<jp> yes
<jp> I think I see the problem...
<jp> He didn't weight each summation by the volume at each price...
<jp> Each sumX should be weighted by its volume
<Nereus> so... everywhere is says SumX?
<jp> yes...when he computes the variance(the difference between each price and the VWAP...
<jp> he has to multiply it by the volume at that price
<jp> And then divide the whole sum by the total current volume
for the day.
<Nereus> which lines need this change?
<jp> the sumX lines and the meanX
<jp> tell him to read the section on STDEV at this link:
<jp> http://mathworld.wolfram.com/StandardDeviation.html
<jp> and previous sections on that site...
<jp> It gives a very coherent explanation on how to compute...
<jp> the StDev from the distribution function
<Nereus> ok... i will convey this to my buddy "
Could someone post what the correct efs script should be that will enable the calx to work properly?
I'm certain that the standard deviation function Alex is using is correct. I think you need to send the EFS code to your friend in its entirety. What you are missing is that the price parameter being passed to the function is already adjusted for volume so there's no need to do it within the function. If the price parameter was simply the close, then yes, you would need to make the volume adjustments within the function. Hope this helps.
Jason K.
Project Manager eSignal - an Interactive Data company
Thanx Jason for your reply...
However.. there is something not quite right. Below are pics of my colleage's chart and of mine for Dec, 6th. Please notice key price points such as at 11:15est, approx 688.40, touches the -2 stdDev on one (his) chart, while on my chart it just barely penetrates the -1 stdDev. Also note where the +2 stdDev closes at 16:15est on his chart (approx 694.1) and on my chart (693.2).
Also.. here is further corresponce with colleague...
<jp> also take a look at equation 2 here for the variance computation...
<jp> http://mathworld.wolfram.com/Variance.html
<jp> You will note that each term in the variance is multiplied....
<jp> by P(x) before the summation is done....
<jp> P(x) is the volume distribution function I have been talking about.
Nereus
I have checked my code and as far as I can see it is computing the Standard Deviation of the VWAP correctly .
At this point I would suggest that you have your colleague or alternatively one of the EFS Consultants write the efs for you.
Alex
Comment