I have a big problem. When I use my AFL program in real life, the FILTER command does not give me the same results as the BUY command the day after.
I mean, I use a FILTER like:
//variable ultimabarra--> Just to avoid delisted stocks
Ultimabarra=( Ref(BarIndex(),1) == LastValue(BarIndex()) OR BarIndex()==LastValue(BarIndex() ) )
AND Year()<=2022 ;
Filter= C>=HHV (c,100) AND NOT ultimabarra;
I explore using stocks data updated until yesterday and I obtain, e.g. 10 stocks, order by one rule,:
IBM
Apple
Microsoft,
Citibank,
Amazon,
America bank,
etc
I should buy for example, the first 2 stocks: IBM and Apple
But the day after, when I have the new stocks data updated, I launch the AFL code, using the BUY command: (I use tradelay 1)
BUY= C>=HHV (c,100) AND NOT ultimabarra;
The BUY command has exactly the same rules as the FILTER.
But the backtest only buys 1 stock, for example citibank.
So, explore and backtest are different.
But, and this is incredible, if I use the explore using
FILTER= BUY;
Then the FILTER command in the explore mode shows me only Citibank. And the explore and backtest are the same.
But, the rest of the stocks should be shown because they accomplish the rules.
I can not understand this. I need the FILTER and the BUY show the same stocks, in order to use the AFL in real time..
Any idea?
Thanks