xoshiro256** (named after its operations: XOR, shift, rotate) is a pseudorandom number generator designed by Sebastiano Vigna in collaboration with David Blackman https://prng.di.unimi.it/
This is a 64-bit all-purpose, rock-solid generator. It has excellent (sub-ns) speed, a state size (256 bits) that is large enough for any parallel application, and it passes all known statistical tests.
The xoshiro256** algorithm is not suitable for cryptographic purposes, but is very fast and has excellent statistical properties.
It is presently used in Microsoft's .NET framework and the JavaScript engines of Chrome, Node.js, Firefox, Safari and Microsoft Edge.
The algorithm used here is translated from the https://prng.di.unimi.it/xoshiro256starstar.c reference source code by David Blackman and Sebastiano Vigna.
For MetaTrader programmers and traders, this is highly relevant for:
Monte Carlo Simulations: Accurately simulating price movements, option pricing, or other stochastic processes.
Backtesting and Strategy Optimization: Generating random data or events to test the robustness of a trading strategy under various market conditions.
Indicator and Expert Advisor (EA) Development: Providing a reliable source of randomness for EAs that use randomized logic, such as in genetic algorithms for optimization.
Research and Analysis: The RandomDoubleHighRes method is particularly useful for researchers and quantitative analysts who require a higher degree of precision for their simulations and models, ensuring more accurate and reliable results than standard MathRand().
The class provides an easy interface for random number generation.
//+------------------------------------------------------------------+ //| Class Xoshiro256 | //| Usage: Provides an implementation of the Xoshiro256** algorithm. | //+------------------------------------------------------------------+ class Xoshiro256 { public: // Constructor and destructor Xoshiro256(void); // Auto-seeded constructor ~Xoshiro256(void) { } // Setting the internal state for the generator void Seed(ulong seed); void Seed(ulong a,ulong b,ulong c,ulong d); // Public methods for generating random numbers int RandomInteger(void); // Random integer [0, INT_MAX] int RandomInteger(const int max); // Random integer [0, max) int RandomInteger(const int min,const int max); // Random integer [min, max) long RandomLong(void); // Random long [0, LONG_MAX] long RandomLong(const long max); // Random long [0, max) long RandomLong(const long min,const long max); // Random long [min, max) double RandomDouble(void); // Random double [0.0, 1.0) double RandomDouble(const double max); // Random double [0.0, max) double RandomDouble(const double min,const double max); // Random double [min, max) double RandomDoubleHighRes(void); // Random double [0.0, 1.0) double RandomDoubleHighRes(const double max); // Random double [0.0, max) double RandomDoubleHighRes(const double min,const double max); // Random double [min, max) bool RandomBoolean(void); // Random true/false (equal probability) bool RandomBoolean(const double prob_true); // Random true/false (with prob_true) double RandomNormal(void); // Random double (normal distribution with mean 0, std dev 1) double RandomNormal(const double mu,const double sigma); // Random double (normal distribution) // Sampling utilities template<typename T> void Shuffle(T &arr[]); // Shuffle array arr[] in place using Fisher-Yates template<typename T> bool Sample(const T &arr[], T &dest[], int k); // Sample k unique items from arr[] without replacement template<typename T> bool SampleWithReplacement(const T &arr[], T &dest[], int k); };
If your are doing a lot of Monte Carlo simulations, then this xoshiro256** generator will be much faster and more accurate than MQL's MathRand():
//+------------------------------------------------------------------+ //| speed_benchmark.mq5 | //| Copyright © 2018, Amr Ali | //| https://www.mql5.com/en/users/amrali | //+------------------------------------------------------------------+ #include "Xoshiro256.mqh" //--- the random number generator object Xoshiro256 prng; #define ITER (500*1000*1000) // 500 millions //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { //--- MathRand() benchmark. uint t1 = GetTickCount(); for(int i = 0; i < ITER; i++) { MathRand(); } uint ticks1 = GetTickCount() - t1; //--- Xoshiro256 benchmark. uint t2 = GetTickCount(); for(int i = 0; i < ITER; i++) { prng.RandomInteger(); } uint ticks2 = GetTickCount() - t2; //--- Display results. PrintFormat("Generating %d random integers: ", ITER); PrintFormat("MathRand() -> %u millisec", ticks1); PrintFormat("Xoshiro256 -> %u millisec", ticks2); PrintFormat("Speed-up factor is %.1fx", (double)ticks1/ticks2); } //+------------------------------------------------------------------+ // sample output: /* Generating 500000000 random integers: MathRand() -> 968 millisec Xoshiro256 -> 422 millisec Speed-up factor is 2.3x */
Updates:
2023.01.06 - v.1.01 :
2025.08.01 - v.1.02 :
2025.08.03 - v.1.03 :
2025.08.28 - v.1.05
2025.09.13 - v.1.06
2025.09.19 - v.1.08
2025.10.02 - v.1.09
2026.06.05 - v.1.10
A BITMAP generated from xoshiro256** Random Number Generator

The code is also mirrored on Algo Forge here: https://forge.mql5.io/amrali/Xoshiro256
RSI Bot MT5
RSI Bot, send alert buy when RSI<=20, send alert sell when RSI>=80
Time Segmented Volume (TSV)
Based on the original “Time Segmented Volume (TSV)” developed by Worden Brothers, Inc.
XP Forex Trade Manager Grid MT5
Forex Trade Manager Grid MT5 helps you to managing orders and achieve the goal.
XP Forex Trade Manager MT5
Forex Trade Manager MT5 simplifies managing open orders in MetaTrader 5.