Hello - I am new to IBC and have been paper testing my code to make sure commands are getting through before I go live. For simplicity, I have been testing the commands using a simple buy/sell strategy since my goal is to make sure alerts are transmitted. My goal is to use this to run through an entire watchlist of 20+ tickers, however, I keep running into the same issue. IBC is not receiving all my buy alerts. Only 8 will get through and then passed on to IB. I have changed the watchlist in size several times but the limit of 8 tickers is never solved. So for a list of 20 buy signals, only 8 are coming through.
Any idea what I am doing wrong? Thanks
Buy = TimeNum() <= 143000;
Sell = TimeNum() >= 143500;
AlertIF( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
Quantity = 10; //Currently using 10 shares to trade low numbers and test IB. Then need to revert back to this algo: (CashBalance * Position3)/LastValue(C);
Quantity = Max(1, round(Quantity));
SetPositionSize (Quantity, spsShares); //we would change this to intrgate Position3 Static Var
Stopper = Optimize ("TrailingStop", 2.5, 0.5, 3, 0.5);
ApplyStop( stopTypeTrailing, stopModePercent, Stopper, True );
TrailingAmount = Stopper/100 * LastValue(C);
Symbol = Name();
//if (LastValue(Buy) || LastValue(Sell)) {
ibc = GetTradingInterface( "IB" );
if (ibc.IsConnected() ) {
//openPosList = ibc.GetPositionList();
pos = ibc.GetPositionSize(Symbol);
pendingOrderId = StaticVarGetText("pendingOrderIdKey");
BuyOrderID = StaticVarGetText("BuyOrderID");
SellOrderID = StaticVarGetText("SellOrderID");
BuyPending = ibc.IsOrderPending(BuyOrderID);
SellPending = ibc.IsOrderPending(SellOrderID);
if( NOT BuyPending ) StaticVarSetText("BuyOrderID","");
if( NOT SellPending ) StaticVarSetText("SellOrderID","");
if (LastValue(Sell) AND SellOrderID == "") {
if (pos > 0) {
SellOrderID = ibc.PlaceOrder( Symbol, "Sell", Quantity, "MKT", LastValue(C), 0, "GTC", False, 1000 );
StaticVarSetText("SellOrderID",SellOrderID);
}
}
else if (LastValue(Buy) AND BuyOrderID == "") {
if (pos == 0){
if (NOT ibc.IsOrderPending(pendingOrderId)){
CashBalance = StrToNum(ibc.GetAccountValue("CashBalance"));
BuyOrderID = ibc.PlaceOrder( Symbol, "Buy", Quantity, "MKT", 0, 0, "Day", False, 1000 );
ibc.PlaceOrder(Symbol, "Sell", Quantity, "TRAIL", 0, Trailingamount, "Day", False, 1000, BuyOrderID);
StaticVarSetText("BuyOrderID",BuyOrderID);
}
}
else {
_TRACE("Order for "+symbol+" already exists!");
}
}
}
else {
Error("IB Controller Interface is not connected");
}
//}