Good afternoon, I need help in placing a limited buy order for bars. Ie if you take the timeframe D1, then you need to place a buy order above the high of yesterday.
I attach the code. How to describe this procedure correctly ?
void OnStart()
{
double open1 = iOpen(Symbol(),Period(),1);
double close1 = iClose(Symbol(),Period(),1);
double high1 = iHigh(Symbol(),Period(),1);
double low1 = iLow(Symbol(),Period(),1);
// Create a request
MqlTradeRequest request = {0};
request.action = TRADE_ACTION_PENDING;
request.symbol = Symbol();
request.volume = 0.1;
request.price = SymbolInfoDouble(request.symbol,SYMBOL_ASK)-1000*_Point;
request.sl = request.price-500*_Point;
request.tp = request.price+100*_Point;
request.type = ORDER_TYPE_BUY_LIMIT;
request.type_filling = ORDER_FILLING_FOK;
request.expiration = ORDER_TIME_DAY;
MqlTradeResult result = {0};
if (OrderSend (request,result))
Print ("Order sent successfully, no errors=", GetLastError());
else
Print ("Failed to send request, error =", GetLastError());
}
prostotrader
Pending order on MQL5
Is there an order that will not work immediately, but will be located in the glass?
setborg
Can you at least write an example ?
alexeyvik
Instead of Period (), put PERIOD_D1 and specify the resulting value as the price.