- reference hand-drawn study

Miscellaneous functions
(AmiBroker 3.50)

SYNTAX Study( STUDYID, CHARTID = 1, scale = -1 )
FUNCTION generates an array equivalent to a trendline study drawn by the user - allows detecting trendline breakouts from AFL.
STUDYID is a two-character identifier of the study. identifiers are: "UP" - uptrend, "DN" - downtrend, "SU" - support, "RE" - resistance, "ST" - stop loss, however you can use ANY identifiers (there are no limitations except that AmiBroker accepts only 2 letter codes).
CHARTID - identifies the chart pane where the study was drawn - you can find out what is the chart ID for given chart by looking in Parameters dialog, Axes & Grid, Miscellaneous: Chart ID or using GetChartID() AFL function.
Scale - this parameter specifies which scale should be used:
  • scale = -1 : automatic (default value) - either linear or logarithmic depending on actual chart setting, chart is specified by chartID
  • scale = 0 : linear scale
  • scale = 1 : logarithmic scale

More information about this function is included in the Tutorial: Using Studies in AFL formulas

EXAMPLE // this example plots filled area between
// support (SU) and resistance (RE) lines

Plot(C, "Price", colorBlack, styleCandle );
su =
Study("SU", GetChartID() );
re =
Study("RE", GetChartID() );
PlotOHLC( re,  re,  su, su, "", colorYellow,styleCloud );


The Study function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.