Overbasic – Pragma

A Pragma is a special parameter that allows you to influence the behavior of the Indicator / Trading-System.
Some Pragmas can be defined exclusively within the script, while others are used to set default values of properties accessible in the configuration window of the Indicator / Trading-System.

Syntax #

Pragma ("<parameter name>", <value>, <result index>)

A pragma is defined by PRAGMA keyword and the following attributes:

Parameter Name: name of the parameter to be set (see available parameters).

Value: parameter value

Result Index: (ONLY for Indicators) if an indicator returns multiple results/curves (RETURN keyword), result index indicates which result the Pragma refers to.

Pragmas must be defined at script level, that is, externally to all functions. We recommend you define all Pragmas at the beginning of the script.

Available Parameters #

HORIZONTAL_SHIFT

Allows right/left shift (of x bars) of the entire indicator-values series.
If greater than zero, the curve after being calculated is shifted to the right by the specified number of bars.
If lower than zero, the curve after being calculated is shifted to the left by the specified number of bars.

Possible Values: Any integer value.

Available for indicators ONLY. If used elsewhere it is ignored.
STYLE_DRAW_AS

Defines the default value of ‘Draw As‘ style property present in the indicator configuration.

Available for indicators ONLY. If used elsewhere it is ignored.
STYLE_ZORDER

Defines the default value of ‘Z-Order‘ style property present in the indicator configuration. This property specifies the drawing order with respect to the other curves present IN THE SAME indicator. The higher the Z-Order value, the more the curve will be drawn in the foreground.

Possible values: any positive integer value.

Available for indicators ONLY. If used elsewhere it is ignored.
USE_REFERENCE_OBJECT_SCALE_AS_DEFAULT

Sets the use of reference chart/indicator scale as default.
In other words, if the indicator is mainly used together with its reference chart/indicator (as happens for example for moving average), then we recommend you use this Pragma to set by default the use of the same scale as the reference chart/indicator.

Possible values: TRUE, FALSE.

Available for indicators ONLY. If used elsewhere it is ignored.
VALID_STARTING_FROM

Defines the bar from which to start drawing the indicator curve. In other words, it is the index of the first valid value in the indicator values series.

Possible values: any positive integer value.

Available for indicators ONLY. If used elsewhere it is ignored.

Usage #

Pragmas must be defined at script level, that is, externally to all functions. We recommend you define all Pragmas at the beginning of the script.

Examples:

Pragma ("HORIZONTAL_SHIFT", 20)
Pragma ("STYLE_DRAW_AS", "HI")
Pragma ("STYLE_ZORDER", 100)
Pragma ("USE_REFERENCE_OBJECT_SCALE_AS_DEFAULT", True)
Pragma ("VALID_STARTING_FROM", 10)

Function Main()
    ...
    ...
EndFunction

If an indicator returns multiple results/curves, the result index Pragma refers to must be specified:

Pragma ("HORIZONTAL_SHIFT", 20, 3)
Pragma ("VALID_STARTING_FROM", 10, 1)
Pragma ("VALID_STARTING_FROM", 10, 2)
Pragma ("VALID_STARTING_FROM", 10, 3)

Function Main()
    ...
    ...
EndFunction

Pragma value can also be defined as an expression consisting of Numbers, Strings, Boolean values (true/false), Options, Properties:

Pragma ("VALID_STARTING_FROM", Period)

Property Period As Numeric
    Default (20)
EndProperty

Function Main()
    ...
    ...
EndFunction