// automagic number generator int AutoMagic() { int m,dE; string s; s=StringConcatenate(EA_Name,MagicKey,Symbol(),Period(),DoubleToStr(AccountNumber(),0),AccountCompany()); m=djb2(s); if(m<0) m=-m; dE=MathPow(10.0,MathMod(m/7,4)+5); m=MathMod(m,dE)+(m-MathMod(m,dE))/dE; if(m>dE) m=MathMod(m,dE); return(m); } // djb2 hash int djb2(string key) { int i,h=5381,c; for(i=0; i<StringLen(key); i++) { c = StringGetChar(key, i); h = (h << 5) + h + c; } return(h); }
发表评论