Problem Example=>
Filter watch list A have 2 stocks=> a,b
Filter watchlist B have 2 stocks=> e,f
Buy=buylogic
Sell=selllogic
Short=shortlogic
Cover=coverlogic
Now Output needed :
Buy/sell signals and buy price/sell price array should be on stock a and B
Short/cover signals and short/cover price array should b on stock e and f
Suggestion from expert needed.
@Puneet You could try something like this:
if (Name() == a || Name() == b)
{
Buy = buylogic
Sell = selllogic
Short = 0;
Cover = 0;
}
else if (Name() == e || Name() == f)
{
Buy = 0;
Sell = 0;
Short = shortlogic
Cover = coverlogic
}
Dear Steve,
thanks for reply.
This idea is good when we have very few selected symbols and when we run backtest on all symbols. Then it will choose corresponding symbols for buy/sell/short/cover respectively.
But it is not solving below purpose.
- Suppose a watch list A is big say 20 or more stocks in it and we need 5 stocks from it to Buy. And
- Other watch list B have 10 different symbols and we need two of them to short. Then how the purpose will solve.
In summary: how can different watchlist be used for Buy/sell and short/cover in same AFL.
Rgds
Perhaps you could use InWatchlistName()
instead of checking for individual symbols? https://www.amibroker.com/guide/afl/inwatchlistname.html