Noticed this section in the mGRID code that looks like it's written to remove all orders:
{
int cpt, total = OrdersTotal();
for(cpt=0;cpt<total;cpt++)
{
OrderSelect(cpt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() > 1)
{
OrderDelete(OrderTicket());
}
else if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
}
else if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}}
if (!ContinueTrading)
{
Enter = false;
}
return(true);
}
Anyone see why it might not work? Running it on an ECN broker, if it matters.
Cheers
Noticed this section in the mGRID code that looks like it's written to remove all orders:
Anyone see why it might not work? Running it on an ECN broker, if it matters.
CheersTry replacing that function with this one :
{
for(int cpt=OrdersTotal()-1; cpt>=0; cpt--)
{
OrderSelect(cpt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() != Symbol()) continue;
if (OrderType() > 1) { OrderDelete(OrderTicket()); continue; }
if (OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red); continue; }
if (OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red); continue; }
}
if (!ContinueTrading)
{
Enter = false;
}
return(true);
}
The way it is written in the original now it can not delete or close multiple orders (the above function should solve that)
I've tried it a few times and it still doesn't seem to be removing orders after TP/SL. Thank you anyway!
If it is called it will close all orders (unlike the original function in the EA)
I did not check the rest of the EA logic. Check the EA logic since that function WILL close all the orders if it is called
If it is called it will close all orders (unlike the original function in the EA) I did not check the rest of the EA logic. Check the EA logic since that function WILL close all the orders if it is called
I see. My knowledge of MQ4 is extremely bad (will make an effort at learning it properly this summer after exams). I am well aware that this isn't supposed to be a learning centre, but could you perhaps remove the "ContinueTrading needs to be true" requirement if it is there the problem lies with the logic?
Do you mean changes from mGRID to mGRID 7.0? Only visual changes, as far as I know (shows number of open positions/orders on the left hand side). Should I attempt to add your code to the original one instead?
Do you mean changes from mGRID to mGRID 7.0? Only visual changes, as far as I know (shows number of open positions/orders on the left hand side). Should I attempt to add your code to the original one instead?
You should replace that code in any case
Here is why :
Imagine that you have 3 orders. The old code starts checking orders from first to last. For the sake of explanation lets say that those are orders 1,2 and 3. At the beginning it checks the first order in the list (order 1) and deletes it and now it has orders 2 and 3 in the remaining list (remember that order 1 is deleted or closed and it is not a part of a list of opened orders any more). And it continues from second order in the list which would be order 3 (not 2) since the order 3 is the second order in the remaining list, And that way the order 2 will remain opened after the whole thing. That is the logical error in that function that will make it omit some orders when it has to close or delete all orders
Replace the code of that function and at least you will not have to think about that part
You should replace that code in any case
Here is why :
Imagine that you have 3 orders. The old code starts checking orders from first to last. For the sake of explanation lets say that those are orders 1,2 and 3. At the beginning it checks the first order in the list (order 1) and deletes it and now it has orders 2 and 3 in the remaining list (remember that order 1 is deleted or closed and it is not a part of a list of opened orders any more). And it continues from second order in the list which would be order 3 (not 2) since the order 3 is the second order in the remaining list, And that way the order 2 will remain opened after the whole thing. That is the logical error in that function that will make it omit some orders when it has to close or delete all orders
Replace the code of that function and at least you will not have to think about that partSorry that I haven't been able to reply for a few days - been travelling. Thanks for the help, I understand what you mean and at least that problem is fixed now. The order never seems to get executed though, probably because of a logic fault in the EA as you said. If you have any time to spare me and my friend would greatly appreciate it if you could take a quick look at the rest of the EA and see if you can find an obvious mistake. Meanwhile I am learning as quickly as possible!
Many thanks.
Hello all,
I'm sure some of you will have heard of the mGRID trading system (coded by FOREXFlash): 100% Win Math Grid Ea @ Forex Factory. To those of you that haven't, mGRID is a grid EA that also doubled positions to always ensure profit as long as there is enough equity on the account (martingale).
I believe that this EA can be used to hedge against trending markets when combined with other EAs, but the problem is that it doesn't close all buy/sell orders after reaching TP/SL and therefore it doesn't continue trading. Notice that if you manually close the standing orders, the EA will automatically open new ones and continue trading.
If someone were to combine the two attached EAs, or find another way to solve this problem, I think this trading system can be profitable to all of us.
Thanks,
Axel
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all,
I'm sure some of you will have heard of the mGRID trading system (coded by FOREXFlash): 100% Win Math Grid Ea @ Forex Factory. To those of you that haven't, mGRID is a grid EA that also doubled positions to always ensure profit as long as there is enough equity on the account (martingale).
I believe that this EA can be used to hedge against trending markets when combined with other EAs, but the problem is that it doesn't close all buy/sell orders after reaching TP/SL and therefore it doesn't continue trading. Notice that if you manually close the standing orders, the EA will automatically open new ones and continue trading.
If someone were to combine the two attached EAs, or find another way to solve this problem, I think this trading system can be profitable to all of us.
Thanks,
Axel