Constants Reference

Top  Previous  Next

Trading Blox Builder contains several built-in constants that can be used in scripts:

 

 

 

Constant

 

Value

PI

 

3.14159265358979321

 

 

 

TRUE

 

1

FALSE

 

0

 

 

 

LONG

 

1

SHORT

 

-1

OUT

 

0

 

 

 

SUNDAY

 

0

MONDAY

 

1

TUESDAY

 

2

WEDNESDAY

 

3

THURSDAY

 

4

FRIDAY

 

5

SATURDAY

 

6

 

 

 

UNDEFINED

 

n/a

 

Using constants makes your code easier to understand.

 

The UNDEFINED can be assigned to plotting series, so that the particular series value does not plot.

 

Contrast this code:

 

IF instrument.position = 1 THEN

 

   ' Do some Long stuff here.

 

ENDIF

 

with this code:

 

IF instrument.position = LONG THEN

 

   ' Do some Long stuff here.

 

ENDIF

 

 

In the following code, is it obvious what day we are referring to:

 

IF DayOfWeek( instrument.date ) = 1 THEN

 

    ' Do our weekly tasks here.

.

ENDIF

 

How about in this code:

 

IF DayOfWeek( instrument.date ) = MONDAY THEN

 

    ' Do our weekly tasks here.

.

ENDIF