[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 365

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
Tell me more about it, do you have the code ready? What extension is it in?
Yes, it's ready! I don't know about the extension, how can I find out?!
Yes, I'm ready! I don't know about the extension!
MQL4 Code Base
Yes, I'm ready! I don't know about the extension!
See all the links in the second post of this page, especially the section
"TERMINAL "
How do I install an EA in MetaTrader 4?
...
Define the concept according to you "... which is closest to the buy and sell price simultaneously..." - how do you mean simultaneous?
replace this penultimate line with return(t); with this
no help,
to choose the order closest to the buy and sell price, maybe it is not quite correct at the same time, but this function chooses either buy or sell, depending on which is closest
Good afternoon!
A question has arisen: the Expert Advisor has been configured to trade on several dozens of currency pairs (in a single pair window). If any of the pairs is not displayed in the Market Watch window, it causes a glitch. How can I programmatically check if these currency pairs are available to trade, or maybe they are just not displayed in the Market Watch?
There will be different errors
did not help,
to select the order closest to the buy and sell price, maybe it is not quite correct at the same time, but this function selects either buy or sell, depending on which is closest
What this function returns with this line at the end
did not work,
to select the closest buy and sell order to the price, maybe it is not quite correct at the same time, but this function selects either buy or sell, depending on which is closest
Try it like this
how to select a position closest to the Buy and Sell price at the same time?
//+----------------------------------------------------------------------------+
//| Возвращает тикет ближайшей к рынку позиции по цене открытия или 0 |
//| Параметры: |
//| sym - наименование инструмента ("" - текущий символ) |
//| op - операция (-1 - любая позиция) |
//| mn - MagicNumber (-1 - любой магик) |
//+----------------------------------------------------------------------------+
int TicketNearPosOnOpen(string sym="", int op=-1, int mn=-1) {
double di=10000, pp;
int i, k=OrdersTotal(), t=0;
if (sym=="") sym=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sym && (op<0 || OrderType()==op)) {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (mn<0 || OrderMagicNumber()==mn) {
if (OrderType()==OP_BUY) pp=MarketInfo(sym, MODE_BID);
if (OrderType()==OP_SELL) pp=MarketInfo(sym, MODE_ASK);
if (di>MathAbs(OrderOpenPrice()-pp)) {
di=MathAbs(OrderOpenPrice()-pp);
t=OrderTicket();
}
}
}
}
}
}
return(t);
}
Or to select two positions (both Buy and Sell), which are close to the current price?
When you tell us what you need, we will help you :)
How do I select the position closest to the buy and sell price at the same time?
DistMarketAndPos - Returns distance in pips between market and nearest position