Hi all,
I've this issue occurring during the time that orders take to get closed;
Say that I have 6 orders open and then the conditions to close all are in place, because the orders do not close at same time how can one avoid to get an opening to happen before all those 6 orders get closed ?
Following is the code to close all.
Thanks in advance for any help provided.
Luis
Hi RaptorUK,
Thank you for your prompt attention to my issue.
What is happening at least during last night, was that nevertheless the setting to close by 7th order the EA have opened more 1 and can't see why.
Following is the code that regulates the maximum number of orders;
extern int MaxOrders = 7;
OTLastTick = OTCurrentTick; OTCurrentTick = OrdersTotal(); if(OTCurrentTick == 0 && OTLastTick > 0) { BuyTrigger = Ask + OpenDistance * pips2dbl; SellTrigger = Bid - OpenDistance * pips2dbl; } if(OTCurrentTick > 0 )Trail(); if(OTLastTick >= 2 && OTCurrentTick < OTLastTick && OTCurrentTick > 0) { CloseAllOnSL();return; } if(OTCurrentTick > 0)OpenOppositeOrder(); if(OTCurrentTick >= MaxOrders)CloseAll();//<------------------------------------------------ Close all at Maximum orders defined at external. if(Hour() >= CloseMarketOnFriday && DayOfWeek() == 5)CloseAll(); if(OTCurrentTick == 0) { BuyAllowed = true; SellAllowed = true;
Any help here ?
Best regards
Luis
What is happening at least during last night, was that nevertheless the setting to close by 7th order the EA have opened more 1 and can't see why.
OTCurrentTick = OrdersTotal(); : if(OTCurrentTick >= MaxOrders)CloseAll();//<- Close all at Max if(OTCurrentTick == 0){ BuyAllowed = true; SellAllowed = true;
- Once you've reached maxOrders you close all trades.
- On the NEXT tick, OrdersTotal == 0 so you set Buy/SellAllowed and open more.
Hi RaptorUK,
Thank you for your prompt attention to my issue.
What is happening at least during last night, was that nevertheless the setting to close by 7th order the EA have opened more 1 and can't see why.
Following is the code that regulates the maximum number of orders;
It's hard to say for sure without seeing all the code, you really need to check what can open a new order and find how this can happen when you already have 7 open orders, for example . . .
if(OTCurrentTick > 0)OpenOppositeOrder(); // <-- will OpenOppositeOrder() open a new order if there are already 7 open ? if(OTCurrentTick >= MaxOrders)CloseAll();//<------------------------------------------------ Close all at Maximum orders defined at external.
if OpenOppositeOrder() will open a new order even if there are already 7 orders open then you will have 8 open orders.
It's hard to say for sure without seeing all the code, you really need to check what can open a new order and find how this can happen when you already have 7 open orders, for example . . .
if OpenOppositeOrder() will open a new order even if there are already 7 orders open then you will have 8 open orders.
Hi RaptorUK;
Thank you and to WHRoeder as well.
Your clue on OpenOppositeOrder() seems to be the guilty, so I've include this code and will see from there.
if(OTCurrentTick > 0 && OTCurrentTick < MaxOrders) OpenOppositeOrder();
Thank you once more for your support.
Luis

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I've this issue occurring during the time that orders take to get closed;
Say that I have 6 orders open and then the conditions to close all are in place, because the orders do not close at same time how can one avoid to get an opening to happen before all those 6 orders get closed ?
Following is the code to close all.
Thanks in advance for any help provided.
Luis