adding stock data to amibroker using c#

May 30, 2010 at 10:14 PM


Can this plugin help with the below?

I have had a hard time getting and answer to this and i would really , really appreciate some help on this.

i have been on this for over 2 weeks without headway.

i want to use c# to add a line of stock data to amibroker but i just cant find a CLEAR response on how to instantiate it in C#.

In VB , I would do it something like;

Dim AmiBroker = CreateObject("Broker.Application")               
sSymbol = ArrayRow(0).ToUpper
                Stock = AmiBroker.Stocks.Add(sSymbol)
                iDate = ArrayRow(1).ToLower
                quote = Stock.Quotations.Add(iDate)
                quote.Open = CSng(ArrayRow(2))
                quote.High = CSng(ArrayRow(3))
                quote.Low = CSng(ArrayRow(4))
                quote.Close = CSng(ArrayRow(5))
                quote.Volume = CLng(ArrayRow(6))

The problem is that CreateObject will not work in C# in this instance.

I found the code below somewhere online but i cant seem to understand how to achieve the above.

Type objClassType;
            objClassType = Type.GetTypeFromProgID("Broker.Application");
            // Instantiate AmiBroker
            objApp = Activator.CreateInstance(objClassType);
            objStocks = objApp.GetType().InvokeMember("Stocks", BindingFlags.GetProperty,null, objApp, null);

Can anyone help me here?


Jan 13, 2014 at 7:16 AM
I got it worked in VC# 2010...

Something like this....

namespace KelvinHand
public partial class Form1 : Form
    public Form1()

    private Object CreateObject(string ProgID)
        Type objType = Type.GetTypeFromProgID(ProgID);
        return System.Activator.CreateInstance(objType);


    private void KelvinHand_Click(object sender, EventArgs e)

        dynamic oAB=CreateObject("Broker.Application");
        dynamic oStocks = oAB.Stocks;
        dynamic Ticker = oAB.ActiveDocument.Name;
        dynamic oStock = oStocks(Ticker);
        dynamic Qty = oStock.Quotations.Count;

        ..... ....