Australian (ASX) Stock Market Forum

How to open an Amibroker chart externally (e.g. by hyperlink in Excel?)

Joined
6 July 2013
Posts
15
Reactions
0
Anyone have any ideas on how I can open an Amibroker chart from a hyperlink in Excel? Would it be a case of saving each chart in AB as a 'xxx.chart' and then creating a hyperlink to that? Any other ways to do this?
 
Yes Richard, you can absolutely do that via VBA and OLE

vqml.png

So here in cell A2 you define the symbol that shall get selected and in cell B2 you define the sheet number of active chart then a click of the button will set sheet and symbol in AB.
 
Played around with macros a little bit and you could also prepare a list of symbols in Excel and making clickable cells that execute a macro on click and after clicking each one of those cells the chart of the selected symbol of each cell will get chosen in AmiBroker.
9qw.gif


Out of interest what's the purpose?
 
Code:
Function ExcelToAB()
  Dim AB As Object
  Dim StockName As String
  Dim ActiveDoc As Object
  Dim ADS As Object
  Dim SheetNo As Integer

  ActiveSheet.Activate
  StockName = Trim(ActiveCell.Value) 'Trim(Worksheets(1).Range("$A$2").Value)
  If StockName = "" Then End

  Set AB = CreateObject("Broker.Application")
  Set ActiveDoc = AB.ActiveDocument
  Set ADS = AB.Documents

  ' set sheet number of currently active/selected AB chart tab defined in Excel Cell B2
  SheetNo = Worksheets(1).Range("$B$2").Value
  AB.ActiveWindow.SelectedTab = (SheetNo - 1) ' sheet of currently active AB chart

  ' set symbol of excel cells A2:A7 in AmiBroker
  ActiveDoc.Name = StockName

  AB.RefreshAll

  Set ActiveDoc = Nothing
  Set ADS = Nothing
  Set AB = Nothing
End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("A2:A7", "B2:B2")) Is Nothing Then
        func = ExcelToAB()
    End If
End Sub
 
Thanks! The first solution is exactly what I was looking for and the macro works perfectly just as you coded it.

The reason I need to do this is because my main 'trading platform' is actually in Excel and in Excel I have certain functions which I think would be extremely difficult to integrate into Amibroker (although not impossible, I'm sure). For example, one of my trading rules is to avoid trading any stock which is within +/- 3 days of releasing its financial results, or some other certain announcements such as profit warnings. So, in Excel I have real time links to the Stock Exchange's announcements page and Excel will automatically highlight all of these 'non-tradeable' stocks.

Another example is that I have a scoring system which evaluates trading opportunities (i.e. buy signals) not just on technical criteria but fundamental / valuation criteria as well.

So in other words, my 'watchlist of tradeable stocks' is dynamic and changes day by day, so I can't just scan through all the Amibroker charts looking for technical trading opportunities, they have to be screened via Excel first.. and THEN I can start looking at the charts - and this is why I need to open the charts via Excel!


You wanna open a different chart template via OLE?
Not sure if you can do this.

Update:

Seems you can load and save template via OLE:
Function LoadTemplate(ByVal lpszFileName As String) As Boolean
Function SaveTemplate(ByVal lpszFileName As String) As Boolean

http://www.amibroker.com/guide/objects.html‎
 
Thanks for insight! Got it.
Yeah, it certainly is possible to move all that to AB. But since you have it readily available in Excel I would just leave as it is.
 
Top