PureBytes Links
Trading Reference Links
|
Hi,
Can someone with COM objects experience please take a
look at following codes to see if it is syntaxically
OK. TIA
EnableScript("jscript");
S1Volume = Volume; // saving the database volume.
x=Cum(1); // X-axis.
totalBars=LastValue(x);
LowestLowBar = 1+LastValue(LLVBars(Price,pds)); //
single bar value at lowest Price within pds period
S1LaunchDate = totalBars - LowestLowBar ; // j th
lauch date.
<%
function myCalculate_SR (Price,S1Volume,LaunchBar)
{
var i;
Price = AFL("Price").toArray(); // get Price array
from AFL side.
Volume = AFL("Volume").toArray();
SRArray = new Array();
for (i=0; i<SRArray.length; i++)
{
SRArray[i]=-1e10; // initialize entire SRArray
}
cumVolArray = new Array();
cumPriceVolArray = new Array();
cumVolArray [LaunchBar -1] = 0; // cumvol start at 0
so end of first day cumVol=V[1]
cumPriceVolArray[LaunchBar -1] = 0; // cumPriceVol
start at 0 so end of first day cumPriceVol=P[1]*V[1]
for( i = LaunchBar; i < Price.length ; i++ )
{
cumVolArray[i] =cumVolArray[i-1]+Volume[i];
// compute cumVolArray
cumPriceVolArray[i]=cumPriceVolArray[i-1]+(Price[i]*Volume[i]);
// compute cumPriceVolArray
SRArray [i]= (cumPriceVolArray[i] - cumPriceVolArray
[LaunchBar])/(cumVolArray[i] - cumVolArray
[LaunchBar]);
}
return SRArray;
} // end of function myCalculate_SR
%>
scriptObj = GetScriptObject();
S1 =
scriptObj.myCalculate_SR(Price,Volume,S1LaunchDate);
Plot (S1, "S1", 4,5);
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
|