Problems with getPositionsize



I am trying to automate Amibroker strategy with Interactive brokers. I have gone through the whole literature and user groups regarding the same. So i am testing right now in a paper trading account with IB.
Whenever i try to get GetPositionSize, it always returns 0 , irrespective whether there is a position or not. I am trying with the following code:

ibc = GetTradingInterface("IB");
PopupWindow( NumToStr(ibc.GetPositionSize(Name1),1),"Alert for Size",120);

But when it comes to executing order etc, it works fine. Would appreciate if someone can give guidance on this.


Now i understand that my Portfolio and Account information tab in IB controller are empty, that is the reason i don’t see Position size because GetPositionSize displays Position column from portfolio tab.
Any clue, why they would be empty?


GetPositionSize reads the “Positions” tab in the IBController. This page in turn is filled exactly what what TWS API returns (you need to be connected to TWS running instance and you have to have account with TWS, not demo)


I understand , thanks. So in a demo account Getpositionsize is not available. How can i simulate IB ordering through Amibroker, to check whether what i have written works or not , before going to live?


They have “paper trading” account for proper testing.

Also DEMO “account” page works BUT demo does not allow to open position on any symbol, but only on small number of stocks chosen by IB (try common US stocks like IBM, MSFT)


My account says i am on a paper trading account. Though i confirm with IB on that.
But following are the messages which i get in IB controller: