| Concept | Lipi | MQL4 | MQL5 | NinjaScript | Pine Script | thinkScript |
|---|---|---|---|---|---|---|
| Absolute value | math.abs | Exact | Exact | Exact | Exact | Exact |
| Rounding | math.round, math.ceil, math.floor | Caveat | Caveat | Differs | Caveat | Differs |
| Round to the tick size | math.round_to_mintick | Caveat | Absent | Caveat | Exact | Composite |
| Smaller or larger of values | math.min, math.max | Caveat | Caveat | Caveat | Exact | Caveat |
| Powers and roots | math.pow, math.sqrt | Exact | Exact | Caveat | Exact | Caveat |
| Exponent and logarithms | math.exp, math.log, math.log10 | Caveat | Caveat | Caveat | Exact | Caveat |
| Trigonometry | math.sin, math.cos, math.tan, math.asin, math.acos, math.atan | Exact | Exact | Exact | Exact | Exact |
| Degrees and radians | math.todegrees, math.toradians | Absent | Absent | Absent | Exact | Absent |
| Sign of a number | math.sign | Absent | Absent | Caveat | Exact | Caveat |
| Random number | math.random | Differs | Differs | Caveat | Caveat | Caveat |
| Average and sum of values | math.avg, math.sum | Absent | Caveat | Caveat | Caveat | Differs |
| Number to text | str.tostring | Caveat | Caveat | Caveat | Caveat | Differs |
| Text to number | str.tonumber | Caveat | Caveat | Caveat | Exact | Absent |
| Length of text | str.length | Caveat | Caveat | Caveat | Caveat | Absent |
| Upper and lower case | str.upper, str.lower | Differs | Differs | Caveat | Exact | Absent |
| Find text | str.contains, str.pos, str.startswith, str.endswith | Caveat | Caveat | Caveat | Caveat | Absent |
| Part of a text | str.substring | Differs | Differs | Differs | Caveat | Absent |
| Replace text | str.replace, str.replace_all | Differs | Differs | Caveat | Differs | Absent |
| Split text | str.split | Caveat | Caveat | Caveat | Exact | Absent |
| Trim spaces | str.trim | Caveat | Caveat | Exact | Exact | Absent |
| Repeat text | str.repeat | Caveat | Caveat | Caveat | Caveat | Absent |
| Match a pattern | str.match | Absent | Absent | Caveat | Caveat | Absent |
| Join texts | + | Caveat | Caveat | Caveat | Exact | Caveat |
Absolute value
The absolute value ofnumber: its magnitude, with the sign removed.
In Lipi: math.abs.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathAbs | Exact | |
| MQL5 | MathAbs | Exact | |
| NinjaScript | Math.Abs | Exact | |
| Pine Script | math.abs | Exact | |
| thinkScript | AbsValue | Exact |
Rounding
Roundsnumber to the nearest whole number and returns an int.
In Lipi: math.round, math.ceil, math.floor.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathRound, MathCeil, MathFloor | Equivalent, with a caveat | All three return double, not int, and take no precision argument; cast to int when a count is needed. Numbers and types: result type is double, where Lipi rounding returns int. |
| MQL5 | MathRound, MathCeil, MathFloor | Equivalent, with a caveat | All three return double, not int, and MathRound has no decimals argument. Cast to int, or use NormalizeDouble for decimal places. Numbers and types: Results are double; Lipi’s one-argument round, ceil and floor return int. |
| NinjaScript | Math.Round, Math.Ceiling, Math.Floor | Looks alike, behaves differently | All three return double, not int. Math.Round on a midpoint defaults to round-half-to-even (2.5 gives 2); cast to int for a whole number. Numbers and types: Return type is double; Lipi’s one-argument forms return int. |
| Pine Script | math.round, math.ceil, math.floor | Equivalent, with a caveat | Pine rounds ties up (toward positive infinity); Lipi rounds ties away from zero, so -2.5 gives -3 in Lipi and -2 in Pine. |
| thinkScript | Round, RoundUp, RoundDown, Ceil, Floor | Looks alike, behaves differently | Round() keeps 2 decimals by default, while Lipi math.round with no precision gives a whole int; RoundDown truncates toward zero, unlike floor. Numbers and types: thinkScript results stay doubles; Lipi ceil, floor and one-argument round return int. |
Round to the tick size
Roundsnumber to the nearest multiple of syminfo.mintick for the chart symbol.
In Lipi: math.round_to_mintick.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | NormalizeDouble | Equivalent, with a caveat | Rounds to a decimal count (0-8), usually Digits(), not to a tick multiple; differs when the tick is not a power of ten. |
| MQL5 | Not in MQL5 | No tick-size rounding function. NormalizeDouble rounds to a count of decimal digits (0 to 8), not to a multiple of the tick size. | |
| NinjaScript | Instrument.MasterInstrument.RoundToTickSize | Equivalent, with a caveat | Called on the instrument object; page says it rounds up to a tick multiple, where Lipi rounds to nearest. A separate RoundDownToTickSize exists. |
| Pine Script | math.round_to_mintick | Exact | |
| thinkScript | Round, TickSize | Built from several Lipi constructs | No single function: divide by TickSize(), Round to 0 digits, multiply back by TickSize(). Lipi math.round_to_mintick does this in one call. |
Smaller or larger of values
The smallest of the numbers you pass. In Lipi:math.min, math.max.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathMin, MathMax | Equivalent, with a caveat | Exactly two arguments; nest calls to compare more values, where Lipi accepts any number. |
| MQL5 | MathMin, MathMax | Equivalent, with a caveat | Exactly two arguments; nest calls for more values. Integer arguments keep an integer result type. Numbers and types: Mixed argument types are cast to the larger type, and the result has that type. |
| NinjaScript | Math.Min, Math.Max | Equivalent, with a caveat | Exactly two arguments; Lipi accepts any number of values. Nest the calls to compare more. |
| Pine Script | math.min, math.max | Exact | |
| thinkScript | Min, Max | Equivalent, with a caveat | Exactly two arguments; Lipi math.min and math.max take any number. Neither looks back over bars (Lowest and Highest do). |
Powers and roots
base raised to the power of exponent.
In Lipi: math.pow, math.sqrt.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathPow, MathSqrt | Exact | |
| MQL5 | MathPow, MathSqrt | Exact | |
| NinjaScript | Math.Pow, Math.Sqrt | Equivalent, with a caveat | Math.Pow returns infinity for a zero base with a negative exponent; Lipi math.pow returns na there, changing later comparisons. |
| Pine Script | math.pow, math.sqrt | Exact | |
| thinkScript | Power, Sqrt, Sqr | Equivalent, with a caveat | Power and Sqrt map to math.pow and math.sqrt; Sqr (square) has no Lipi function, use math.pow(x, 2). |
Exponent and logarithms
Euler’s number raised to the power ofnumber.
In Lipi: math.exp, math.log, math.log10.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathExp, MathLog, MathLog10 | Equivalent, with a caveat | Invalid input gives NaN, and MathLog(0) gives INF, where Lipi’s log10 gives na. Warm-up and missing values: out-of-domain input yields NaN or INF, not na. |
| MQL5 | MathExp, MathLog, MathLog10 | Equivalent, with a caveat | MathLog(0) returns infinity and negatives give NaN; Lipi math.log(0) and negatives return na, so later comparisons on the result differ. |
| NinjaScript | Math.Exp, Math.Log, Math.Log10 | Equivalent, with a caveat | Math.Log(0) returns negative infinity; Lipi math.log(0) returns na, so later comparisons on the result differ. |
| Pine Script | math.exp, math.log, math.log10 | Exact | |
| thinkScript | Exp, Log, Lg | Equivalent, with a caveat | Log is the natural logarithm and Lg is base 10, so Lg maps to math.log10, not math.log. |
Trigonometry
The sine ofangle, where the angle is in radians.
In Lipi: math.sin, math.cos, math.tan, math.asin, math.acos, math.atan.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathSin, MathCos, MathTan, MathArcsin, MathArccos, MathArctan | Exact | |
| MQL5 | MathSin, MathCos, MathTan, MathArcsin, MathArccos, MathArctan | Exact | |
| NinjaScript | Math.Sin, Math.Cos, Math.Tan, Math.Asin, Math.Acos, Math.Atan | Exact | |
| Pine Script | math.sin, math.cos, math.tan, math.asin, math.acos, math.atan | Exact | |
| thinkScript | Sin, Cos, Tan, ASin, ACos, ATan | Exact |
Degrees and radians
Converts an angle in radians to the same angle in degrees. In Lipi:math.todegrees, math.toradians.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No degree/radian converters in the math group; multiply by the pi/180 factor yourself. | |
| MQL5 | Not in MQL5 | The math index has no degree or radian conversion function; multiply by 180 over pi yourself. | |
| NinjaScript | Not in NinjaScript | System.Math has no degree or radian converters; multiply by 180/Math.PI, or its inverse, by hand. | |
| Pine Script | math.todegrees, math.toradians | Exact | |
| thinkScript | Not in thinkScript | No degree/radian conversion function in the math section; docs multiply by 180 and divide by Double.Pi by hand. |
Sign of a number
The sign ofnumber: -1 for a negative number and 1 for a positive one.
In Lipi: math.sign.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No sign function in the math group; compare the value to zero. | |
| MQL5 | Not in MQL5 | No sign function in the math index; use a comparison expression instead. | |
| NinjaScript | Math.Sign | Equivalent, with a caveat | Returns an int (-1, 0 or 1), while Lipi returns a float; it throws on NaN. Numbers and types: int result instead of float. |
| Pine Script | math.sign | Exact | |
| thinkScript | Sign | Equivalent, with a caveat | Returns 1, 0 or -1, so zero gives 0; Lipi’s reference states only -1 and 1, so check how it treats zero. |
Random number
Gives your script a random float, bounded below bymin and above by max.
In Lipi: math.random.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | MathRand, MathSrand | Looks alike, behaves differently | Returns an integer 0 to 32767, not a float in a range you choose; scale it yourself. Call MathSrand first to set the seed. State and side effects: generator state is seeded with MathSrand; a fixed seed repeats the sequence. |
| MQL5 | MathRand, MathSrand | Looks alike, behaves differently | Returns an integer from 0 to 32767, not a float between two bounds. Seed with MathSrand before the first call and scale the result yourself. Numbers and types: Integer result 0 to 32767 instead of a float within min and max. State and side effects: The generator must be seeded with MathSrand first; Lipi has no seed argument. |
| NinjaScript | Random.NextDouble() | Equivalent, with a caveat | An instance method on a Random object; returns 0.0 up to but excluding 1.0. Scale to min and max by hand. |
| Pine Script | math.random | Equivalent, with a caveat | Pine takes an optional seed for repeatable sequences; Lipi has none. Pine’s reference excludes the lower bound, Lipi’s docs include it. |
| thinkScript | Random | Equivalent, with a caveat | Takes no arguments and returns a value from 0.0 up to, not including, 1.0; scale it yourself to match math.random(min, max). |
Average and sum of values
The arithmetic mean of the numbers you pass: their sum divided by how many there are. In Lipi:math.avg, math.sum.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No average or multi-value sum in the math group; MathMax and MathMin take two values only. | |
| MQL5 | MathMean, vector::Sum | Equivalent, with a caveat | MathMean averages an array, not a list of arguments. There is no per-bar windowed sum; vector::Sum totals a whole vector you fill first. |
| NinjaScript | Enumerable.Average() and Enumerable.Sum() (System.Linq) | Equivalent, with a caveat | Apply to an array or list, not to separate arguments; needs using System.Linq. Average and Sum are separate calls. |
| Pine Script | math.avg, math.sum | Equivalent, with a caveat | Pine math.sum ignores na values; Lipi returns na on bars where the current source is na and skips na inside the window. |
| thinkScript | Average, Sum | Looks alike, behaves differently | Average is a moving window like ta.sma, not Lipi math.avg (mean of its arguments). Sum is a window sum and matches math.sum. History indexing: Average looks back over length bars; Lipi math.avg averages only its own arguments on the current bar. |
Number to text
Renders a value as a string. In Lipi:str.tostring.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | DoubleToString, IntegerToString | Equivalent, with a caveat | One function per type; DoubleToString defaults to 8 decimals where Lipi trims to 4. No na or bool rendering is documented. Numbers and types: decimals are set by the digits argument (0-16); negative values give scientific format. |
| MQL5 | DoubleToString, IntegerToString | Equivalent, with a caveat | Fixed decimal places (default 8; negative digits give scientific form). Separate IntegerToString for integers; no bool or na handling. Numbers and types: Digits 0 to 16 are kept as fixed places; Lipi rounds to 4 places and trims trailing zeros. |
| NinjaScript | ToString() | Equivalent, with a caveat | No default four-decimal rounding: full precision prints. Bool prints True or False. Custom patterns go in as a format string. Numbers and types: Lipi rounds floats to four decimals by default; C# does not. |
| Pine Script | str.tostring | Equivalent, with a caveat | Pine renders na as “NaN”; Lipi renders “NA”. Lipi’s unformatted float rounds to 4 decimals; Pine’s reference states no such default. Warm-up and missing values: A na value becomes the text “NaN” in Pine and “NA” in Lipi, so string comparisons on it differ. |
| thinkScript | AsText | Looks alike, behaves differently | AsText defaults to 2 decimals; Lipi str.tostring rounds to 4 decimals. Concat and the + operator convert doubles with 4 decimals. Numbers and types: Decimal places come from a NumberFormat constant, not a format string such as Lipi’s ”#.####”. |
Text to number
Reads a number out of a string. In Lipi:str.tonumber.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringToDouble, StringToInteger | Equivalent, with a caveat | Two functions by result type (double, long); Lipi always returns float. Behaviour on unparsable text is not documented. Numbers and types: StringToInteger returns long, not float. |
| MQL5 | StringToDouble, StringToInteger | Equivalent, with a caveat | Two functions by result type (double or long); Lipi always returns a float. The page does not state behaviour on invalid text. Numbers and types: StringToInteger returns long; Lipi returns float for every input. |
| NinjaScript | double.TryParse / double.Parse | Equivalent, with a caveat | TryParse reports success through a bool return and an out parameter instead of giving na on bad text. |
| Pine Script | str.tonumber | Exact | |
| thinkScript | Not in thinkScript | No text-to-number function: the conversion table shows String accepting only Symbol, and no function in the reference parses text. |
Length of text
Gives the length of a string as an int. In Lipi:str.length.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringLen | Equivalent, with a caveat | Counts symbols of a Unicode string; Lipi counts UTF-8 bytes, so non-ASCII text gives different numbers. |
| MQL5 | StringLen | Equivalent, with a caveat | Counts symbols without the terminating zero. Lipi counts UTF-8 bytes, so non-ASCII text can give different results. |
| NinjaScript | string.Length | Equivalent, with a caveat | A property, not a call; it counts Char objects (UTF-16 units) where Lipi counts UTF-8 bytes, so non-ASCII text can differ. |
| Pine Script | str.length | Equivalent, with a caveat | Pine’s reference counts characters; Lipi counts UTF-8 bytes, so text outside ASCII gives a larger Lipi length. |
| thinkScript | Not in thinkScript | No string length function; the String type page describes only text constants in double quotes. |
Upper and lower case
Converts a string to upper case; the other half of the pair with str.lower. In Lipi:str.upper, str.lower.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringToUpper, StringToLower | Looks alike, behaves differently | Changes the variable in place and returns a success bool, not the converted text; do not use the result as the string. State and side effects: the string argument is [in][out] and is modified by the call. |
| MQL5 | StringToUpper, StringToLower | Looks alike, behaves differently | Changes the variable in place and returns a success flag, not the new string. Code like s = StringToUpper(s) is wrong here. State and side effects: Mutates its argument by reference; Lipi returns a new string and leaves the source unchanged. |
| NinjaScript | ToUpper(), ToLower() | Equivalent, with a caveat | ToUpper() and ToLower() use the current culture’s casing rules; Lipi’s str.upper and str.lower do not depend on culture. |
| Pine Script | str.upper, str.lower | Exact | |
| thinkScript | Not in thinkScript | No upper or lower case functions in the reference; text tools are limited to +, Concat and AsText. |
Find text
Tests whether one string occurs inside another. In Lipi:str.contains, str.pos, str.startswith, str.endswith.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringFind | Equivalent, with a caveat | Returns the start position or -1, like str.pos. Contains is a test for >= 0; starts-with and ends-with have no function. |
| MQL5 | StringFind | Equivalent, with a caveat | One function returns a 0-based start position or -1. Contains, startswith and endswith are tests on that result or on StringSubstr. |
| NinjaScript | Contains, IndexOf, StartsWith, EndsWith | Equivalent, with a caveat | IndexOf returns a character index where Lipi counts bytes. StartsWith and EndsWith with a string argument are culture-sensitive by default. |
| Pine Script | str.contains, str.pos, str.startswith, str.endswith | Equivalent, with a caveat | str.pos returns na when absent, Lipi returns -1 (byte offsets). Pine names the second parameter str in startswith and endswith; Lipi uses prefix and suffix. Warm-up and missing values: Not-found is na in Pine and -1 in Lipi, so a na() test on the result never fires in Lipi. |
| thinkScript | Not in thinkScript | No contains, position, starts-with or ends-with function; the docs only show whole-string == comparison. |
Part of a text
Cuts a piece out of a string. In Lipi:str.substring.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringSubstr | Looks alike, behaves differently | Third argument is a length, not an end index; a length of 0 or less runs to the end of the string. |
| MQL5 | StringSubstr | Looks alike, behaves differently | The third argument is a length, not an end index; -1 or omitted runs to the end. Lipi’s second bound is an exclusive end position. |
| NinjaScript | Substring | Looks alike, behaves differently | Second argument is a length, not an exclusive end index as in Lipi. .NET counts UTF-16 code units; Lipi counts whole characters. |
| Pine Script | str.substring | Equivalent, with a caveat | Same 0-based, start-inclusive, end-exclusive cut with optional end. Pine’s parameters are begin_pos and end_pos; Lipi’s are start and end. |
| thinkScript | Not in thinkScript | No substring or slicing function; strings can only be built (Concat, +) and compared. |
Replace text
Substitutes one piece of text for another inside a string. In Lipi:str.replace, str.replace_all.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringReplace | Looks alike, behaves differently | Edits the string in place, replaces every match, and returns the replacement count (-1 on error), not the new text. State and side effects: the str argument is [in][out] and is modified. |
| MQL5 | StringReplace | Looks alike, behaves differently | Edits the variable in place, replaces every match and returns the replacement count (-1 on error). There is no maximum-count argument. State and side effects: Mutates its argument and returns a count, not the new string. |
| NinjaScript | Replace | Equivalent, with a caveat | Replaces every occurrence and has no count argument, so it matches Lipi’s replace_all, not the counted replace. |
| Pine Script | str.replace, str.replace_all | Looks alike, behaves differently | Pine str.replace changes only the single occurrence numbered by occurrence (0-based, default first). Lipi’s str.replace changes all unless count limits it. |
| thinkScript | Not in thinkScript | No text replacement function in the reference. |
Split text
Splitsstring wherever separator occurs and returns the pieces as an array of strings.
In Lipi: str.split.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringSplit | Equivalent, with a caveat | Separator is one character code (ushort), pieces fill an output array, and the return value is the piece count. |
| MQL5 | StringSplit | Equivalent, with a caveat | The separator is one character code, not a string. Pieces go into an output array and the call returns their count. |
| NinjaScript | Split | Equivalent, with a caveat | Returns string[]. The separator is a char or an array of strings plus an options value, not one plain string argument. |
| Pine Script | str.split | Exact | |
| thinkScript | Not in thinkScript | No split function, and no array type to return pieces in. |
Trim spaces
Removes whitespace from around a string and hands back the result. In Lipi:str.trim.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringTrimLeft, StringTrimRight | Equivalent, with a caveat | Two functions, one per side; the page says the string is modified in place and a copy is returned. Call both to trim both ends. State and side effects: The page says the string argument is modified in place as well as returned. |
| MQL5 | StringTrimLeft, StringTrimRight | Equivalent, with a caveat | Two in-place calls, one per side, each returning the number of cut characters. They cut line feeds, spaces and tabs. State and side effects: Mutates the variable passed in instead of returning a new string. |
| NinjaScript | Trim() | Exact | |
| Pine Script | str.trim | Exact | |
| thinkScript | Not in thinkScript | No whitespace trimming function in the reference. |
Repeat text
Produces a string made of repeated copies of another, with the option of something between the copies. In Lipi:str.repeat.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | StringInit | Equivalent, with a caveat | Fills a string with one repeated character in place; cannot repeat a multi-character text or add a separator. |
| MQL5 | StringInit | Equivalent, with a caveat | Fills a variable with one repeated character code to a set length. It cannot repeat a longer string or add a separator. |
| NinjaScript | string.Concat(Enumerable.Repeat(text, count)) | Equivalent, with a caveat | No String method repeats text. Combine Enumerable.Repeat with string.Concat or string.Join; a separator needs Join. |
| Pine Script | str.repeat | Equivalent, with a caveat | Same behaviour; the count parameter is named repeat in Pine and count in Lipi, which matters for named arguments. |
| thinkScript | Not in thinkScript | No text repeat function in the reference. |
Match a pattern
Returns the first part ofsource that matches the regular expression pattern.
In Lipi: str.match.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No regular-expression function in the string group; search with StringFind and cut with StringSubstr. | |
| MQL5 | Not in MQL5 | The string function list has no regular-expression function; pattern matching needs manual string handling. | |
| NinjaScript | Regex.Match(input, pattern) | Equivalent, with a caveat | Returns the first match as a Match object, not a string; read its Value property. Pattern syntax is .NET regex, not RE2. |
| Pine Script | str.match | Equivalent, with a caveat | Parameter is regex in Pine, pattern in Lipi. Lipi patterns use RE2 (no lookaround or backreferences); Pine’s reference names no dialect. |
| thinkScript | Not in thinkScript | No regular-expression or pattern matching function in the reference. |
Join texts
Joining two pieces of text into one. In Lipi:+.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | + operator, StringConcatenate | Equivalent, with a caveat | In MQL4 + joins a string and a number by converting the number; Lipi needs str.tostring first. StringConcatenate joins many values in one call. |
| MQL5 | + | Equivalent, with a caveat | MQL5 casts the non-string operand of + to string automatically; Lipi rejects string + number, so numbers must be wrapped in str.tostring. |
| NinjaScript | + | Equivalent, with a caveat | C# + converts a non-text operand to text; Lipi’s + joins text only, so wrap numbers in str.tostring. |
| Pine Script | + | Exact | |
| thinkScript | +, Concat | Equivalent, with a caveat | Concat joins exactly two values, so nest calls for more; + does the same inline. Non-text values are converted first, doubles with 4 decimals. |