Mitch Zanting: I use the Orderstotal() at the moment but then i cant open more trades from different symbols.
-
Why did you post your MT4 question in the
Root /
MT5 EA section
instead of the
MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. -
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum -
Using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR
where spread is over 500 points,) and metals. Compute what a PIP is and use it,
not points.
How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum
Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum
Mitch Zanting:
Hello everyone,
I'm looking for a check function, So the EA checks if a trade of the symbol is already open and if its open already then dont open a second one.
I use the Orderstotal() at the moment but then i cant open more trades from different symbols.
Here is a small piece of what im talking about.
Im looking for a replacement for the OrderTotal function.
So it doesnt check the whole Tradelist but only for the Symbol it active on.
Hope you all understand what im saying and i really appreciate if you want to help.
Regards,
As one of ways:
extern int EAMagic = 777888; //EA's magic number parameter int CountSymbolPositions=0; for(int trade=OrdersTotal()-1;trade>=0;trade--) { if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()==Symbol()) { if((OrderType()==OP_SELL||OrderType()==OP_BUY) && OrderMagicNumber()==EAMagic) CountSymbolPositions++; } } //And then - your code, for example if(RSIValue<23 && CountSymbolPositions<1){ int buyticket = OrderSend ( Symbol(), OP_BUY, LotSize, Ask, 2, Ask- 250*_Point, Ask+1200*_Point, NULL, 0, 0, Green ); }
Alternatively...
bool trades_on_symbol(string symbol) { for(int i=OrdersTotal()-1;OrderSelect(i,SELECT_BY_POS);i--) if(OrderSymbol()==symbol && OrderType()<2) return true; return false; }
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
Hello everyone,
I'm looking for a check function, So the EA checks if a trade of the symbol is already open and if its open already then dont open a second one.
I use the Orderstotal() at the moment but then i cant open more trades from different symbols.
Here is a small piece of what im talking about.
Im looking for a replacement for the OrderTotal function.
So it doesnt check the whole Tradelist but only for the Symbol it active on.
Hope you all understand what im saying and i really appreciate if you want to help.
Regards,