Hello guys,
I'm missing a bit to connect the dots in my workflow... hopefully someone will have an opinion on an efficient way to do this.
My AFL contains both backtesting and the exploration part in an "if ( Status( "action" ) == actionExplore )" block.
Backtest and exploration rely on "trying" to buy the top X ranked stocks using a limit order.
So it's using a low-level CBT for the limit order and StaticVarGenerateRanks to filter the top X ranked stocks for the last bar.
rank = StaticVarGet( "rankvalues_" + symbol );
Filter = Buy AND rank <= MaxPositions;
Now the exploration give me the top X stocks for which I should send a buy limit order to IB for the last bar.
I have tried to call the ibc.PlaceOrder function ONLY for the top X ranked stocks but I keep getting the message : Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type. You can not use array here
if( ibc.IsConnected() AND LastValue(Buy) AND LastValue(rank) <= MaxPositions) // check if connection to IB was successfull
{
ibc.PlaceOrder(Name(), "BUY", 100, "MKT", 0, 0, "DAY", False ); // place order but do not transmit yet
}
I don't understand why I get this message since LastValue(Buy) and LastValue(rank) <= MaxPositions are both equal to 1.
Is it just a dumb programming error on my part or should I code the sending to IBcontroller elsewhere ?
Thanks a lot,