Professional Documents
Culture Documents
In AmiBroker we will be dealing mostly with charts and indicators of various types.
These are all plotted with the plot( ) function.
So let us start our study with the plot( ) function.
The plot( ) function plots a graph with the data points given in an array, provided to the function as a
parameter.
The syntax of plot( ) in its simplest form is given below:
The function returns a number. The function plots a graph using the array data.
Parameters:
This is not a complete list. For complete style constants see the User’s Guide.
Cross( ) Function //This is an important function.
lengthFast = 10;
lengthSlow = 50;
fastMA = MA( Close, lengthFast);
slowMA = MA( Close, lengthSlow);
longEntry = Cross( fastMA, slowMA);
longExit = Cross( slowMA, fastMA);
True/False values in longEntry and longExit determine the conditions for buying the security and
exit if already long.
Ref( ) Function // referring to previous bars
The Ref() function is the easy way to refer the previous values of an array.
The use does not limit to arrays O, H, L, C etc. but on all derived arrays.
This is an important function used extensively in AFL programming.
Syntax: Ref ( array, period )
The function returns an array.
It references a previous or subsequent element of the “array” passed.
A positive period “p” references “p” periods in the future while negative period “p” periods ago.
The formula ref(Close, -5) refers to the Close price 5 periods ago.
Let’s assign this to a variable x.
x = ref( Close, -5 );
The variable x will be an array. The value of x will be the close price 5 periods ago.