[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: COM object helps needed.



PureBytes Links

Trading Reference Links

Mike

you need to define Price and pds at the top of your code. For 
instance - 

Price = close;
pds = 14;

allows the script to run and gives graphical output.

Stefan

--- In amibroker@xxxx, Mike Pham <mmqp@xxxx> wrote:
> 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