Lipi Reference
Lipi

Functions

math.random()

Gives your script a random float, bounded below by `min` and above by `max`. The contract marks both bounds optional and offers nothing else. In particular there is no seed argument, so the language gives you no way to ask for a result you can reproduce. Keep the value out of anything a reader is meant to compare between runs. It is the one function in this namespace published in a single form, series. A series value is refused wherever a narrower form is required, so this result cannot fill a const, input or simple argument - a script's title, for instance.

Syntax

                math.random(series float min, series float max) → series float
              

Arguments

min series float The lower bound of the range of random values. The value is not included in the range. The default is 0.
max series float The upper bound of the range of random values. The value is not included in the range. The default is 1.

Return Type

series float

Example


          //@lipi=2
indicator("math.random Example", overlay=false)
noise = math.random(-1, 1)
plot(noise, title="Random Value", color=color.gray)