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

[amibroker] Load AB data



PureBytes Links

Trading Reference Links

Hi
I'm developing a external NeuralNet  programm to avoid some AB trouble 
like  automatic function run when push down parameter button  not 
resolving with  ParamTrigger 
My aim is to  import only FAVOURITE stocks data  from AB to VB
Although AB OLE is well done it has insufficient details with few 
examples so looking previuos  mails  I was able to develope a little 
VB source
Is that correct way ? 
Do you have any different one ?
How to have direct access to FAVOURITE stock without loop trough all 
stocks (see  OLE Markets Class  ) ?
My TLB-OLE is last Beta ver with AB 4.76beta 
OLE -> http://www.amibroker.com/guide/objects.html
 ------------------------ Start VB Source ----------------------
'Structure 
'Favourite
Type FavStock
  StockBars As Long
  StockIndex As Integer
  StockTicker As String
  StockName As String
End Type
'Historical 
Type Hist
  pOpen As Double
  pHigh As Double
  pLow As Double
  pClose As Double
  pVolume As Double
End Type
'Sub Load data 
Dim  oAB As broker.Application, oStocks As broker.Stocks, oStock As 
broker.Stock
  Dim m As broker.Markets, b As broker.Markets, oQuote As broker.
Quotation
  Dim FavouriteStock() As FavStock, StockHist() As Hist, CountIndex As 
Integer
  Set oAB = CreateObject("Broker.Application")
  Set oStocks = oAB.Stocks
  StockQty = oStocks.Count - 1 ' # of stocks  minus 1
  CountIndex = -1 'Set count to nothing
'Loop trough all securities 
 For i = 0 To StockQty
    Set oStock = oStocks(i)
    If oStock.Favourite Then 'If is favourite stock then retrive 
information
     CountIndex = CountIndex + 1 'increase count
     ReDim Preserve FavoriteStock(0 To CountIndex)
     FavouriteStock(CountIndex).StockIndex = i
     FavouriteStock(CountIndex).StockBars = oStock.Quotations.Count - 
1
     FavouriteStock(CountIndex).StockName = oStock.FullName
     FavouriteStock(CountIndex).StockTicker = oStock.Ticker
  End If
 Next
'Load first favourite stock
'resize array 
ReDim StockHist(0 To FavouriteStock(0).StockBars)
Set oStock = oStocks(FavouriteStock(0).StockIndex)
'retrive "close" data 
For i = 0 To FavouriteStock(0).StockBars
  Set oQuote = oStock.Quotations(i) 'Nr of bar
  StockHist(i).pClose = oQuote.Close
Next
Set oQuote = Nothing
Set oAB = Nothing
Set oStocks = Nothing
Set oStock = Nothing



-------------------------- END VB Source -----------------------
Best regards
B.-






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/