Doing string matches

I have a afl code that applies to both stocks and forex and so i want to check if the string is having idealpro in it and so will apply the volume filters.
i did a code sample but this seems to not work. can you help me?
The string match always returns false. However when i type the Name() in commentary box, it returns USD.JPY-IDEALPRO-CASH
so i am confused on what mistake i am making.

volumeCheck= StrMatch( "-IDEALPRO-CASH",Name()) OR ( V > MA( V, 50 ) * 1.4 AND MA( V, 50 ) > 250000 );
pricecheck =StrMatch( "-IDEALPRO-CASH",Name()) OR MA( C, 15 ) > 1 AND  MA( C, 15 )<40;

If you want to use StrMatch() to check if a string: "USD.JPY-IDEALPRO-CASH" contains : "-IDEALPRO-CASH", you should additionally use wild-card character "*":

The function returns TRUE (1) or FALSE (0) whenever string matches searchstring or not. Searchstring is can contain wild-card characters such as:
" * " - matches any string, including empty strings
" ? " - matches any single character

https://www.amibroker.com/guide/afl/strmatch.html

EnableTextOutput( False );
String1 = "USD.JPY-IDEALPRO-CASH";
String2 = "-IDEALPRO-CASH";
printf( "Match:  " + StrMatch( String1, "*" + String2 ) );

1

Alternatively you can also use StrFind(): https://www.amibroker.com/guide/afl/strfind.html

7 Likes