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
Hello!
In this code you check OpenOrdersNew[x][x] - for each order the ea has made
ie:
Order 1 - Check OpenOrdersNew[1][x]
Order 2 - Check OpenOrdersNew[1][x]
Order 3 - Check OpenOrdersNew[1][x]
Order n - Check OpenOrdersNew[1][x]
in:
you save data from the olders order towards the newest (from 0 to n)
Either change the iteration in OpenOrdersArray()....
Or preferably Check OrderOpenTime() for each order and use data from the newest.
Example:
Aloha, Compania!
Yes, this is what I am revising right now. I confess, do not know what is the difference btw
for (int i = 0; i < OrdersTotal(); i++) // https://www.mql5.com/en/articles/1390 = Terminal.mqh - this counts all orders, but starts from last?
for (int i = OrdersTotal() ; i >= 0; i--) // code used in my EA - this counts all orders, but starts from first (oldest)? 'i--' means count backwards > toward newest orders?
for (int i = OrdersTotal() - 1; i >= 0; i--) // tried this too - this counts all arders, but starts from first - 1 (second?)
Or preferably Check OrderOpenTime() for each order and use data from the newest. - I used this in my previously code, had same problems as now, not working correctly.
Thank you for your precious help,
Regards,
Simon
So...
OpenOrdersArray(); function selects orders and puts them in array. I have recoded into original (int Terminal()) version:
Using my 'off-the-attick' funcion 'displayOpenOrdersNew()', the openOrdersArray() seem to work properly. It does select last open order as first, order opened before last as second. So far, so good.
- MT4 log file -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
12:22:25 Agent SukrChi 007 EA EURUSD,H1: Alert: Total no. of open orders: EURUSD - 2
12:22:25 Agent SukrChi 007 EA EURUSD,H1: Alert: Open orders buy: EURUSD - 2
12:22:25 Agent SukrChi 007 EA EURUSD,H1: Alert: #1 order ticket: EURUSD - 152528163, date 2012.06.19, time 13:01, Buy, lots 0.14 at 1.26189, SL at 1.26591
// if (OpenOrdersNew [1,1] > 0) {Alert ("#1 order ticket: "... - order ticket is > than 0, so there is order...
12:22:25 Agent SukrChi 007 EA EURUSD,H1: Alert: #2 order ticket: EURUSD - 152590200, date 2012.06.21, time 12:00, Buy, lots 0.22 at 1.26721, SL at 1.26449
// if (OpenOrdersNew [2,1] > 0) {Alert ("#2 order ticket: "...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
So, it seems that I am selecting wrong order (or coding) in function 'lastIsBE'. How can I select (with OrderSelect()) only array order that I am interested in, that is last one (OpenOrdersNew [1])?
After selecting right order, it should not matter if I check via (OP_BUY):
if (OpenOrdersNew [1,6] >= OpenOrdersNew [1,5] + (MoveSLTo * Point))
or
if (OrderStopLoss() >= OrderOpenPrice() + (MoveSLTo * Point))
Btw, I have not used OrderSelect() (as I have been pointed out) because (by my logic, not necessarily correct) the correct order is already selected by OpenOrdersNew [1,x]. Seems I am missing something here! I mean, do I have to select order from TRADE pool, when OpenOrdersArray() function has already done this? Brrrrrrrr... LOL.
OK, took a look to my code - I do have to select via OrderSelect(), because I want to know if selected order is of correct Symbol() (hey, where is Auto list names function here! LOL) and OrderMagicNumber(). But, maybe if I just condition...
Back to tweaking.
Have fun,
Simon
Regarding this...
order ticket #108, open time = today 11:40 -> lastordertime = today 11:40 - order #108 opened
order ticket #109, open time = today 16:20 -> lastordertime = today 16:20 - order #109 opened
order ticket #109, close time = today 18:15 -> lastordertime = today 16:20 - order #109 closed (time stays the same?)
last order is order #108 and OrderOpenTime() < lastordertime! So it would not select it. Or am I, again!, missing something?
Besta regarda,
Simon
Regarding this...
order ticket #108, open time = today 11:40 -> lastordertime = today 11:40 - order #108 opened
order ticket #109, open time = today 16:20 -> lastordertime = today 16:20 - order #109 opened
order ticket #109, close time = today 18:15 -> lastordertime = today 16:20 - order #109 closed (time stays the same?)
last order is order #108 and OrderOpenTime() < lastordertime! So it would not select it. Or am I, again!, missing something?
Your loop is selecting open orders so it will never see #109
If you were selecting history OrderOpenTime would be unchanged, and OrderCloseTime will be now be nonzero.
This should do the trick, shouldn't? I think I do not have to select orders again, when they are selected in OpenOrdersArray() function already. Just condition... and pray to the Mighty Lord, cause now I am realy out of ideas. It looks like working on Demo, but not on Tester. Is there any catch with arrays and Texter?
Best regards,
Simon
Now this is my old LastIsBE() function (which I will test again):
And this is my old & current trailLast() function:
... both similar as Master enotrek (bow) suggestion.
I was avoiding learning arrays like El Diabolo is avoiding a Holly Cross. I tought it would be cool to learn those el D arrays.
Btw, there is some strange white foam coming out of my mouth. I am afraid... LOL.
Hope this will work now. Hoping for last 2 years...
I, Simon the Wanna-be-coder, humbly bow to all Code Masters helping me! Thank you.
Besta regarda,
Simon
Now back to learning... LOL.
Your loop is selecting open orders so it will never see #109
If you were selecting history OrderOpenTime would be unchanged, and OrderCloseTime will be now be nonzero.
... if I zeroize it, right? This is exactly what I did - at beginning of lastIsBE() custom function set value LastOrderTime = 0;
Now, it seem this to be working properly - trailLast() function:
... and lastIsBE() function:
No more foam from my mouth. Hooraay!
Best regards,
Have fun,
Simon
S love nia