@ Don and MrPip
geee, this is 4th time or 5th time that i have to post about the bug in
void T101_CloseAll(). i refrain myself posting another of my own edition, cos none test it although it correct this closeall() problem.
1. suppose we have 20 pos opened by EA-charvo, 14 pos opened by EA-D&M (if this EA wants to go LIVE, we need to make it ok with other trades/EA.)
2. let's see below:
while(OpenOrders > 0) {
~~~~~~14~~~~~~
for (int i = OpenOrders - 1; i >= 0; i--) {
~~~~~13~~~~~~~~~
OrderSelect(i, SELECT_BY_POS);
if (OrderMagicNumber()==Magicnumber)
{ // do the closing stuff // }
so this for loop will search from 13th to 0th pos, now say, if EA-charvo's pos are number/index from 0~19 (20 pos), then the while-->for loop above will be searching in vain for EA-D&M's pos that are very likely indexed from 20~33.
To correct this problem:
add another internal var:
int allpos = orderstotal();
then in above loop, replace "for (int i = OpenOrders - 1; i >= 0; i--)" with " for (int i = allpos - 1; i >= 0; i--)"
......
never thought a closeall() could be so time-consuming...... my solution is pretty simple, COPY steve hopwood's MPTM's closeall() to this EA.
geee, this is 4th time or 5th time that i have to post about the bug in
void T101_CloseAll(). i refrain myself posting another of my own edition, cos none test it although it correct this closeall() problem.
1. suppose we have 20 pos opened by EA-charvo, 14 pos opened by EA-D&M (if this EA wants to go LIVE, we need to make it ok with other trades/EA.)
2. let's see below:
while(OpenOrders > 0) {
~~~~~~14~~~~~~
for (int i = OpenOrders - 1; i >= 0; i--) {
~~~~~13~~~~~~~~~
OrderSelect(i, SELECT_BY_POS);
if (OrderMagicNumber()==Magicnumber)
{ // do the closing stuff // }
so this for loop will search from 13th to 0th pos, now say, if EA-charvo's pos are number/index from 0~19 (20 pos), then the while-->for loop above will be searching in vain for EA-D&M's pos that are very likely indexed from 20~33.
To correct this problem:
add another internal var:
int allpos = orderstotal();
then in above loop, replace "for (int i = OpenOrders - 1; i >= 0; i--)" with " for (int i = allpos - 1; i >= 0; i--)"
......
never thought a closeall() could be so time-consuming...... my solution is pretty simple, COPY steve hopwood's MPTM's closeall() to this EA.