How can I be sure that the position with the given id has closed?
The obvious solution - when PositionSelectByTicket returns false, but this can probably happen in a situation where the open positions have not had time to be loaded into the terminal when connected to the trading account?
A slightly more complicated solution - PositionSelectByTicket returns false and HistorySelectByPosition returns true. In this case, if the history for this position is loaded, then the list of open positions must be loaded.
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
Wait for the terminal to synchronise. For example, while (HistorySelect).
I'm not an expert in the inner workings of the terminal. But maybe it's gaoanted that when OnInit comes, the table of open positions (and possibly trading history) is already loaded?
cepreu1: This is known. But I want to know how to set the pair in the application ? Is there a function for this ?
Easily.
For example, trade operations. SeeCTrade trade class,Buy method:
bool Buy(
double volume, // объем позиции conststring symbol=NULL, // символ double price=0.0, // цена исполнения double sl=0.0, // цена Stop Loss double tp=0.0, // цена Take Profit conststring comment=""// комментарий
)
I have highlighted the place where you can specify the required symbol.
Or for example receiving data about opening and closing prices... -CopyRates:
intCopyRates(
string symbol_name, // имя символа ENUM_TIMEFRAMES timeframe, // период int start_pos, // откуда начнем int count, // сколько копируем MqlRates rates_array[] // массив, куда будут скопированы данные
);
Yes, okay. But I didn't specify that I want to assign a couple when starting up, but
without opening a position. And Buy does this by opening a position,
andCopyRates giveshistorical data of pair without assigning it.
You are being florid, but I'll try to guess: you need an input parameter with the symbol name? Then here's the code - you specify the desired symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Symbol name
Ask price
Price Bid
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it works with the EURUSD symbol, but the data (prices) comes from USDJPY
You're being a bit florid, but let me guess: you need an input parameter with a symbol name? Then here is the code - you specify the desired symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Symbol name
Ask price
Price Bid
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it works with EURUSD symbol, but the information (prices) comes from US
Vladimir Karputov:
You're being florid, but let me guess: you need an input parameter with the symbol name? Then here's the code - you specify the required symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Symbol name
Ask price
Price Bid
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it turns out that it works with the EURUSD symbol, but receives information (prices) from the USDJPY symbol
Yes, but in this example, the Expert Advisor runs on EURUSD, but the information (prices) is obtained from the USDJPY symbol.
Why complicate things, I mean, if we take this example, then we launch the Expert Advisor on EURUSD ( or any other
needed currency pair) and that's it, we observe this pair, and then, if necessary, we open a position.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Stupidly made a script to copy inside the computer.... Doesn't copy!!!
So where is the error description? What operating system? What build of MetaTrader 5?
Do you have write rights to the folder?
Added: it looks like if there is no directory, it needs to be created first.
When copying to existing directory - no problem. MetaTrader 5 will work without errors.
How can I be sure that the position with the given id has closed?
The obvious solution - when PositionSelectByTicket returns false, but this can probably happen in a situation where the open positions have not had time to be loaded into the terminal when connected to the trading account?
A slightly more complicated solution - PositionSelectByTicket returns false and HistorySelectByPosition returns true. In this case, if the history for this position is loaded, then the list of open positions must be loaded.
Wait for the terminal to synchronise. For example, while(HistorySelect).
Wait for the terminal to synchronise. For example, while (HistorySelect).
I'm not an expert in the inner workings of the terminal. But maybe it's gaoanted that when OnInit comes, the table of open positions (and possibly trading history) is already loaded?
I am not an expert in the inner workings of the terminal.
Also far from an expert. It's just that several options come to mind to try out at once. And what will work will have to be experimented with.
The easiest solution: open a chart of the desired financial instrument in MetaTrader and place the Expert Advisor on it.
This is known. But I want to know how to set the pair in the application ? Is there a function for this ?
Easily.
For example, trade operations. SeeCTrade trade class,Buy method:
I have highlighted the place where you can specify the required symbol.
Or for example receiving data about opening and closing prices... -CopyRates:
Easily.
For example, trade operations. SeeCTrade trade class,Buy method:
I have highlighted the place where you can specify the required symbol.
Or for example receiving data about opening, closing prices ... -CopyRates:
Yes, ok. But I haven't specified that I want to assign a pair at startup, but
without opening position. And Buy does it by opening a position,
andCopyRates giveshistorical data of the pair without assigning it.
Yes, okay. But I didn't specify that I want to assign a couple when starting up, but
without opening a position. And Buy does this by opening a position,
andCopyRates giveshistorical data of pair without assigning it.
You are being florid, but I'll try to guess: you need an input parameter with the symbol name? Then here's the code - you specify the desired symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it works with the EURUSD symbol, but the data (prices) comes from USDJPY
You're being a bit florid, but let me guess: you need an input parameter with a symbol name? Then here is the code - you specify the desired symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it works with EURUSD symbol, but the information (prices) comes from US
You're being florid, but let me guess: you need an input parameter with the symbol name? Then here's the code - you specify the required symbol in the"InpSymbol" parameter. This symbol is checked in OnInit() - if there is no such a symbol, then the Expert Advisor will be unloaded and an error message will appear in the "Experts" tab of the terminal (or in the "Journal" tab of the Strategy Tester).
If a symbol specified in the"InpSymbol" parameter exists, then the following information will be displayed on the chart
Here is how it works: we start it on EURUSD and specify the USDJPY symbol in the settings. So, it turns out that it works with the EURUSD symbol, but receives information (prices) from the USDJPY symbol
Yes, but in this example, the Expert Advisor runs on EURUSD, but the information (prices) is obtained from the USDJPY symbol.
Why complicate things, I mean, if we take this example, then we launch the Expert Advisor on EURUSD ( or any other
needed currency pair) and that's it, we observe this pair, and then, if necessary, we open a position.