I cannot see an OrderSelect() call? However, it is clear that your EA will only handle one position at the same time, as your if-condition is based on number of open orders.
You probably wouldn't even need different magic numbers, as you can filter your OrderSelect() loop by symbol. Feel free to ask further questions, if this doesn't really help yet.
I cannot see an OrderSelect() call? However, it is clear that your EA will only handle one position at the same time, as your if-condition is based on number of open orders.
You probably wouldn't even need different magic numbers, as you can filter your OrderSelect() loop by symbol. Feel free to ask further questions, if this doesn't really help yet.
Thanks. i still need help. i further enhanced my code by add a global function as a filter please would this work?
int totaltrades()
{
int total=0;
for(int i=0; i<OrdersTotal(); i++)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
Alert("error modifying order ",GetLastError());
if(MagicNumber ==OrderMagicNumber())
total++;
}
return(total);
}
if(totaltrades()==0)
-
Play videoPlease edit your post.
For large amounts of code, attach it.
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) Alert("error modifying order ",GetLastError()); if(MagicNumber ==OrderMagicNumber()) total++;This give you the total open/pending orders for the MN. It is incompatible with the EA running on other charts. Filter by pair. If the EA could be placed on the same pair but different timeframes, you must use a range of magic numbers.
I use magic numbers, i guess i would have to assign each instance of a running EA a unique magic number by editing the properties.
You cannot use OrdersTotal() because that looks at orders across all pairs. Use something like this to filter specifically to Symbol().
int OpenOrdersThisPair(string pair) { int total=0; for(int b=OrdersTotal()-1; b>0; b--) { if(!OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()==pair) total++; //can add more specific criteria if you want to trade across multiple timeframes on same pair by using magicnumbers. } return(total); }
You cannot use OrdersTotal() because that looks at orders across all pairs. Use something like this to filter specifically to Symbol().
int totaltrades() { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) Alert("error Selecting order ",GetLastError()); if(MagicNumber ==OrderMagicNumber()) total++; } return(total); } if(totaltrades()==0) {
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I use magic numbers, i guess i would have to assign each instance of a running EA a unique magic number by editing the properties.