0% found this document useful (0 votes)
22 views6 pages

Built-In Functions

The plot( ) function plots a graph with data points from an array passed as a parameter. It returns a number and allows specifying the graph name, color, and style. The cross( ) function checks for crossovers between two arrays and returns true/false values to identify buy/sell signals. The ref( ) function refers to previous values in an array by specifying the array and number of periods ago or in the future.

Uploaded by

swapnil kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

Built-In Functions

The plot( ) function plots a graph with data points from an array passed as a parameter. It returns a number and allows specifying the graph name, color, and style. The cross( ) function checks for crossovers between two arrays and returns true/false values to identify buy/sell signals. The ref( ) function refers to previous values in an array by specifying the array and number of periods ago or in the future.

Uploaded by

swapnil kamble
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Plot( ) Function

 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:

Plot( array, name, color, style );

 The function returns a number. The function plots a graph using the array data.
Parameters:

• array - This contains the data to be plotted


• name - This defines the graph name to be displayed in the title bar
• color - This defines the color of the plot
• style - Style determines the style of the plot, such as line chart, histogram chart, thick line etc.

Style can be a combination of one or more of the following.

• styleLine normal line chart ( This is the default value )


• styleHistogram histogram chart
• styleThick fat(thick) line – in combination with other styles
• styleDots dotted line
• styleDashed dashed line style
• styleCandle candlestick chart
• styleBar traditional bar chart

This is not a complete list. For complete style constants see the User’s Guide.
Cross( ) Function //This is an important function.

 It checks for the crossovers of two arrays.


 Syntax Cross ( array1, array2)
 The function returns an array and gives a True when array1 crosses above array2 from below
otherwise the result will be False(0).
 To determine when array1 cross array2 from above use cross(array2,array1).
 Figure shows two arrays array1 and array2 plotted. At point A array1 is crossing array2 from
below, while at point B, the array1 is crossing array2 from above.
 Moving average cross-over is a frequently used trading system, where one enter a long position when
a fast moving average crosses a slow moving average and exit the position when the slow moving
average crosses the fast moving average.
 The code below shows how one identifies the entry and exit.

//Simple moving average cross over system


//Demonstration of the cross() 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.

You might also like