AFL Function Reference - Categorized list of functions
Basic price pattern detection
Composites
Date/Time
- BarIndex -
get zero-based bar number (AFL 2.3)
- BeginValue -
Value of the array at the begin of the range (AFL 2.3)
- DATE -
date (AFL 1.1)
- DATENUM -
date number (AFL 1.4)
- DATETIME -
retrieves encoded date time (AFL 2.3)
- DAY -
day of month (AFL 1.4)
- DAYOFWEEK -
day of week (AFL 1.4)
- DAYOFYEAR -
get ordinal number of day in a year (AFL 2.4)
- ENDVALUE -
value of the array at the begin of the selected range (AFL 2.3)
- HOUR -
get current bar's hour (AFL 2.0)
- INTERVAL -
get bar interval (in seconds) (AFL 2.1)
- MINUTE -
get current bar's minute (AFL 2.0)
- MONTH -
month (AFL 1.4)
- NOW -
gets current system date/time (AFL 2.3)
- SECOND -
get current bar's second (AFL 2.0)
- TIMENUM -
get current bar time (AFL 2.0)
- YEAR -
year (AFL 1.4)
Indicators
- AccDist -
accumulation/distribution
- ADX -
average directional movement index (AFL 1.3)
- ATR -
average true range (AFL 1.3)
- BBandBot -
bottom bollinger band
- BBandTop -
top bollinger band
- CCI -
commodity channel index
- CHAIKIN -
chaikin oscillator
- MACD -
moving average convergence/divergence
- MDI -
minus directional movement indicator (-DI) (AFL 1.3)
- MFI -
money flow index
- NVI -
negative volume index
- OBV -
on balance volume
- OSCP -
price oscillator
- OSCV -
volume oscillator
- PDI -
plus directional movement indicator (AFL 1.3)
- PVI -
positive volume index
- RMI -
Relative Momentum Index (AFL 2.1)
- ROC -
percentage rate of change
- RSI -
relative strength index
- RWI -
random walk index
- RWIHI -
random walk index of highs
- RWILO -
random walk index of lows
- SAR -
parabolic stop-and-reverse (AFL 1.3)
- SIGNAL -
macd signal line
- STOCHD -
stochastic slow %D
- STOCHK -
stochastic slow %K
- TRIX -
triple exponential smoothed price
- ULTIMATE -
ultimate oscillator
Information / Categories
Lowest/Highest
Math functions
- abs -
absolute value
- atan -
arc tan
- CEIL -
ceil value
- COS -
cosine
- EXP -
exponential function
- FLOOR -
floor value
- FRAC -
fractional part
- INT -
integer part
- LOG -
natural logarithm
- LOG10 -
decimal logarithm
- MAX -
maximum value of two numbers / arrays
- MIN -
minimum value of two numbers / arrays
- PREC -
adjust number of decimal points of floating point number
- ROUND -
round number to nearest integer
- SIN -
sine function
- SQRT -
square root
Miscellaneous functions
- #include -
preprocessor include command (AFL 2.2)
- #pragma -
sets AFL pre-processor option (AFL 2.4)
- CREATEOBJECT -
create COM object (AFL 1.8)
- CREATESTATICOBJECT -
create static COM object (AFL 1.8)
- ENABLESCRIPT -
enable scripting engine
- ENABLETEXTOUTPUT -
enables/disables text output in the Chart Commentary window (AFL 2.2)
- GETEXTRADATA -
get extra data from external data source (AFL 1.9)
- GETSCRIPTOBJECT -
get access to script COM object (AFL 1.8)
- ISEMPTY -
empty value check (AFL 1.5)
- ISFINITE -
check if value is not infinite (AFL 2.3)
- ISNAN -
checks for NaN (not a number) (AFL 2.3)
- ISNULL -
check for Null (empty) value (AFL 2.3)
- ISTRUE -
true value (non-empty and non-zero) check (AFL 1.5)
- NZ -
Null (Null/Nan/Infinity) to zero (AFL 2.3)
- PREFS -
retrieve preferences settings (AFL 1.4)
- SETBARSREQUIRED -
set number of previous and future bars needed for script/DLL to properly execute (AFL 2.1)
- STATUS -
get run-time AFL status information (AFL 1.65)
- STUDY -
reference hand-drawn study (AFL 1.5)
- VERSION -
get version info (AFL 1.9)
- _TRACE -
print text to system debug viewer (AFL 2.4)
Moving averages, summation
- AMA -
adaptive moving average (AFL 1.5)
- AMA2 -
adaptive moving average (AFL 1.5)
- CUM -
cumulative sum
- DEMA -
double exponential moving average (AFL 2.0)
- EMA -
exponential moving average
- MA -
simple moving average
- SUM -
sum data over specified number of bars
- TEMA -
triple exponential moving average (AFL 2.0)
- WILDERS -
Wilder's smoothing (AFL 1.4)
- WMA -
weighted moving average (AFL 2.0)
Statistical functions
String manipulation
- NumToStr -
convert number to string (AFL 2.5)
- printf -
Print formatted output to the output window. (AFL 2.5)
- StrExtract -
extracts given item (substring) from comma-separated string (AFL 2.4)
- StrFind -
find substring in a string (AFL 2.5)
- StrFormat -
Write formatted output to the string (AFL 2.5)
- StrLeft -
extracts the leftmost part (AFL 2.0)
- StrLen -
string length (AFL 1.5)
- StrMid -
extracts part of the string (AFL 2.0)
- StrRight -
extracts the rightmost part of the string (AFL 2.0)
- StrToNum -
convert string to number (AFL 2.5)
Trading system toolbox
- AlertIf -
trigger alerts (AFL 2.1)
- ApplyStop -
apply built-in stop (AFL 1.7)
- BarsSince -
bars since
- CROSS -
crossover check
- EnableRotationalTrading -
Turns on rotational-trading mode of the backtester (AFL 2.5)
- EQUITY -
calculate equity line (AFL 2.0)
- EXREM -
remove excessive signals (AFL 1.5)
- EXREMSPAN -
remove excessive signals spanning given number of bars (AFL 2.0)
- FLIP -
(AFL 1.5)
- HOLD -
hold the alert signal
- IIF -
immediate IF function
- LASTVALUE -
last value of the array
- OPTIMIZE -
define optimization variable (AFL 1.7)
- REF -
reference past/future values of the array
- SetFormulaName -
set the name of the formula (AFL 2.5)
- SetOption -
sets options in automatic analysis settings (AFL 2.3)
- SETTRADEDELAYS -
allows to control trade delays applied by the backtester (AFL 2.1)
- VALUEWHEN -
get value of the array when condition met (AFL 1.1)
Exploration /Indicator Builder
- AddColumn -
add numeric exploration column (AFL 1.8)
- AddTextColumn -
add text exploration column (AFL 1.8)
- ENCODECOLOR -
encodes color for indicator title (AFL 2.2)
- GETCHARTID -
get current chart ID (AFL 2.3)
- LineArray -
generate trend-line array (AFL 2.5)
- PARAM -
add user user-definable numeric parameter (AFL 2.3)
- PARAMCOLOR -
add user user-definable color parameter (AFL 2.3)
- PARAMSTR -
add user user-definable string parameter (AFL 2.3)
- PLOT -
plot indicator graph (AFL 1.8)
- PLOTGRID -
Plot horizontal grid line (AFL 2.3)
- PLOTOHLC -
plot custom OHLC chart (AFL 2.2)
- PLOTSHAPES -
plots arrows and other shapes (AFL 2.3)
- PLOTVAPOVERLAY -
plot Volume-At-Price overlay chart (AFL 2.4)
- SELECTEDVALUE -
retrieves value of the array at currently selected date/time point (AFL 2.1)
- WRITEIF -
commentary conditional text output
- WriteVal -
write number or value of the array
- _N -
no text output (AFL 2.1)
File Input/Output functions
- fclose -
close a file (AFL 2.5)
- feof -
test for end-of-file (AFL 2.5)
- fgets -
get a string from a file (AFL 2.5)
- fopen -
open a file (AFL 2.5)
- fputs -
write a string to a file (AFL 2.5)
Referencing other symbol data
- FOREIGN -
access foreign security data (AFL 1.5)
- GETBASEINDEX -
retrieves symbol of relative strength base index (AFL 2.1)
- PLOTFOREIGN -
plot foreign security data (AFL 2.2)
- RELSTRENGTH -
comparative relative strength (AFL 1.3)
- RestorePriceArrays -
restore price arrays to original symbol (AFL 2.5)
- SetForeign -
replace current price arrays with those of foreign security (AFL 2.5)
Time Frame functions