Kum001
August 23, 2018, 4:25pm
#1
Hi,
I want to run my AFL between market hours.So i am using the below code. Here i am trying to run between 10 AM to 3 PM. Please correct me what is wrong in the code.PFA for the error message.
if (100000<TimeNum() AND TimeNum()< 150000)
{
// MY AFL CODE
}
As mentioned by @fxshrat in ValueWhen - how to use a typical mistake users make is that they mix up if statement with IIf() function.
IIf() (which stands for "immediate if") is a function, which means it takes arguments and returns the result
result = IIf( condition, YesValue, NoValue );
It works with both numbers (scalars) and arrays. When any of arguments is an array it returns array. It goes bar by bar, checks condition again bar by bar and returns either corresponding array value from Yes…
as well as
https://www.amibroker.com/guide/a_mistakes.html
as well as
https://www.amibroker.com/guide/h_understandafl.html
Example:
tn = TimeNum();
within_session = tn > 100000 AND tn < 150000;
Buy = Cross( C, MA(C, 20) ) AND within_session;
3 Likes