How to exit (an *.afl or code block) when interval is not matched?

I'm wrting some code for [Explore],
I want to let one Explore.afl work only in 5-minute time frame.

I did the following code (but not work)
if( Interval() != in5Minute ) return;

Q) Please tell me the correct syntax to exit a *.afl
or to exit a code block on AmiBroker, Thank you :slight_smile: !

You can do this in a two ways:

  1. If you want to STOP the execution of exploration at all you can trigger error:
if( Interval() != in5Minute ) Error("Interval selected is incorrect");
  1. If you want to "do nothing" silently, you can just assign zero to filter:
if( Interval() != in5Minute ) 
{
  Filter = 0;
}
else
{
   // your normal exploration code
}

If you want to display message in the list view without displaying anything more:

if( Interval() != in5Minute ) 
{
  Filter = 0;
  if( Status("stocknum") == 0 ) AddRow("Wrong interval");
}
else
{
   // your normal exploration code
}
4 Likes