IBC triggering order every sec even in 15 sec time frame

Following program displays time array and IBC order number.

if we run program in 15 sec time frame,
Time array is updated every 15 sec but IBC order number is updated every sec.

Why this is so ? if program runs after every sec then both should be updated every sec or if program runs every 15 sec, then both should be updated every 15 sec.

Can somebody please explain this behavior, Thanks

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Buy =1;

ibc = GetTradingInterface("IB");
BuyOrderID= ibc.PlaceOrder( "MSFT", "Buy", 100, "MKT", 0, 0, "Day", True );

Title = "\n"+ 
"Time : "+NumToStr(LastValue(Second()))+"\n"+ 


Your code is wrong. You are making assumptions that are false.
Code can and will be executed MANY times on number of occasions NOT related to bar interval, see: http://www.amibroker.com/kb/2015/02/03/when-and-how-often-afl-code-is-executed/

You need a STATE MACHINE and check the STATE (status) of previously placed order and/or open positions.
You have to follow examples given in http://www.amibroker.org/userkb to avoid repeated orders.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.