Exploration/scanning "only" for specified DB

Example: I have 3 different Database.

1: ABStock
2: ABIndex
3 ABFutures

I have an exploration formula and and I want to run it only in the database ABIndex and not in any other. (and if possible... signaling me with a popup or in other way which DB work with this formula)

(In this way I want to prevent my mistake made by distraction [example: fill watchlist which are set differently by dB ] )

I think we can add a condition at the beginning of code.... but what?

You can retrieve current Database's name using GetDatabaseName() and you can add this condition to the Filter --> https://www.amibroker.com/guide/afl/getdatabasename.html

1 Like

ok I'll go to watch. Thanks for the fastest reply :slight_smile:

Filter is OK but it is rather used for array filtering.
So instead you might rather disable entire exploration execution for unwanted DBs via if() statement.

db_str = "ABIndex"; // your DB name to run exploration with

if ( StrMatch(GetDatabaseName(), db_str ) ) {
    // your exploration code here
    // ......
    Filter = C > O;
    AddColumn( O, "Open", 1.2);
    AddColumn( C, "Close", 1.2);
} else {
    Filter = 0;
    Error(StrFormat("Wrong DB for this exploration code. Open DB '%s'.", db_str ));

If it is wrong DB then upper sample returns error in Analysis window



I was just trying now with if.... and I saw your answer now...

Thank you so much!

and if I want a popup (better for me)...:

PopupWindow("WRONG DB . PLEASE OPEN DB: " + (StrFormat("%s'", db_str )), "Alert", 5, -1,-1,300, 80,True );

PS: I have AB open in 2nd monitor and if I modify the "-1" (x-y position) parameters, the box show me this alert in the 1st monitor)

corrected now (was my mistake)

PopupWindow("WRONG DB . PLEASE OPEN DB: " + (StrFormat("%s'", db_str )), "Alert", 5, 1800,80,300, 80,True );