Libraries: sToken

 

sToken:

The script contains a class, that can be used to solve mathematical and logical expressions, defined as string.

The script has two classes: cTokenBase and cToken (a member of CTokenBase). The cTokenBase class must be configured before its use (see below).

The following MQL5 mathematical functions are supported: abs, arccos, arcsin, arctan, ceil, cos, exp, floor, log, log10, max, min, mod, pow, rand, round, sin, sqrt, tan.

Logical and math operations:  /, %, *, +, -, >, <, >=, <=, ==, !=, &&, ||.

The expression may contain numbers, including double numbers, user variables and user arrays. If you will use the user's variables and arrays, you need to add functions, that returns the values of these variables and arrays. The functions should be added into the cTokenBase class.

The user variables and arrays are named with letters (the case isn't important), the array elements are defined as follows: e[0], e[1], f[0], f[1].

Author: Дмитрий

sToken demo expressions


sToken demo results

 

Hello,

I recently started to use this library, but, I can't create a custom function with a double as argument, for example:

double MyFunction1(double number);

Or

bool MyFunction2(double number);


One importante point is to evaluate the expression all the times when SolveExpression() is called. This, because my function uses ask and bid prices so, each call have a different value.

I already tried to create a standard function, in the same group as abs(), sin(), cos(), etc., but these functions are evaluated once and becomes a constant.


Is possible to do this or there are a new version?

Reason: