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
I'm missing something here. If I open two charts for e.g. USDJPY H1, and add an instance of the EA to each of them, then both use the the magic number 9999033.
Yes, that option was not built into it because I never had any use for it. Only possibility to distinguish between two indentical charts (that I can see) would be to hash in the window handle...
but then you'd loose the persistance over restartsand chart close, and therefore orphaned orders may or will be created as a result.
So is the MT terminal app a 'container' - with a single hWnd for <the whole thing>?
Yes. It's a fairly typical MDI application. There's a top-level window which contains things like toolbars, panes, and the MDI client area. The latter then contains each chart, and each chart actually consists of two windows: a container with the drawing area inside it. Each of these things has its own hWnd handle. The WindowHandle() function returns the handle of the drawing area, and therefore using the GetParent() API call three times gives you the hWnd of the top-level MT4 window.
fwiw, I use below and have never had duplicates. Same EA on up to 10 [any type] charts.
I have no answer to the massively overkill junk actuals handed to hash function. I just shoved in everything including the kitchen sink. ie, I'm no maths person..., just hammer 'n chisled away until never got repeats - even on terminal startup with 10 chart profile all same EA...
Obviously, I would be keen to have a better and more describable/logical method... so start tearing it to pieces :O)
fwiw, I use below and have never had duplicates. Same EA on up to 10 [any type] charts.
I have no answer to the massively overkill junk actuals handed to hash function. I just shoved in everything including the kitchen sink. ie, I'm no maths person..., just hammer 'n chisled away until never got repeats - even on terminal startup with 10 chart profile all same EA...
Obviously, I would be keen to have a better and more describable/logical method... so start tearing it to pieces :O)
I like it. Particularly the good ol' djb2 hash.
Very impressive stuff chaps :)
MDI containers takes me back <sigh>
I still say that, IMHO, Magic Numbers are too important to apply randomly!
I'm sure CB would confirm that predictable recovery on restart is an extremely important element in a robust system..
FWIW
-BB-
With this code an EA is able to recognize its own orders if the platform shutdowns. It uses Global Variables so if you want to make the EA "inmune" to PC shutdown it could be rewritten to use files instead of Global Variables. I have attached too an example that opens a position just at the init time and closes it in the next bar, you can load the expert in 1M timeframe, shutdown metatrader and then open it again, just wait for the next bar to see how the EA closes its order. It hasn't been proved with multiple graphs neither tricked with multiple orders, but what do you think about it?
I like it. Particularly the good ol' djb2 hash.
thanks - but I really do feel sheepish about such an uninformed bit of coding in makeexpertid...
Is early yet but maybe someone will spot the flaw(s)... should they be present
Very impressive stuff chaps :)
MDI containers takes me back <sigh>
I still say that, IMHO, Magic Numbers are too important to apply randomly!
I'm sure CB would confirm that predictable recovery on restart is an extremely important element in a robust system..
FWIW
-BB-
I still say that, IMHO, Magic Numbers are too important to apply randomly!
for sure BB, vip datums. I spent way too much time attempting to discover a unique datum which multiple instances of an EA could use. This datum had to be repeatable such that all files opened would be mapable on recovery/restart. I wanted to allow possibility of any number of same ccy+per chart EA instances to 'some how' open a unique filename and on restart magically reopen...
Window handle data could be that 'factor X' ?
for sure BB, vip datums. I spent way too much time attempting to discover a unique datum which multiple instances of an EA could use. This datum had to be repeatable such that all files opened would be mapable on recovery/restart. I wanted to allow possibility of any number of same ccy+per chart EA instances to 'some how' open a unique filename and on restart magically reopen...
I can't see how this is possible without either MT4 or the user assigning an ID to each EA. Or, more accurately, I can't see anything which doesn't involve something very nasty such as generating a unique ID and then modifying the EA's .chr file to store the ID as part of the EA's extern parameters.
And, for general entertainment, the following doesn't really advance the discussion in any way, but it replaces the input to the djb2 hash with a value which is guaranteed to be unique (at the cost of requiring DLL calls). I don't know how good djb2 is meant to be on things like GUIDs, but I've just tried generating 1,000,000 IDs without any collisions. But still doesn't solve the restart issue.
Window handle data could be that 'factor X' ?
If you weren't partially closing any orders, you could use the order comment to store the originating pair/timeframe info..?
Thus the EA, on restart, could work out if it had any prior orders and what magic number it was therefore supposed to be using?
NB
Keep the comments to < 25 and check on the LEFT(OrderComments(), 24) else the [sl] or [tp] stuff could affect things
Does assume that <all history> is left available in the Account History tab!
FWIW
-BB-