Probably you wanted to write this:
for (i=0;i<OrdersTotal();i++) { if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false ) continue; ..
You were right! Thanks But after opening different orders for different currencies, it opened too many orders on the same currency, How can i fix it?
Stan4o1:
You were right! Thanks But after opening different orders for different currencies, it opened too many orders on the same currency, How can i fix it?
If it was only a temporary mistake in your code close'em by hand?
It is not temporary, as soon as i attach the EA to a second chart it starts opening many many orders, i dont know whats wrong i even added Refreshates but it wouldn`t help.If someone could help me i would be very gratefull
int AreThereOrders () { if (OrdersTotal()<1) {return 1;} else { int i; for (i=0;i<OrdersTotal();i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderMagicNumber() != magic) {return 2;} break; } return 0; } RefreshRates(); } And then i use if (AreThereOrders() == 1 || AreThereOrders() ==2) { and there follows the buy or sell condition
You probably wanted to write:
if(OrderMagicNumber() == magic) return 0; // no further order
...
//and at the end
return 2; // no matching open order found
Im sorry i tried it but it still doesnt work - The EA opens many orders
int AreThereOrders () { if (OrdersTotal()<1) {return 1;} else { int i; for (i=0; i<OrdersTotal() ; i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && ( OrderMagicNumber()== magic)) return 0; break; } } return 2 ; } This is what you meant right?
Thanks
int AreThereOrders () { if (OrdersTotal()<1) { return 1; } else if (OrdersTotal()>0) { int i; for (i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if( OrderMagicNumber()!= magic && OrderSymbol()!=Symbol()) { return 2; } } } return 0 ; }This is what i made but ,i dont know why, it still keeps opening too many orders, not like i wanted just 1 per currency/magic number. I dont` know what to do .
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
Hi, I made some changes to one of my EAs it is about searching for already opened orders by their magic nbr. I have set different magic nbr for the ea, when i attached it to different currencies, but still order opened stops the other EAs from trading with different currencies. Can you help me ? This is the function i created, and in the ontick function i have set an if (Arethereorders() == 1 || AreThereOrders() == 2) then it checks for buy/sell signals
)