Whoa. What does this have to do with warrants? We have been talking about a position all along. A position and pending orders are different things. They must be closed differently!
Pending orders are not closed but deleted. Positions are closed by opening a market order of equal volume and opposite direction to the open position.
The code you cited was not designed to delete pending orders.
You can use this function to delete orders:
Got it. Nothing about orders - just positions.
I prescribed PositionSelect at night - it seems to have caught my breath. It sends (closes) positions every once in a while, but I think conditions are already involved here.
I do not understand something else. It does not form stop and profit losses, the values of which are prescribed in the input parameters. If I prescribe these values in the sending, the same thing happens - i.e. nothing.
inputint StopLoss=60; // Stop Lossinputint TakeProfit=170; // Take ProfitintOnInit()
...
STP = StopLoss;
TKP = TakeProfit;
if(_Digits==5 || _Digits==3)
{
STP = STP*10;
TKP = TKP*10;
}
return(0);
}
...
mrequest.action = TRADE_ACTION_DEAL; // немедленное исполнение
mrequest.price = NormalizeDouble(Ask,_Digits); // последняя цена ask
mrequest.sl = StopLoss; // Stop Loss
mrequest.tp = TakeProfit; // Take Profit
mrequest.symbol = _Symbol; // символ
mrequest.volume = Lot; // количество лотов для торговли
mrequest.magic = EA_Magic; // Magic Number
mrequest.type = ORDER_TYPE_BUY; // ордер на покупку
mrequest.type_filling = ORDER_FILLING_FOK; // тип исполнения ордера - все или ничего
mrequest.deviation=10; // проскальзывание от текущей цены//--- отсылаем ордерOrderSend(mrequest,mresult);
// анализируем код возврата торгового сервераif(mresult.retcode==10009 || mresult.retcode==10008) //запрос выполнен или ордер успешно помещен
{
Alert("Ордер Buy успешно помещен, тикет ордера #:",mresult.order,"!!");
}
else
{
Alert("Запрос на установку ордера Buy не выполнен - код ошибки:",GetLastError());
return;
Hello. Can you please tell me what I should do in MT4 after I subscribe to the signals, so that the synchronization could take place? I found in the instructions what to do with MT5, I have not found instructions for MT4. I have subscribed to the signal from MT4.
I have signed up for the signal from MT4. Thank you.
Understood. No mention of orders - just positions.
I prescribed PositionSelect at night - it seems to have caught my breath. It sends (closes) positions every once in a while, but I think conditions are already involved here.
I do not understand something else. It does not form Stop and Profit Loss, values of which are prescribed in the input parameters. If I prescribe these values in the sending, the same thing happens - i.e. nothing.
Stops and Profits are not specified correctly.
Здес указали целое число
inputint StopLoss=60; // Stop Lossinputint TakeProfit=170; // Take Profit
...
STP = StopLoss;
TKP = TakeProfit;
if(_Digits==5 || _Digits==3)
{
STP = STP*10;
TKP = TKP*10;
}
return(0);
}
...
mrequest.action = TRADE_ACTION_DEAL; // немедленное исполнение
mrequest.price = NormalizeDouble(Ask,_Digits); // последняя цена ask
mrequest.sl = NormalizeDouble(Ask - StopLoss*_Points,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble(Ask + TakeProfit*_Points,_Digits); // Take Profit
На места для стоп и профит нужна цена!
The reason why stops are not set when a position is opened may depend on the trading mode. There are three modes: Request Execution, Instant Execution and Market Execution.
If your broker uses the Market Execution mode, you need to open a position first and then modify (set stops) it on the next tick. At the same time, i.e. in one order, with this trading mode it is not possible to open a position with stops.
Indeed, there's Market Execution in Alpari . Is there an order modification structure itself? As there is no modification in the forum as long as there is an open sell or buy order.
If I'm not mistaken, the "fish" of modification looks like this.
if(PositionSelect(_Symbol)==true) // есть открытая позиция
{
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
{ ModifyPosition(стоплосс на покупку)
}
else if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
{
{ ModifyPosition(стоплосс на продажу)
}
return
Lester: Indeed, in Alpari Market Execution . Is there an order modification structure itself? As there is no modification in the forum as long as there is an open Sell or Buy order.
If I'm not mistaken, the 'fish' of the modification looks like this.
Use the ready solution from the standard library(CTrade class- PositionModify method). It is a good solution for a beginning. At any moment you can make your own similar class and make the necessary changes.
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.
Lester:
This is a template with built-in functions for opening, closing and modifying.
The opening and closing are written by Nikolay Kositsin.
I easily changed them and added modifications.
I think it's clear how to call them up, so for your convenience.
Sorry about that - mixed upthe file.
Try it this way:
Lester:
This template has built-in functions for opening, closing and modifying.
The opening and closing are written by Nikolay Kositsin.
I easily changed them and added modifications.
I think it's clear how to challenge them, so for your convenience.
How do you open such files with an editor?
You can't open those. ))
Try reading some articles. There's a lot to choose from, from the smallest to the most mature. ))
Unfortunately, the orders do not close at all. I think I should think about it for a while)
Changed the file, sorry about that.
I got the file mixed up, sorry.
Whoa. What does this have to do with warrants? We have been talking about a position all along. A position and pending orders are different things. They must be closed differently!
Pending orders are not closed but deleted. Positions are closed by opening a market order of equal volume and opposite direction to the open position.
The code you cited was not designed to delete pending orders.
You can use this function to delete orders:
Got it. Nothing about orders - just positions.
I prescribed PositionSelect at night - it seems to have caught my breath. It sends (closes) positions every once in a while, but I think conditions are already involved here.
I do not understand something else. It does not form stop and profit losses, the values of which are prescribed in the input parameters. If I prescribe these values in the sending, the same thing happens - i.e. nothing.
Hello. Can you please tell me what I should do in MT4 after I subscribe to the signals, so that the synchronization could take place? I found in the instructions what to do with MT5, I have not found instructions for MT4. I have subscribed to the signal from MT4.
I have signed up for the signal from MT4. Thank you.
Understood. No mention of orders - just positions.
I prescribed PositionSelect at night - it seems to have caught my breath. It sends (closes) positions every once in a while, but I think conditions are already involved here.
I do not understand something else. It does not form Stop and Profit Loss, values of which are prescribed in the input parameters. If I prescribe these values in the sending, the same thing happens - i.e. nothing.
The reason why stops are not set when a position is opened may depend on the trading mode. There are three modes: Request Execution, Instant Execution and Market Execution.
If your broker uses the Market Execution mode, you need to open a position first and then modify (set stops) it on the next tick. At the same time, i.e. in one order, with this trading mode it is not possible to open a position with stops.
In general, deal with the structure of a trade request:MQL5 Reference / Standard constants, enumerations and structures / Data structures / Structure of a trade request. I think this will help you in further study of the language.
If I'm not mistaken, the "fish" of modification looks like this.
Indeed, in Alpari Market Execution . Is there an order modification structure itself? As there is no modification in the forum as long as there is an open Sell or Buy order.
If I'm not mistaken, the 'fish' of the modification looks like this.