You do NOT want to "generate Magic Number automatically," i.e. generate using hash/windowHandle etc. because, then you must use permanent storage to find your orders in case of restart.
Yours is just using a range of numbers. I do it slightly differently
extern int Magic.Number.Base = 20110202; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int magic.number; // Export to ModifyStops string TF.text, // Export to Decide : int init(){ /*++++ Adjust for the current chart timeframe */{ int TFperiod[] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1 }; string TFtext[] = { "M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN1" }; for(int iTF=0; TFperiod[iTF] < Period(); iTF++){} TF.text = TFtext[iTF]; magic.number = Magic.Number.Base + iTF; /*---- Adjust for the current chart timeframe */} : }OrderSelect loops filter on magic.number and pair.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
thanks in advance