In the IB controller’s help page there is an example for “Placing and transmitting Market Buy Order for 100 shares when MACD crosses above Signal line”:
Buy = Cross( MACD(), Signal() );
if( LastValue( Buy ) )
ibc.PlaceOrder( Name(), "Buy", 100, "MKT", 0, 0, "Day", True );
If this code is invoked multiple times within a bar’s time frame, does this mean that the last value in the Buy array can toggle on/off as this last (and incomplete) bar is being built?
If yes, than I can have the scenario where in the middle of a 5 minute interval LastValue( Buy ) is 1 and an order is placed, then at the end of this bar the condition is not true. How can this be avoided to only place order when a complete bar is received?
With other tools I have used before my strategy code was notified with a bar when the bar was complete.