Chart
object: Legal chart object types
typedef enum
|
|
{
|
|
LABEL_OBJECT,
|
/* Label object */ |
TEXT_OBJECT,
|
/* Text object */ |
VLINE_OBJECT,
|
/* Vertical line object */ |
HLINE_OBJECT,
|
/* Horizontal line object */ |
LINE_OBJECT,
|
/* Trend line object */ |
FIBO_OBJECT
|
/* Fibonacci object */ |
SUBCHART_OBJECT,
|
/* Subchart object */ |
VBARS_OBJECT,
|
/* Vertical bars object */ |
CURVE_OBJECT,
|
/* Curve object */ |
DOT_OBJECT,
|
/* Dot object */ |
CONTAINER_OBJECT
|
/* Container object */ |
} Object_t; |
/* Object type */
|
Text
adjustment:
Legal text adjustment methods
typedef enum
|
|
{
|
|
TEXT_VADJUST_NORMAL,
|
/* Text vertical adjustment normal */
|
TEXT_VADJUST_CENTER,
|
/* Text vertical
adjustment center */ |
TEXT_VADJUST_ABOVE,
|
/* Text vertical adjustment above */
|
TEXT_VADJUST_BELOW,
|
/* Text vertical adjustment below */
|
TEXT_HADJUST_NORMAL,
|
/* Text horizontal adjustment normal
*/ |
TEXT_HADJUST_CENTER,
|
/* Text horizontal adjustment center
*/ |
TEXT_HADJUST_LEFT,
|
/* Text horizontal adjustment left */
|
TEXT_HADJUST_RIGHT
|
/* Text horizontal adjustment right
*/ |
} TextAdjustment_t; |
/* Text adjustment */ |
Time
frames: Legal time frames
typedef enum |
|
{
|
|
TF_DAY,
|
/* Day time frame (daily
chart) */ |
TF_WEEK,
|
/* Week time frame (weekly chart) */
|
TF_MONTH,
|
/* Month time frame (monthly chart)
*/ |
TF_YEAR
|
/* Year time frame (yearly chart) */
|
} TimeFrame_t |
/* Time frame */
|
Candle:
Legal candle types
typedef enum |
|
{ |
|
CTYPE_CANDLE,
|
/* Standard candle */
|
CTYPE_HEIKINASHI
|
/* Japanese heikin-ashi candle */
|
} Candle_t; |
/* Candle types */
|
Price:
For open, close, high and low price
typedef enum |
|
{ |
|
OPEN_PRICE,
|
/* Open price */
|
CLOSE_PRICE,
|
/* Close price */
|
HIGH_PRICE,
|
/* High price */
|
LOW_PRICE
|
/* Low price */
|
} Price_t;
|
/* Price types */
|
Error
codes:
Error codes returned by various CGScript functions
typedef enum
|
|
{
|
|
CGSERR_OK = -4999,
|
/* No error */
|
CGSERR_INITIALIZATION_FAILED,
|
/* Initialization failed */
|
CGSERR_RUNTIME_ERROR,
|
/* Run-time error */
|
CGSERR_UNINITIALIZED,
|
/* Uninitialized module
*/
|
CGSERR_ALREADY_INITIALIZED,
|
/* Module is initialized
*/
|
CGSERR_NO_PARENT_CHART,
|
/* No parent */
|
CGSERR_NO_MODULE,
|
/* No module */
|
CGSERR_NO_ARRAY,
|
/* No array */
|
CGSERR_ARRAY_CREATION_AFTER_INIT,
|
/* Array creation after Init()
execution */
|
CGSERR_ARRAY_ELEM_BIG,
|
/* Array element too big */
|
CGSERR_ARRAY_ELEM_ZERO,
|
/* Array element size is zero */
|
CGSERR_ARRAY_CREATION_FAILED,
|
/* Array creation failed */
|
CGSERR_ARRAY_SUBSCRIPT,
|
/* Array subscript out of range */
|
CGSERR_MEMORY,
|
/* Out of memory */
|
CGSERR_TIMEFRAME,
|
/* Invalid time frame */
|
CGSERR_INVALID_ARGUMENT,
|
/* Invalid argument */
|
CGSERR_NEGATIVE_SHIFT,
|
/* Negative shift */
|
CGSERR_INVALID_MODTYPE,
|
/* Invalid module type */
|
CGSERR_INTERNAL_100,
|
/* internal error 100 */
|
CGSERR_INTERNAL_101,
|
/* internal error 101 */
|
CGSERR_FPE,
|
/* floating point exception */
|
CGSERR_SEGV,
|
/* segmentation fault */
|
CGSERR_ILL,
|
/* illegal instruction */
|
CGSERR_SIGNAL
|
/* signal not handled */
|
} ErrCode_t;
|
/* Error codes */
|
Event
codes: Event codes returned in LastEvent global variable
typedef enum |
|
{ |
|
EV_MOUSE_ON_BAR = 1,
|
/* mouse pointer changed bar
*/
|
EV_INPUT_VAR
|
/* input variable changed */
|
} Event_t; |
/* Event types */
|
Bar
data:
Structure holding information about bars
typedef struct
|
|
{
|
|
double High;
|
/* High */
|
double Low;
|
/* Low */
|
double Open;
|
/* Open */
|
double Close;
|
/* Close */
|
double AdjClose;
|
/* Adjusted close */
|
double Volume;
|
/* Volume */
|
unsigned short Year;
|
/* Year */
|
unsigned short Month;
|
/* Month */
|
unsigned short Day;
|
/* Day */
|
char Date[16];
|
/* Full date */
|
char Time[16];
|
/* Time */
|
char Id[256];
|
/* Bar id string */
|
} BarData_t;
|
/* Bar data */
|
Strings:
typedef void * String_t;
Arrays:
typedef void * Array_t;
Colors:
typedef unsigned int Color_t;
See: Color definitions
Font Weight:
typedef int FontWeight_t;
See: Constants
for font weight
Other:
Various
types used in CGScript programs
typedef const char Property;
typedef void * ObjectHandler_t;
|
From stdio.h:
int printf(const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format,
...);
Notice: printf prints formatted data to
debug console, not to stdout
From string.h:
void *memset(void *s, int c, size_t n);
void *memmove(void *dest, const void *src, size_t n);
char *strncpy(char *dest, const char *src, size_t n);
char *strncat(char *dest, const char *src, size_t n);
int strncmp(const char *s1, const char *s2, size_t n);
size_t strlen(const char *s);
From stdlib.h:
int atoi(const char *nptr);
long atol(const char *nptr);
long long atoll(const char *nptr);
double atof(const char *nptr);
double strtod(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
long double strtold(const char *nptr, char **endptr);
long int strtol(const char *nptr, char **endptr, int base);
long long int strtoll(const char *nptr, char **endptr, int
base);
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
void qsort(void *base, size_t nmemb, size_t size,
int
(*compar)(const void *, const void *));
void *bsearch(const void *key, const void *base,
size_t
nmemb, size_t size,
int
(*compar)(const void *, const void *));
From math.h:
double sqrt(double x);
float sqrtf(float x);
long double sqrtl(long double x);
double cos(double x);
float cosf(float x);
long double cosl(long double x);
double sin(double x);
float sinf(float x);
long double sinl(long double x);
double tan(double x);
float tanf(float x);
long double tanl(long double x);
double atan(double x);
float atanf(float x);
long double atanl( long double x);
double log(double x);
float logf(float x);
long double logl(long double x);
double log10(double x);
float log10f(float x);
long double log10l(long double x);
double log2(double x);
float log2f(float x);
long double log2l(long double x);
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
long double ldexpl(long double x, int exp);
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
double modf(double x, double *iptr);
float modff(float x, float *iptr);
long double modfl(long double x, long double *iptr);
double frexp(double x, int *exp);
float frexpf(float x, int *exp);
long double frexpl(long double x, int *exp);
double scalbln(double x, long int exp);
float scalblnf(float x, long int exp);
long double scalblnl(long double x, long int exp);
|
Array functions
CGScript supports its own array type
along with the standard arrays of ISO C99. Usage of CGScript
arrays is recommended for most applications. Non-static Array_t
declared variables are auto destroyed when they go out of
scope.
Synopsis
Details
ArrayCreate ()
Array_t
|
ArrayCreate
|
(int elemsize,
int maxdim); |
Creates and initializes an array. On failure it disables the
module's execution. This function cannot be present in Loop().
elemsize:
|
The maximum size in bytes
of each element. Valid values are between 1 and 512.
|
maxdim:
|
The maximum expected
dimension of the array. Valid values are between 1
and 65536.
|
Returns:
|
A new array of type Array_t.
|
ArrayAppend ()
int
|
ArrayAppend
|
(Array_t
arr,
void *elem);
|
Appends an element to the array. On failure it disables the
module's execution.
arr:
|
The array where the
element is going to be appended.
|
elem:
|
The element to be
appended. ArrayAppend will copy the contents of
element into a new array element.
|
Returns:
|
The size of the array
after the append operation.
|
|
|
Macros:
|
|
#define cArrayAppend(a,e)
|
ArrayAppend(a,(void
*)&e)
|
ArrayPut ()
void
|
ArrayPut
|
(Array_t
arr,
int index,
void *elem); |
Overwrites the contents of an already existing array
element. If the element does not exist, it does nothing. On
failure it disables the module's execution.
arr:
|
The array that holds the
element to be overwritten.
|
index:
|
The position of the
element in the array.
|
elem:
|
The new contents of the
element.
|
Returns:
|
Nothing.
|
|
|
Macros:
|
|
#define cArrayPut(a,i,e)
|
ArrayPut(a,i,(void
*)&e)
|
ArraySize ()
Returns the number of elements in the array. On failure it
disables the module's execution.
arr:
|
The array.
|
Returns:
|
The total number of
elements in the array.
|
ArrayGet ()
void *
|
ArrayGet
|
(Array_t
arr,
int index); |
Returns a pointer to the contents of an array element. On
failure it disables the module's execution.
arr:
|
The array the element
belongs
|
index:
|
The position of the
element in the array.
|
Returns:
|
A pointer to the contents
of the element. For negative index, the contents of
the first element are returned. For index greater
than the size of the array, ArrayGet returns the
contents of the last element.
|
|
|
Macros:
|
|
#define sArrayGet(a,i)
|
(*(short *)ArrayGet(a,i))
|
#define usArrayGet(a,i)
|
(*(unsigned short
*)ArrayGet(a,i))
|
#define iArrayGet(a,i)
|
(*(int *)ArrayGet(a,i))
|
#define uiArrayGet(a,i)
|
(*(unsigned int
*)ArrayGet(a,i))
|
#define lArrayGet(a,i)
|
(*(long *)ArrayGet(a,i))
|
#define ulArrayGet(a,i)
|
(*(unsigned long
*)ArrayGet(a,i))
|
#define llArrayGet(a,i)
|
(*(long long
*)ArrayGet(a,i))
|
#define ullArrayGet(a,i)
|
(*(unsigned long long
*)ArrayGet(a,i))
|
#define fArrayGet(a,i)
|
(*(float *)ArrayGet(a,i))
|
#define dArrayGet(a,i)
|
(*(double
*)ArrayGet(a,i))
|
#define ldArrayGet(a,i)
|
(*(long double
*)ArrayGet(a,i))
|
ArrayReset ()
Clears the contents of an array and resets its size to zero.
On failure it disables the module's execution.
arr:
|
The array to reset.
|
Returns:
|
Nothing.
|
Bar functions
Information about bars.
Synopsis
Details
Bar ()
Returns a bar data structure for time frame tf. Shift is an
index, relative to the most recent bar. The most recent bar
can be accessed with shift = 0. On failure it disables the
module's execution.
tf:
|
The time frame the bar
belongs to.
|
shift:
|
An index relative to the most recent
bar of time frame tf. Valid values between 0 and
NBars (tf). A value below 0, returns a bar data
structure containing only nulls. A value above NBars
(tf) is truncated to NBars (tf).
|
Returns:
|
A bar data structure. |
|
|
Macros:
|
|
#define Open(s)
|
Bar(TF_CURRENT,s).Open
|
#define High(s)
|
Bar(TF_CURRENT,s).High
|
#define Low(s)
|
Bar(TF_CURRENT,s).Low |
#define Close(s)
|
Bar(TF_CURRENT,s).Close
|
#define Volume(s)
|
Bar(TF_CURRENT,s).Volume
|
#define Year(s)
|
Bar(TF_CURRENT,s).Year
|
#define Month(s)
|
Bar(TF_CURRENT,s).Month
|
#define Day(s)
|
Bar(TF_CURRENT,s).Day
|
#define Date(s)
|
Bar(TF_CURRENT,s).Date
|
#define Time(s)
|
Bar(TF_CURRENT,s).Time
|
#define Id(s)
|
((const char *) Bar(TF_CURRENT,s).Id)
|
BarHA ()
Same as Bar () but for Heikin-Ashi
candles.
tf:
|
The time frame the bar
belongs to.
|
shift:
|
An index relative to the most recent
bar of time frame tf. Valid values between 0 and
NBars (tf). A value below 0, returns a bar data
structure containing only nulls. A value above NBars
(tf) is truncated to NBars (tf).
|
Returns:
|
A bar data structure. |
|
|
Macros:
|
|
#define OpenHA(s)
|
BarHA(TF_CURRENT,s).Open
|
#define HighHA(s)
|
BarHA(TF_CURRENT,s).High
|
#define LowHA(s)
|
BarHA(TF_CURRENT,s).Low |
#define CloseHA(s)
|
BarHA(TF_CURRENT,s).Close
|
#define Volume(s)
|
Bar(TF_CURRENT,s).Volume
|
#define Year(s)
|
Bar(TF_CURRENT,s).Year
|
#define Month(s)
|
Bar(TF_CURRENT,s).Month
|
#define Day(s)
|
Bar(TF_CURRENT,s).Day
|
#define Date(s)
|
Bar(TF_CURRENT,s).Date
|
#define Time(s)
|
Bar(TF_CURRENT,s).Time
|
#define IdHA(s)
|
((const char *)
BarHA(TF_CURRENT,s).Id)
|
NBars ()
Returns the total number of bars for time frame tf.
tf:
|
The time frame.
|
Returns:
|
The total number of bars
for time frame.
|
NVisibleBars ()
Returns the number of visible bars on chart. Time frame is
always the current.
Arguments:
|
None.
|
Returns:
|
The number of visible
bars on chart.
|
NewestVisibleBar ()
int
|
NewestVisibleBar |
(void); |
Returns the shift value of the newest visible bar. Time
frame is always the current.
Arguments:
|
None.
|
Returns:
|
The shift value of the
newest visible bar.
|
OldestVisibleBar ()
int
|
OldestVisibleBar |
(void); |
Returns the shift value of the oldest visible bar. Time
frame is always the current.
Arguments:
|
None.
|
Returns:
|
The shift value of the
oldest visible bar.
|
Chart functions
Information about and manipulation of charts.
Synopsis
Details
ChartBackColor ()
Returns the background color
of the chart.
Arguments:
|
None.
|
Returns:
|
The background color of the
chart.
|
ChartCurrentBar ()
int
|
ChartCurrentBar |
(void);
|
Returns the shift of the bar under the mouse pointer, or -1
if none.
Arguments:
|
None.
|
Returns:
|
The shift of the bar
under the mouse pointer, or -1 if none.
|
ChartCurrentTF ()
Returns the current time frame.
Arguments:
|
None.
|
Returns:
|
The current time frame of
the chart.
|
|
|
Macros: |
|
#define TF_CURRENT |
ChartCurrentTF () |
ChartForeColor ()
Returns the foreground color
of the chart.
Arguments:
|
None.
|
Returns:
|
The foreground color of the
chart.
|
ChartHeight ()
Returns the height of the chart in pixels.
Arguments:
|
None.
|
Returns:
|
The height of the chart
in pixels.
|
ChartWidth ()
Returns the width of the chart in pixels.
Arguments:
|
None.
|
Returns:
|
The height of the chart
in pixels.
|
Common functions
Commonly used functions.
Synopsis
Details
GetParentTitle ()
Returns the title of the chart the module is attached on. On
failure it disables the module's execution.
Arguments:
|
None.
|
Returns:
|
A string containing the
title of the parent chart.
|
GetModuleName ()
Returns the module's name. On failure it disables the
module's execution.
Arguments:
|
None.
|
Returns:
|
A string containing the
current module's name.
|
GetFractionalDigits ()
int
|
GetFractionalDigits |
(double num); |
Returns the number of significant digits after the decimal
point. In Chart Geany 5 this is up to two for numbers
greater than 1.0 and up to four for number between 0.0 and
1.0.
Arguments:
|
A double precision
number.
|
Returns:
|
An integer containing the
number of significant digits after the decimal
point.
|
Input variable
functions
This set of functions gives access to the object's
properties dialog. An input variable appears in the object's
properties dialog
where the user can change its value. In conjunction with Event()
and EV_INPUT_VAR signal, gives to the module the ability to
interact with the user. Input variables must be of integer,
double or Color_t type. Input
variable functions must appear in Init(). The object
type must be SUBCHART_OBJECT or CONTAINER_OBJECT, otherwise
input variables are ignored.
Synopsis
void InputIntegerVariable
|
(const char *title,
int value,
int min,
int max,
int *var,
bool show);
|
void InputDoubleVariable
|
(const char *title,
double value,
double min,
double max,
double *var,
bool show);
|
void InputColorVariable
|
(const char *title,
Color_t value,
Color_t *var,
bool show);
|
Details
InputIntegerVariable ()
void
|
InputIntegerVariable |
(const char *title,
int value,
int min,
int max,
int *var,
bool show); |
Adds an integer property in the object's dialog box.
title:
|
Variable's title as it
appears in the dialog.
|
value:
|
The default value.
|
min:
|
The minimum valid value.
|
max:
|
The maximum valid value.
|
var:
|
A pointer to the module's variable
that keeps input variable's value.
|
show:
|
Set false to hide the variable from
dialog, true otherwise.
|
Returns:
|
Nothing.
|
Since version 1.1
InputDoubleVariable
void
|
InputDoubleVariable |
(const char *title,
double value,
double min,
double max,
double *var,
bool show); |
Adds a double precision property in the object's dialog box.
title:
|
Variable's title as it
appears in the dialog.
|
value:
|
The default value.
|
min:
|
The minimum valid value.
|
max:
|
The maximum valid value.
|
var:
|
A pointer to the module's variable
that keeps input variable's value.
|
show:
|
Set false to hide the variable from
dialog, true otherwise.
|
Returns:
|
Nothing.
|
Since version 1.1
InputColorVariable
void
|
InputColorVariable |
(const char *title,
Color_t value,
Color_t *var,
bool show); |
Adds a color dialog property in the object's dialog box.
title:
|
Variable's title as it
appears in the dialog.
|
value:
|
The default value.
|
var:
|
A pointer to the module's variable
that keeps input variable's value.
|
show:
|
Set false to hide the variable from
dialog, true otherwise.
|
Returns:
|
Nothing.
|
Since version 1.1
Object functions
This set of functions provides access to the attributes of a
Chart Geany
object. Drawing objects and technical indicators share the
same attributes. If an attribute is not applicable for a
specific type of object, it's simply ignored.
Synopsis
ObjectHandler_t
AddCurve |
(void);
|
ObjectHandler_t
AddHorizontalLine |
(void);
|
ObjectHandler_t
AddLabel |
(void);
|
ObjectHandler_t
AddText
|
(void);
|
ObjectHandler_t
AddVerticalBars
|
(void);
|
ObjectHandler_t
AddVerticalLine |
(const char *id); |
void AttachText
|
(ObjectHandler_t
handler,
const char *id,
double y);
|
Color_t GetColor
|
(ObjectHandler_t
handler); |
int GetPeriod
|
(ObjectHandler_t
handler);
|
void SetColor
|
(ObjectHandler_t
handler,
Color_t color);
|
void SetColorRGB
|
(ObjectHandler_t
handler,
int red,
int green,
int blue);
|
void SetFontSize
|
(ObjectHandler_t
handler,
int fontsize);
|
void SetFontWeight
|
(ObjectHandler_t
handler,
FontWeight_t
fontweight);
|
void SetHAdjustment
|
(ObjectHandler_t
handler,
TextAdjustment_t
hadjustment);
|
void SetObjectType
|
(Object_t
type);
|
void SetPeriod
|
(ObjectHandler_t
handler,
int period);
|
void SetRefresh
|
(ObjectHandler_t
handler);
|
void SetSubChartRange
|
(double min,
double max);
|
void SetSymbol
|
(ObjectHandler_t
handler,
const char *symbol);
|
void SetText
|
(ObjectHandler_t
handler,
String_t text);
|
void SetThickness
|
(ObjectHandler_t
handler,
int thickness);
|
void SetVAdjustment
|
(ObjectHandler_t
handler,
TextAdjustment_t
vadjustment);
|
void SetXY
|
(ObjectHandler_t
handler,
int x,
int y);
|
void SetY
|
(ObjectHandler_t
handler,
double y)
|
void ValueSet
|
(ObjectHandler_t
handler,
double value,
int shift); |
Details
AddCurve ()
Adds a curve object as a child of the current object. Y
axis values must be set using ValueSet(). It returns an
object handler to the created object. On failure it disables
the module's execution
Arguments:
|
None.
|
Returns:
|
An object handler to the
created object.
|
AddHorizontalLine ()
Adds a horizontal line object as a child the current object.
Line's position on Y axis can be set with SetY(). It returns
an object handler to the created object. On failure it
disables the module's execution.
Arguments:
|
None.
|
Returns:
|
An object handler to the
created object.
|
AddLabel ()
Adds a label object as a child of the current object. It
returns an object handler to the created object. On failure
it disables the module's execution. Labels cannot be added
on sub charts.
Arguments:
|
None.
|
Returns:
|
An object handler to the
created object.
|
AddText ()
Adds a trailing text object as a child of the current
object, attached on the bar with shift equal to 0, at
close price level. It returns an object handler to the
created object. On failure it disables the module's
execution.Trailing text objects cannot be added on sub
charts.
Arguments:
|
None.
|
Returns:
|
An object handler to the
created object.
|
AddVerticalBars ()
Adds vertical bars object as a child of the current object.
The current object must be a sub chart, otherwise it fails
and disables the module's execution. It returns an object
handler to the created object.
Arguments:
|
None.
|
Returns:
|
An object handler to the
created object.
|
AddVerticalLine ()
Adds a vertical line object as a child of the current
object. Line's position is determined by id.
It returns an object handler to the created object. On
failure it disables the module's execution.
Arguments:
|
id as it is returned by Id(s).
|
Returns:
|
An object handler to the
created object.
|
Since version 1.1
AttachText ()
Adds a trailing text object as a child of handler. The
object's X coordinate is determined by argument id as it is
returned by Id(s). The Y coordinate (aka
price) is determined by argument y.
handler:
|
The handler of the parent
object or NULL if the parent is the current object.
|
id:
|
The id of the bar the object is
attached on.
|
y:
|
The Y coordinate, means the price.
|
Returns:
|
Nothing
|
GetColor ()
Returns the color of handler. If handler is NULL, it returns
the color of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
Returns: |
The color of handler.
|
Since version 1.2
GetPeriod ()
Returns the period of handler. If handler is NULL, it
returns the period of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
Returns:
|
The period of handler.
|
SetColor ()
Set's the color of handler. If handler is NULL, sets the
color of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
color:
|
A color
definition.
|
Returns:
|
Nothing.
|
SetColorRGB ()
Set's the color of the handler using red, green and blue. If
handler is NULL, sets the color of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
red:
|
Code for red.
|
green:
|
Code for green.
|
blue:
|
Code for blue.
|
Returns:
|
Nothing.
|
SetFontSize ()
Set's the font size of handler. If handler is NULL, sets the
font size of the current object. Minimum font size is 7 and
maximum is 24. Below or above the limits, font size is
adjusted accordingly.
handler:
|
A child object handler or
NULL for the current object.
|
fontsize:
|
The font size.
|
Returns:
|
Nothing.
|
SetFontWeight ()
Set's the font weight of handler. If handler is NULL, sets
the font weight of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
fontweight:
|
The font weight.
|
Returns:
|
Nothing.
|
SetHAdjustment ()
Sets the horizontal adjustment of handler. If handler is
NULL, sets the horizontal adjustment of the current object.
Handler must point to a label or text object.
handler:
|
A child object handler or
NULL for the current object.
|
hadjustment:
|
The horizontal adjustment attribute.
|
Returns:
|
Nothing.
|
SetObjectType ()
Sets the object type of the current object. It must appear
in Init().
type:
|
The type of the current
object.
|
Returns:
|
Nothing.
|
SetPeriod ()
Sets the period of handler. If handler is NULL, sets the
period of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
period:
|
The period.
|
Returns:
|
Nothing.
|
SetRefresh ()
Imposes NeedsUpdate() to return true when is called
the next time.
handler:
|
A child object handler or
NULL for the current object.
|
Returns:
|
Nothing.
|
SetSubChartRange ()
void
|
SetSubChartRange |
(double min,
double max);
|
Sets the minimum and maximum value of the Y axis of a sub
chart object. Default values are 0 and 100. If minimum
or maximum values cannot be determined in advance,
DBL_MIN and DBL_MAX must be used.
min:
|
Minimum value of Y, or
DBL_MIN. Default is 0.
|
max:
|
Maximum value of Y, or DBL_MAX.
Default is 100.
|
Returns:
|
Nothing.
|
SetSymbol ()
Set's the symbol
as content of a text or label object. If handler is NULL, it
refers to the current object.
handler:
|
A child object handler or
NULL for the current object.
|
symbol:
|
The symbol.
|
Returns:
|
Nothing.
|
SetText ()
Set's the text as content of a text or label object. if
handler is NULL, it refers to the current object.
handler:
|
A child object handler or
NULL for the current object.
|
text:
|
The text.
|
Returns:
|
Nothing.
|
SetThickness ()
Determines how thick a curve, dot or bar object will be.
Minimum is 1 and maximum is 4. Values outside the limits
will be adjusted within the limits. Default is 1. If handler
is NULL, it refers to the current object.
handler:
|
A child object handler or
NULL for the current object.
|
thickness:
|
The width of the object.
|
Returns:
|
Nothing.
|
SetVAdjustment ()
Sets the vertical adjustment of handler. If handler is NULL,
sets the vertical adjustment of the current object. Handler
must point to a label or text object.
handler:
|
A child object handler or
NULL for the current object.
|
vadjustment:
|
The vertical adjustment attribute.
|
Returns:
|
Nothing.
|
SetXY ()
Sets the X and Y coordinates of a text or label object. If
handler is NULL, sets the coordinates of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
x:
|
The X coordinate.
|
y:
|
The Y coordinate.
|
Returns:
|
Nothing.
|
SetY ()
Sets the Y coordinate of a text or label object. SetPrice()
and SetLevel() are synonyms of this function. If handler is
NULL, sets the Y coordinate of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
y:
|
The Y coordinate.
|
Returns:
|
Nothing.
|
ValueSet ()
In CGScript, each object has a value set. The value set is
actually an array of double with dimension equal to the
number of bars of the current time frame. This array is used
for the Y values of bar, dot and curve objects. ValueSet()
set's the value of the element indicated by shift, for the
object pointed by handler. A NULL value for handler has the
meaning of the current object.
handler:
|
A child object handler or
NULL for the current object.
|
value:
|
The value of element indicated by
shift.
|
shift:
|
An index relative to the most recent
bar of current time frame. Valid values between 0
and NBars (TF_CURRENT) - 1. A value outside the
limits is ignored.
|
Returns:
|
Nothing.
|
String functions
CGScript supports its own string type
along with the standard ISO C99 null terminated string.
Usage of CGScript strings is recommended for most
applications.
Synopsis
Details
StrCpy ()
Copies src to dst and returns dst. On failure, it returns
NULL.
dst:
|
The destination string.
|
src:
|
The source string.
|
Returns:
|
dst or NULL on failure.
|
Cstr2Str ()
Copies src to dst and returns dst. On failure, it returns
NULL.
dst:
|
The destination string.
|
src:
|
The source null terminated string.
|
Returns:
|
dst or NULL on failure.
|
StrCat ()
Appends src to dst and returns dst. On failure, it returns
NULL.
dst:
|
The destination string.
|
src:
|
The source string.
|
Returns:
|
dst or NULL on failure.
|
Str2NCstr ()
char * |
Str2NCstr |
(char *cstr,
String_t str,
size_t n); |
Copies at most n bytes from str to cstr. It returns a
pointer to cstr.
cstr:
|
The destination string.
|
src:
|
The source string.
|
n:
|
The maximum number of bytes to be
copied.
|
Returns:
|
A pointer to null
terminated c string.
|
StrLen ()
Calculates the length of a string.
str:
|
A string.
|
Returns:
|
The number of bytes in
the string str.
|
StrCmp ()
Compares two strings. It returns an integer less than, equal
to, or greater than zero if str1 is found, respectively, to
be less than, to match, or be greater than str2.
str1:
|
The first string of the
comparison.
|
str2:
|
The second string of the comparison.
|
Returns:
|
if (str1 < str2), it
returns a value less than zero.
if (str1 > str2), it returns a value greater than
zero.
if (str1 == str2), it returns zero.
|
StrCstrCmp ()
int
|
StrCstrCmp |
(String_t
str1,
const char *cstr2); |
Compares a string with a null terminated c string. It
returns an integer less than, equal to, or greater than zero
if str1 is found, respectively, to be less than, to match,
or be greater than cstr2.
str1:
|
The first string of the
comparison.
|
cstr2:
|
The second string of the comparison.
|
Returns:
|
if (str1 < cstr2), it
returns a value less than zero.
if (str1 > cstr2), it returns a value greater
than zero.
if (str1 == cstr2), it returns zero.
|
Str2Cstr ()
Converts a string to a null terminated c string.
str:
|
The string to be
converted.
|
Returns:
|
A pointer to a null
terminated string.
|
StrInit ()
Initializes a string with the contents of a c string. On
failure, it returns NULL.
cstr:
|
The null terminated c
string to be used as initial content for string.
|
Returns:
|
A string, or NULL on
failure.
|
Technical
analysis functions
There are two families of technical analysis functions. The
'f' family, where the input comes from current object's
value set and the 'g' family where the input is an array of
double. All technical analysis functions return an array of
double.
Synopsis
Array_t
fADX
|
(TimeFrame_t
tf,
int period);
|
Average directional movement index
|
Array_t fATR
|
(TimeFrame_t
tf,
int period);
|
Average true range
|
Array_t
fAROONUP
|
(TimeFrame_t
tf,
int period);
|
Aroon up
|
Array_t
fAROONDOWN
|
(TimeFrame_t
tf,
int period);
|
Aroon down
|
Array_t
fBBANDSUPPER
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Bollinger bands upper
|
Array_t
fBBANDSLOWER
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Bollinger bands lower
|
Array_t
fBBANDSMIDDLE
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Bollinger bands middle
|
Array_t fCCI
|
(TimeFrame_t
tf,
int period); |
Commodity channel index
|
Array_t fDMX
|
(TimeFrame_t
tf,
int period); |
Directional movement index
|
Array_t fEMA
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Exponential moving average
|
Array_t
fSTOCHSLOWK
|
(TimeFrame_t
tf,
int period); |
Slow stochastic %K
|
Array_t
fSTOCHSLOWD
|
(TimeFrame_t
tf,
int period); |
Slow stochastic %D |
Array_t
fSTOCHFASTK
|
(TimeFrame_t
tf,
int period); |
Fast stochastic %K |
Array_t
fSTOCHFASTD
|
(TimeFrame_t
tf,
int period); |
Fast stochastic %D |
Array_t fMACD
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Moving average convergence/divergence
|
Array_t
fMACDSIGNAL
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Moving average convergence/divergence
signal
|
Array_t
fMACDHIST
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Moving average convergence/divergence
histogram
|
Array_t fMFI
|
(TimeFrame_t
tf,
int period); |
Money flow index
|
Array_t
fMOMENTUM
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Momentum
|
Array_t fPSAR
|
(TimeFrame_t
tf,
int period); |
Parabolic SAR
|
Array_t fROC
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Rate of change
|
Array_t fRSI
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Relative strength index
|
Array_t fSMA
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Simple moving average
|
Array_t
fSTDDEV
|
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Standard deviation
|
Array_t fWILLR
|
(TimeFrame_t
tf,
int period); |
Williams %R
|
Array_t
fLINEARREG |
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Linear regression
|
Array_t
fLINEARREG_INTERCEPT |
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Linear regression intercept
|
Array_t
fLINEARREG_SLOPE |
(TimeFrame_t
tf,
int period,
Price_t
appliedprice); |
Linear regression slope
|
Array_t gEMA
|
(int period,
Array_t data)
|
Exponential moving average |
Array_t
gSMA |
(int period,
Array_t
data) |
Simple moving average |
Array_t
gSTDDEV |
(int period,
Array_t
data) |
Standard deviation |
Array_t
gLINEARREG |
(int period,
Array_t
data) |
Linear regression |
Array_t
gLINEARREG_INTERCEPT |
(int period,
Array_t
data) |
Linear regression intercept |
Array_t
gLINEARREG_SLOPE |
(int period,
Array_t
data) |
Linear regression slope |
|