Combining different afl for scanning

I have about ten afl scan scripts which are specific to symbols such as afl1 for nflx afl2 for tsla etc, what is the best way to combine these scripts to scan for tomorrow’s signals for watchlist of 10 symbols. Right now i run ten scripts separately on each symbol to see if there is a signal for tomorrow, it is time consuminga nd error prone. Thanks

Combine your individual criteria with a check for the symbol it applies to, then combine them altogether with ORs in your Buy / Sell statements.

Then Scan across a watchlist that contains all the symbols and the Scan will display which symbols have signals on that bar.

Symbol = Name();
NFLXEntry = Cross(MA1, MA2) AND Symbol == "NFLX";
TSLAEntry = Cross(MA3, MA4) AND Symbol == "TSLA";

Buy = NFLXEntry OR TSLAEntry;

Moderator comment: Changed = (assigment) to == (equality check)

That code example is partly incorrect because single “=” operator is assignment operator but not used for equality check. This one is used for equality check: “==”

So for example

check = Symbol == "NFLX";

https://www.amibroker.com/guide/a_mistakes.html

Secondly, (IMO) a cleaner way is checking for symbol first (either using if-else or switch statements). Also since a symbol check such as Symbol == “XXX” is not of type array it rather makes more sense to exclude it from array entry signal variable.

So long story short (IMO) a better way is, i.e.:

switch( Name() ) {
	case "NFLX": 
		MA1 = MA( C, 10 );
		MA2 = MA( C, 30 );
		Entry = Cross(MA1, MA2); break;
	case "TSLA": 
		MA1 = MA( C, 20 );
		MA2 = MA( C, 50 );
		Entry = Cross(MA1, MA2); break;
	default: 
		Entry = False; break;
}

Buy = Entry;

....
......
2 Likes

Spot on @fxshrat. Thanks for the pick up. I was one proof-read short before sending!

One downside of this platform is there is no way for users to alter errors in previous posts…

Thanks for your help, fxshraut solution worked perfectly