TWS(IB) AutoTrading is not execution the order

Dear Friends,

I am using the below afl coder for auto trading with IB, but it is not executing the order while doing Bar Reply. Kindly support to correct the afl code issue.

Ex. MACD crossover system, buy ands sell on open Price.

// create instance of trading interface
ibc = GetTradingInterface("IB");

// retrieve orderID from previous run, will be empty if no order was placed before
OrderID = StaticVarGetText("OrderID"+Ticker);

if( TriggerOrder )
{
// check if we are connected OK
if( ibc.IsConnected() )
{
if( Mode == 1 ) OrderID = ""; // if mode set to 'always new' then clear orderid

// place orders only if we do not have already open position on this symbol
// place or modify the order - don't transmit yet
OrderID = ibc.ModifyOrder( OrderID, Ticker,ACT, NumShares, OT, LimitPrice, StopPrice, TIF, Transmit);

// store orderID for next run so we know which order to modify

StaticVarSetText("OrderID"+Ticker, OrderID);

if( Mode == 1 )
Msg = "New order has been placed with ID = ";
else
Msg = "Order placed/modified with ID = ";

Msg = Msg + OrderID + " on " + Now();
}
else
{
Msg = "Placing order failed because of no connection to TWS";
}
}

if( TriggerCancel )
{
if( OrderId != "" )
{
if( ibc.CancelOrder( OrderId ) )
Msg = "Request to cancel order " + OrderID + " sent successfully";
else
Msg = "Request to cancel order " + OrderID + " failed.";
}
else
Msg = "Can not cancel order becase OrderID is empty";

}

execlist = ibc.GetExecList(0,""); // all

execinfo = "";
for( i = 0; ( OId = StrExtract( execlist, i ) ) != ""; i++ )
{
execinfo = execinfo + OID + " Symbol: " + ibc.GetExecInfo( OID, "Symbol" ) +
" Filled: " + ibc.GetExecInfo( OID, "Filled" ) +
" Avg. price: " + ibc.GetExecInfo( OID, "Avg. price" ) + "\n";

}

// monitoring code
Title =
Msg +
"\nLast TWS message: "+ ibc.GetLastError(0) +
"\nAvailable funds: " + ibc.GetAccountValue("AvailableFunds")+
" Gross Pos. Value: " + ibc.GetAccountValue("GrossPositionValue")+
"\nOrderID = "+OrderId+
"\nTicker = "+Ticker+
"\nAction = "+ACT+
"\nShares = "+NumToStr(NumShares,1.0)+
"\nOrderType = "+OT+
"\nLimitPrice = "+NumToStr(LimitPrice,1.3)+
"\nStopPrice = "+NumToStr(StopPrice,1.3)+
"\nTimeInForce= "+TIF+
"\nTransmit = "+NumToStr(Transmit,1.0)+"\n"+
"\nGetStatus = "+ibc.GetStatus( OrderID )+
"\nGetPositionSize = "+ibc.GetPositionSize( Ticker )+
"\nIsConnected = "+NumToStr(ibc.IsConnected(),1.0) +
"\nExecInfo\n" + execinfo;