#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);
}
//+------------------------------------------------------------------+
#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);
}
//+------------------------------------------------------------------+
enum_trade_request_actions
识别器
描述
交易_行动_交易
以指定的参数下达立即执行的交易指令(市价单)。
正在进行的贸易行动
在指定的条件下下达交易指令,以便执行(挂单)。
TRADE_ACTION_PENDING交易操作的例子,用于下一个挂单。
enum_trade_request_actions
识别器
描述
交易_行动_交易
以指定的参数下达立即执行的交易指令(市价单)。
正在进行的贸易行动
在指定的条件下下达交易指令,以便执行(挂单)。
谢谢你!
TRADE_ACTION_PENDING交易操作的例子,用于下一个挂单。
弗拉基米尔,你不能用俄语写吗?
你不能。因为我完整地引用了参考文献中的内容。否则,这是个漫长的过程:每个人都有一张 "票",有些人有 "票"。这就是为什么功能、帮助和帮助中的引语都是英文的原因。
你不能。因为我完整地引用了参考资料。否则,这是个漫长的过程:每个人都有一张 "票",有些人有 "票"。这就是为什么功能、参考文献和参考文献中的引文都是英文的原因。
大家好!我认为这个问题主要是针对专业人士的(事实证明)。已经过了一个星期,有一个关于代码的问题。
例如 - 我们知道M5蜡烛包含5个蜡烛M1(例如,00:00,00:01,00:02,00:03和00:04)。此外,我们将只考虑这种结合--即我们在M1上运行指标并希望看到M5的指标读数。
也就是说,为了正确地在下层TF上显示中间的数据,我应该在下层TF的所有5个柱子出现时进行循环。这意味着周期应该是从0到4 - 这是最大的,而历史上的空隙不被考虑。问题是,我得到了从0到5的循环,而我没有足够的逻辑来使它达到4!相信我,我已经为这个问题纠结了一个星期,我真的请求你的帮助。下面是一个非常截断的代码,其中循环到5而不是4。我希望它4!!!!!
如何添加一个列表视图编辑窗口?
https://www.mql5.com/en/docs/standardlibrary/controls/clistview
我有上面的图书馆。我想在这个列表中添加一个带标签的编辑框。 你能告诉我如何才能做到这一点吗?我试过了,但没有用。
而他们有 "门票",只是因为他们开始用谷歌进行翻译 :)
好吧,我承认:抓住了我。 回答得很快,没有切换帮助语言 😎
收到;)