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 do occasionally delete all open orders so that our MT4 friends dont get upset.
u will get this problem in back testing but this is not a script problem.. but a MT4 backtesting problem.
If it continues, please let me know or send me some reports showing the problem...
thanks and reagrds,
hugues
The advisor is creating the grid with my given comment "GridEURUSD". This comment stands in the Commentfield as long as the order is waiting. If the order is activated, the comment changes to "activate/auto". After all its clear that this behavior leds to the described problem.
I am trading with Alpari. They are supporting MT4 in demo accounts
I will check, if I can go around this behavior, i.e. using the magic of the order as identifier for the grid and let you know the results.
While testing this, I have also made modifications to the cleanup script for the grid. I have added functionality to close open orders too. Unfortunately I get error 129 which means Order locked, if I try to close an open order. But it deletes all pending orders for the given grid.
cori
let me know if it works and i will use the magic.. as i was unaware that the broker does strange things like that!!
thanks and regards,
hugues
I have changed the gridMaker to use the OrderMagicNumber instead of the comment. I have also made some small modification about building the comment.
Here is the result.
with regards, cori
since i had already done a few changes myself, i integrated your changes into the newer version.
I did do 1 little variation: in order to keep my current grids active, i put a test on magic OR gridname...
can u check if i did it correctly?
seems ok. But you should define the GridName as extern, which I changed, because I didn't need it as parameter.
greetings, cori
You can change the line :
if (MathAbs( OrderOpenPrice() - atRate ) < inRange) // dont look for exact price but price proximity (less than gridsize)
to
if (MathAbs( OrderOpenPrice() - atRate ) < (inRange*0.9)) // dont look for exact price but price proximity (less than gridsize) - added 0.9 because of floating pont errors
and this corrects the problem.
Sorry for any inconvenience...
hugues
Is this Problem already in there?
Found something similar in old MQL2.
The really sure way to go around this problem is to do something like:
int intOOP = MathRound( OrdeOpenPrice() / Point );
for all your double variables. Then you have all straight int variables which are comparable without faults.
Its a bit more to write to keep it clear and understandable but its less faulty.
with regards,
cori
regards,
hugues
1) changed the logic for UseMACD, wantLongs, wantShorts. Previously, if useMACD was set, the EA took longs and shorts, irrecspective of wnatLongs and wantShorts flags. Now, useMACD will not override these flags so u can be long only with useMACD or short only.
2) I added an additional check to make shure there were no open orders the wrong side of the EMA if the limitEMA34 was set. What used to happen is orders were well placed above or below the EMA but after a few hours the EMA moved.. so there were orders on both sides of the EMA.
3) There seems to be a bug in the switch statement on OrderType().. i am not sure what it is but it really behaves funny. I simply eliminated the switch statements and replaced by "if"... i dont like it but it works!
4) I made the EMA period variable... nice for backtesting..
I also have a few companion scripts if someone wants :
1) to remove unfilled open orders for a pair
2) to remove all open orders for all pairs in one go
3) to close out all positions and remove open orders.
4) to get some simple stats on the grid behaviour from the open positions and history.
Here is the code of V1.08: