creating a magic number - page 2

 
cameofx:
Goodness, you beat my editing speed :)). I edited it. Forgot to mention It's a GlobalVariable.

And what happens if u have to continue a session from a DIFFERENT terminal (cause your computer died for example)...? U would still need a persistence layer (GV's are stored with the Terminal - client side). The whole idea behind an 'automated' magic number, is to get a unique one for each expert but without needing a persistence layer...

 
gordon:

Because then u have to keep a persistence level for that magic. What happens if your Terminal restarts? The magic would be different...

I read somewhere GlobalVariable values exist like 14 days after last access. Besides if that technique holds, we have extra benefit of retrieving time of order by its magic number.

What do you recon?

 
gordon:

And what happens if u have to continue a session from a DIFFERENT terminal (cause your computer died for example)...? U would still need a persistence layer (GV's are stored with the Terminal - client side). The whole idea behind an 'automated' magic number, is to get a unique one for each expert but without needing a persistence layer...

That would probably break the GV, but the seconds will hold and it is unique to the seconds IMHO..

 
cameofx:

That would probably break the GV, but the seconds will hold and it is unique to the seconds IMHO..

It is unique; no disagreement there. But again - let's say the computer breaks. U take your expert to another computer with another terminal, log onto the same account and continue the same expert. If the expert is designed properly, then this 'should' be no problem, except that now the expert would assign a DIFFERENT magic to the orders it's handling. So obviously it won't work.

 
cameofx:

I read somewhere GlobalVariable values exist like 14 days after last access. Besides if that technique holds, we have extra benefit of retrieving time of order by its magic number.

What do you recon?

I think 30... But regardless, they stay client side with the specific Terminal.


p.s. if u haven't done so then take a look at this thread -> https://www.mql5.com/en/forum/120034. Discusses the same problem and has many cool ideas...

 
gordon:

... except that now the expert would assign a DIFFERENT magic to the orders it's handling. So obviously it won't work.

I don't understand..

- I thought the point is to assign a different magic number for each generated trade? Only after an order is accepted by broker then the OrderMagicNumber() is fixed and can be retrieved.

If the previous trade by former 'dead' client terminal has successfully generated OrderMagicNumber then the next same or - different expert in different terminal will not generate the same magic number.

- IMHO - using your terms : Time is persistent without the need for layering, No two times are ever the same.. :))

- Thank you for the links, I have read them. I have nothing against magic number that is generated to be completely random, but I still prefer a magic number that is somewhat logical and have other uses..

- Maybe the technique will break if you have 2 or more orders accepted at a fraction of a second on different terminals. which I'm guessing is unlikely...

 
cameofx:

I don't understand..

- I thought the point is to assign a different magic number for each generated trade? Only after an order is accepted by broker then the OrderMagicNumber() is fixed and can be retrieved.

If the previous trade by former 'dead' client terminal has successfully generated OrderMagicNumber then the next same or - different expert in different terminal will not generate the same magic number.

- IMHO - using your terms : Time is persistent without the need for layering, No two times are ever the same.. :))

- Thank you for the links, I have read them. I have nothing against magic number that is generated to be completely random, but I still prefer a magic number that is somewhat logical and have other uses..

- The technique will break if you have 2 or more orders accepted at a fraction of a second on different terminals. which I'm guessing is unlikely...

No... It's for the entire expert. So if u run a few experts in the same account they won't interfere with each other. Personally, I don't like or use an automated system either. I use a range of magic numbers for each expert as opposed to one magic number, cause I store information in the magic. Regardless, this thread discusses how to automatically set a unique magic number for each expert.

 
Gordon,
I value your opinion. maybe I didn't explain it too clearly, but please re-read my post regarding this technique. It is for the entire expert
(and consequently each expert, each trade, each terminal, automatically) ... hence the use of WindowsExpertName() call retrieving its ID and concatenating it with a GlobalVariable counter each time the expert with the same name is attached to different charts & TimeCurrent().
Please consider it some more.. It either holds or it won't. If you or others find it easily breakable then probably I would have to rethink this too... :))
 
cameofx:
Gordon,
I value your opinion. maybe I didn't explain it too clearly, but please re-read my post regarding this technique. It is for the entire expert... hence the use
of WindowsExpertName() call and concatenating it with a GlobalVariable counter each time the expert with the same name is attached to different charts.
Please consider it some more.. It either holds or it won't. If you or others find it easily breakable then probably I would have to rethink this too... :))
I did. I was referring to what u said ("I thought the point is to assign a different magic number for each generated trade"), not to the original post. Sorry if I wasn't clear.

Anyway, after reading it again. Here are the problems I see with it:
- What is the ID number? A hard-coded unique number for each expert or what? It's easy to make sure experts don't have the same name, it's harder to make sure they don't have the same number, especially if it's hard-coded.
- Persistence. Persistence. Persistence. Again - how do u continue a session from another terminal. Where is the time-frame saved for example?
- User might mess around with GV's manually (but this will probably not be a concern in most cases...).

Edit: maybe the time-frame is not a good example...
 
I'm glad you're online at the same time I have net connection...:) I'm stealing time between work.. :D
I'll put some codes...
Reason: