Today I've faced two more issues I don't understand, but this time they are in the code taken from the MQL5 Reference in its entirety. This time I didn't write anything myself, but just took a ready-made example.
I open MQL5 Reference / Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request. I find it there:
Structure of the trade request
Modify Pending Order
Торговый приказ на модификацию уровней цен отложенного ордера. Требуется указание 7 полей:
action
order
price
sl
tp
type_time
expiration
Пример торговой операции TRADE_ACTION_MODIFY для модификации уровней цен отложенного ордера:
This is clear. I am followed by an example with the following code:
#define EXPERT_MAGIC 123456// MagicNumber эксперта//+------------------------------------------------------------------+//| Модификация отложенных ордеров |//+------------------------------------------------------------------+voidOnStart()
{
//-- объявление и инициализация запроса и результатаMqlTradeRequest request={};
MqlTradeResult result={};
int total=OrdersTotal(); // количество установленных отложенных ордеров//--- перебор всех установленных отложенных ордеровfor(int i=0; i<total; i++)
{
//--- параметры ордераulong order_ticket=OrderGetTicket(i); // тикет ордераstring order_symbol=Symbol(); // символint digits=(int)SymbolInfoInteger(order_symbol,SYMBOL_DIGITS); // количество знаков после запятойulong magic=OrderGetInteger(ORDER_MAGIC); // MagicNumber ордераdouble volume=OrderGetDouble(ORDER_VOLUME_CURRENT); // текущий объем ордераdouble sl=OrderGetDouble(ORDER_SL); // текущий Stop Loss ордераdouble tp=OrderGetDouble(ORDER_TP); // текущий Take Profit ордераENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); // тип ордераint offset = 50; // отступ от текущей цены для установки ордера, в пунктахdouble price; // цена срабатывания ордераdouble point=SymbolInfoDouble(order_symbol,SYMBOL_POINT); // размер пункта//--- вывод информации об ордереPrintFormat("#%I64u %s %s %.2f %s sl: %s tp: %s [%I64d]",
order_ticket,
order_symbol,
EnumToString(type),
volume,
DoubleToString(PositionGetDouble(POSITION_PRICE_OPEN),digits),DoubleToString(sl,digits),
DoubleToString(tp,digits),
magic);
//--- если MagicNumber совпадает, Stop Loss и Take Profit не заданыif(magic==EXPERT_MAGIC && sl==0 && tp==0)
{
request.action=TRADE_ACTION_MODIFY; // тип торговой операции
request.order = OrderGetTicket(i); // тикет ордера
request.symbol =Symbol(); // символ
request.deviation=5; // допустимое отклонение от цены//--- установка уровня цены, тейк-профит и стоп-лосс ордера в зависимости от его типаif(type==ORDER_TYPE_BUY_LIMIT)
{
price = SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point;
request.tp = NormalizeDouble(price+offset*point,digits);
request.sl = NormalizeDouble(price-offset*point,digits);
request.price =NormalizeDouble(price,digits); // нормализованная цена открытия
}
elseif(type==ORDER_TYPE_SELL_LIMIT)
{
price = SymbolInfoDouble(Symbol(),SYMBOL_BID)+offset*point;
request.tp = NormalizeDouble(price-offset*point,digits);
request.sl = NormalizeDouble(price+offset*point,digits);
request.price =NormalizeDouble(price,digits); // нормализованная цена открытия
}
elseif(type==ORDER_TYPE_BUY_STOP)
{
price = SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point;
request.tp = NormalizeDouble(price+offset*point,digits);
request.sl = NormalizeDouble(price-offset*point,digits);
request.price =NormalizeDouble(price,digits); // нормализованная цена открытия
}
elseif(type==ORDER_TYPE_SELL_STOP)
{
price = SymbolInfoDouble(Symbol(),SYMBOL_BID)-offset*point;
request.tp = NormalizeDouble(price-offset*point,digits);
request.sl = NormalizeDouble(price+offset*point,digits);
request.price =NormalizeDouble(price,digits); // нормализованная цена открытия
}
//--- отправка запросаif(!OrderSend(request,result))
PrintFormat("OrderSend error %d",GetLastError()); // если отправить запрос не удалось, вывести код ошибки//--- информация об операции PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
//--- обнуление значений запроса и результатаZeroMemory(request);
ZeroMemory(result);
}
}
}
//+------------------------------------------------------------------+
I'm trying to understand the line highlighted in yellow. A question arises right away: what doesPositionGetDouble(POSITION_PRICE_OPEN) have to do with itif this example is related to pending orders? Maybe, there should be a line like this:
This is the first point. The second issue comes up when I try to run this script on a chart with a BUY_STOP pending order I have set (though everything similar happens to other types of pending orders). So, what happens? Nothing happens! I do not see any modification of a pending order. Maybe, I do not understand something?
There is no price on forex Last.
The solution is as follows.It must be such a thrashing ))
Configure all the chart display properties as you like, and save it in the template as default.tpl
How do you do this?
I don't understand why this last price line was added, in a practical sense it's useless.
how do I do it?
PCM on graphic -> Templates -> Save template
File name: default.tpl
Forum on trading, automated trading systems & strategy testing
Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes
MrBrooklin, 2022.02.25 07:15
Good Morning, Dear Experts!
Today I've faced two more issues I don't understand, but this time they are in the code taken from the MQL5 Reference in its entirety. This time I didn't write anything myself, but just took a ready-made example.
I open MQL5 Reference / Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request. I find it there:
Structure of the trade requestThis is clear. I am followed by an example with the following code:
I'm trying to understand the line highlighted in yellow. A question arises right away: what does PositionGetDouble(POSITION_PRICE_OPEN) have to do with itif this example is related to pending orders? Maybe, there should be a line like this:
I only find this in the Experts tab: Dear Experts, please help me to understand this example, why it is in the directory, but its code does not work?
Regards, Vladimir.
Hello. Can you tell me how to withdraw the deposit to the card?
This is the website of the developer of the trading platform. It is not a broker, it is not a DC, there are no real trading accounts.
It clearly says so at the bottom of the page:
Please ask such questions of your broker - who did you transfer money to your trading account.
Good afternoon. Can you tell me how to withdraw the deposit to the card?
Dear developers! Why in the second and third calls is (T* const Ptr) overloaded instead of (T* & Ptr)?
Is this a bug or a feature? b3213.
PCM on graphic -> Templates -> Save template
File name: default.tpl
There is such a template by default. I replaced it. Didn't help, alas. It's still the same when switching to or from it.
Do you know how to write to the developers? Surely it has already been reported to them a few hundred times, well, I'll write again.
When scrolling, the header in the signals rides