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

Help accessing AB objects from Jscript.



PureBytes Links

Trading Reference Links

Hi,

I am trying to access Volume datas from AB databases and calculate a 
simple 90DMA on the volume; However when running the Script, 
the "Object Required" error keep appearing. I am not sure if I 
declared the AB object correctly or the code must be run inside AB. 
The following are part of the script (BTW, this codes was extracted 
from "Export.js" which TJ included for ASCII export). TIA 

var Qty, accVolume, volumeFilePtr,i, oStock, oQuote;

/* AmiBroker objects definition and declarations */
var oAB = WScript.CreateObject("Broker.Application");
var oStocks = oAB.Stocks;

ticker = "^DJI";
volumeFilePtr = fileSystemObj.OpenTextFile ("C:\\Program 
Files\\AmiBroker\\Scripts\\" + ticker + "_volume90DMA.txt", 
ForWriting, true);

oStock = oStocks(ticker);
Qty = oStock.Quotations.Count;

for( i = (Qty-91); i < (Qty-1); i++ )
{
oQuote = oStock.Quotations( i );
accVolume += oQuote.Volume;
volumeFilePtr.WriteLine( i+91 + "," + oQuote.Volume + "," + 
accVolume );
}

avgVol = accVolume / 90;
volumeFilePtr.WriteLine( i+91 + "," + accVolume + "," + Math.round 
(avgVol) );

volumeFilePtr.close ();