Trading Blox Builder contains several built-in constants that can be used in scripts:
| Constant Name: | 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 | 
Trading Blox Preferences:
| Preference Setting Values: | Description: | 
|---|---|
| CHARTNOVALUE | Constant. Assign to an IPV plotting series when no value is to be plotted on the instrument chart. | 
| LoadUnadjustedClose | TRUE/FALSE value. | 
| LoadVolume | TRUE/FALSE value. | 
| NumberOfExtraDataFields | Number value of the Extra Data Fields setting field. | 
| ProcessDailyBars | TRUE/FALSE value. | 
| ProcessMonthlyBars | TRUE/FALSE value. | 
| ProcessWeekends | TRUE/FALSE value. | 
| ProcessWeeklyBars | TRUE/FALSE value. | 
| RaiseNegativeDataSeries | TRUE/FALSE value. | 
| UNDEFINED | Constant. When assigned to an IPV series, the negative value will be outside of the plotting range of the instrument chart. | 
| YearsOfPrimingData | Number value of the Extra Data Fields setting field. | 
Using constants improves code understanding.
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
| Edit Time: 9/12/2020 10:28:44 AM | Topic ID#: 217 |