2026-08-31 21:32:45 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Main.mqh |
|
|
|
|
|
//| Copyright 2026, Niquel Mendoza |
|
|
|
|
|
//| https://www.mql5.com |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#property copyright "Copyright 2026, Niquel Mendoza"
|
|
|
|
|
#property link "https://www.mql5.com"
|
|
|
|
|
#property strict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PRNGBYLEO_SRC_IMP_NATIVE_NAT_MQH
|
|
|
|
|
#define PRNGBYLEO_SRC_IMP_NATIVE_NAT_MQH
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
namespace TSN
|
|
|
|
|
{
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
class CMathRandNative
|
|
|
|
|
{
|
2026-08-31 21:47:56 -05:00
|
|
|
protected:
|
2026-08-31 21:32:45 -05:00
|
|
|
//---
|
|
|
|
|
uint m_last_seed;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CMathRandNative(void);
|
|
|
|
|
~CMathRandNative(void) {}
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
void Seed(uint seed);
|
|
|
|
|
__forceinline uint LastSeed() const { return m_last_seed; }
|
2026-09-01 09:13:18 -05:00
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
__forceinline uint nextUInt32(void) const;
|
|
|
|
|
__forceinline ulong nextUInt64(void) const;
|
2026-08-31 21:32:45 -05:00
|
|
|
};
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
CMathRandNative::CMathRandNative()
|
|
|
|
|
{
|
|
|
|
|
// para no alterar el global no habra nada aqui cada uno qeu sea responsable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void CMathRandNative::Seed(uint seed)
|
|
|
|
|
{
|
|
|
|
|
m_last_seed = _RandomSeed;
|
|
|
|
|
MathSrand(seed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
__forceinline uint CMathRandNative::nextUInt32(void) const
|
|
|
|
|
{
|
|
|
|
|
return uint(MathRand()) | uint(MathRand()) << 16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
__forceinline ulong CMathRandNative::nextUInt64(void) const
|
|
|
|
|
{
|
|
|
|
|
return ulong(MathRand()) | ulong(MathRand()) << 16 | ulong(MathRand()) << 32 | ulong(MathRand()) << 48;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // PRNGBYLEO_SRC_IMP_NATIVE_NAT_MQH
|