Place a trade order for the execution under specified conditions (pending order)
Example of the TRADE_ACTION_PENDING trade operation for placing a pending order:
#property description"Example of placing pending orders"#property script_show_inputs#define EXPERT_MAGIC 123456// MagicNumber of the expertinputENUM_ORDER_TYPE orderType=ORDER_TYPE_BUY_LIMIT; // order type//+------------------------------------------------------------------+//| Placing pending orders |//+------------------------------------------------------------------+voidOnStart()
{
//--- declare and initialize the trade request and result of trade requestMqlTradeRequest request={0};
MqlTradeResult result={0};
//--- parameters to place a pending order
request.action =TRADE_ACTION_PENDING; // type of trade operation
request.symbol =Symbol(); // symbol
request.volume =0.1; // volume of 0.1 lot
request.deviation=2; // allowed deviation from the price
request.magic =EXPERT_MAGIC; // MagicNumber of the orderint offset = 50; // offset from the current price to place the order, in pointsdouble price; // order triggering pricedouble point=SymbolInfoDouble(_Symbol,SYMBOL_POINT); // value of pointint digits=SymbolInfoInteger(_Symbol,SYMBOL_DIGITS); // number of decimal places (precision)//--- checking the type of operationif(orderType==ORDER_TYPE_BUY_LIMIT)
{
request.type =ORDER_TYPE_BUY_LIMIT; // order type
price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point; // price for opening
request.price =NormalizeDouble(price,digits); // normalized opening price
}
elseif(orderType==ORDER_TYPE_SELL_LIMIT)
{
request.type =ORDER_TYPE_SELL_LIMIT; // order type
price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point; // price for opening
request.price =NormalizeDouble(price,digits); // normalized opening price
}
elseif(orderType==ORDER_TYPE_BUY_STOP)
{
request.type =ORDER_TYPE_BUY_STOP; // order type
price =SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point; // price for opening
request.price=NormalizeDouble(price,digits); // normalized opening price
}
elseif(orderType==ORDER_TYPE_SELL_STOP)
{
request.type =ORDER_TYPE_SELL_STOP; // order type
price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point; // price for opening
request.price =NormalizeDouble(price,digits); // normalized opening price
}
elseAlert("This example is only for placing pending orders"); // if not pending order is selected//--- send the requestif(!OrderSend(request,result))
PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code//--- information about the operationPrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
}
//+------------------------------------------------------------------+
Artyom Trishkin: Vladimir, can't you write it in Russian?
You can't. Because I quoted the full reference. Otherwise, it's a long shot: everyone has a 'ticket' and some have 'tickets'. That's why the functions, help and quotes from the help are in English.
You can't. Because I quoted in full from the reference. Otherwise, it's a long shot: everyone has a "ticket" and some have "tickets". Therefore, the functions, the reference and the quotes in the reference are in English.
And they have "tickets" just because they start translating with google :)
In the Russian official help, there are "tickets".
Hello all! I think the question is primarily for the pros (as it turns out). It has been a week with one question about the code.
For example - we know that the M5 candle contains 5 candles M1 (for example, 00:00, 00:01, 00:02, 00:03 and 00:04). Further we will consider only this conjunction - i.e. we run the indicator on M1 and want to see the indicator readings from M5.
I.e. to correctly display data of the middle TF on the lower one, I should loop through all 5 bars of the lower TF as they appear. I.e. the first bar appears 00:00, then 00:01 etc. up to 00:04 and after that the next one appears. It means the cycle should be from 0 to 4 - this is the maximum, while gaps in history are not considered. The problem is that I get the cycle from 0 to 5, and I do not have enough logic to make it up to 4! Believe me, I've been struggling with this for a week now and I'm really asking for your help. Below is a very truncated code where the loop goes to 5 instead of 4. I want it to 4!!!!!
#property copyright""#property link""#property version""#property indicator_chart_window//+----------------------------------------------+//| Входные параметры индикатора |//+----------------------------------------------+inputENUM_TIMEFRAMES TF=PERIOD_M5;
int LastCountBar;
datetime tt;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total, // количество истории в барах на текущем тикеconstint prev_calculated,// количество истории в барах на предыдущем тикеconstdatetime &time[],
constdouble &open[],
constdouble& high[], // ценовой массив максимумов цены для расчёта индикатораconstdouble& low[], // ценовой массив минимумов цены для расчёта индикатораconstdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
datetime IndTime[1];
//--- объявления локальных переменныхint limit,bar;
//--- индексация элементов в массивах как в таймсерияхArraySetAsSeries(time,true);
//--- расчёт стартового номера first для цикла пересчёта баровif(prev_calculated>rates_total || prev_calculated<=0) // проверка на первый старт расчёта индикатора
{
limit=100; // стартовый номер для расчёта всех баров
LastCountBar=limit;
}
else
limit=LastCountBar+rates_total-prev_calculated; // стартовый номер для расчёта новых баров//--- основной цикл расчёта индикатораfor(bar=limit; bar>=0; bar--)
{
//--- копируем вновь появившиеся данные в массив IndTimeif(CopyTime(Symbol(),TF,time[bar],1,IndTime)<=0)
return(0);
if(time[bar]>=IndTime[0] && time[bar+1]<IndTime[0])
{
LastCountBar=bar;
//--- Далее проводим вычисления индикатора МТФ ...............Print(bar," ",IndTime[0]);
//---
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
The question is this. Can I open 2 (or more) charts at the touch of a button so that they are positioned vertically, equally occupying the entire monitor?
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.
ENUM_TRADE_REQUEST_ACTIONS
Identifier
Description
TRADE_ACTION_DEAL
Place a trade order for an immediate execution with the specified parameters (market order)
TRADE_ACTION_PENDING
Place a trade order for the execution under specified conditions (pending order)
Example of the TRADE_ACTION_PENDING trade operation for placing a pending order:
ENUM_TRADE_REQUEST_ACTIONS
Identifier
Description
TRADE_ACTION_DEAL
Place a trade order for an immediate execution with the specified parameters (market order)
TRADE_ACTION_PENDING
Place a trade order for the execution under specified conditions (pending order)
Thank you!
Example of the TRADE_ACTION_PENDING trade operation for placing a pending order:
Vladimir, can't you write it in Russian?
You can't. Because I quoted the full reference. Otherwise, it's a long shot: everyone has a 'ticket' and some have 'tickets'. That's why the functions, help and quotes from the help are in English.
You can't. Because I quoted in full from the reference. Otherwise, it's a long shot: everyone has a "ticket" and some have "tickets". Therefore, the functions, the reference and the quotes in the reference are in English.
Hello all! I think the question is primarily for the pros (as it turns out). It has been a week with one question about the code.
For example - we know that the M5 candle contains 5 candles M1 (for example, 00:00, 00:01, 00:02, 00:03 and 00:04). Further we will consider only this conjunction - i.e. we run the indicator on M1 and want to see the indicator readings from M5.
I.e. to correctly display data of the middle TF on the lower one, I should loop through all 5 bars of the lower TF as they appear. I.e. the first bar appears 00:00, then 00:01 etc. up to 00:04 and after that the next one appears. It means the cycle should be from 0 to 4 - this is the maximum, while gaps in history are not considered. The problem is that I get the cycle from 0 to 5, and I do not have enough logic to make it up to 4! Believe me, I've been struggling with this for a week now and I'm really asking for your help. Below is a very truncated code where the loop goes to 5 instead of 4. I want it to 4!!!!!
How do I add a list view editing window?
https://www.mql5.com/en/docs/standardlibrary/controls/clistview
I have the library above. I want to add an edit box with a label inside this list. Can you tell me how I can do this? I've tried, but it doesn't work.
And they have "tickets" just because they start translating with google :)
OK, I confess: caught me. Answered quickly and didn't switch the help language 😎
Copy that ;)