Function Pseudo Random Generator

Function to return a pseudo random number.
you can constrict it to a range and provide a seed to step through on the same bar.

thanks to Duyck, for the link.
Release Notes: Update for V4, the function now can return a prng value every time its called.
it uses a external global variable to parse the seed in and out via parameters and output.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


not clear what is this indicator how do you use it
Hi Sir , absolute work. I have a question : Can we limit range ? ( For example : Random numbers between : 20 - 100 ) . Best regards.
@Noldo, 20 + f_pseudo_random_number(80, 0)
+1 Reply
Noldo RicardoSantos
@RicardoSantos, Thank you so much !
You're undervalued, as a coder and a trader, I admire your work from a long time. I've been thinking how to generate random numbers for a while and I've only found failure - and there you go.

Good find!
You are a historic trader in Trading View
Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Private Messages Chat Sign Out