MQL4 Reference
Trading functions
OrderModify
| bool OrderModify( |
int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE) |
Modification of characteristics for the previously opened position or pending orders.
If the function succeeds, the returned value will be TRUE.
If the function fails, the returned value will be FALSE.
To get the detailed error information, call GetLastError() function.
Notes: Open price and expiration time can be changed only for pending orders.
If unchanged values are passed as the function parameters, the error 1 (ERR_NO_RESULT) will be generated.
Pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified
in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.
Parameters:
| ticket |
- |
Unique number of the order ticket. |
| price |
- |
New open price of the pending order. |
| stoploss |
- |
New StopLoss level. |
| takeprofit |
- |
New TakeProfit level. |
| expiration |
- |
Pending order expiration time. |
| arrow_color |
- |
Arrow color for StopLoss/TakeProfit modifications in the chart. If the parameter is missing or has CLR_NONE value, the arrows will not be shown in the chart. |
Sample:
if(TrailingStop>0)
{
OrderSelect(12345,SELECT_BY_TICKET);
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Blue);
return(0);
}
}
}
|
|
|