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.
math.random(series float min, series float max) → series float| Parameter | Type | Required | Description |
|---|---|---|---|
min | series float | no | The lower bound. The contract marks it optional and does not record what is used when you leave it out, so pass it. |
max | series float | no | The upper bound. The contract marks it optional and does not record what is used when you leave it out, so pass it. |
Returns series float — A series float.
indicator("A random value")
plot(math.random(0, 1))See also math.abs · math.acos · math.asin
Part of the function index.
Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.