Ordersend Error 134 Mql4
Contents |
Return Codes Trade Server Return CodesCompiler WarningsCompilation ErrorsRuntime Errors Trade Server Return Codes GetLastError() - returns error codes. Error codes are defined in stderror.mqh. To
Mql4 Error 130
print the error description you can use the ErrorDescription() function, ordersend error 130 defined in stdlib.mqh. Example: #include
and Regulations (1) Setup (6) Trading Education (8) Ordersend Error 134 - Err_not_enough_money If you are getting the Metatrader 4 error: Ordersend Error 134, it means you do not have enough money in your account to place an order with the given lot size. What should you do? Ordersend error 134 tends to happen a lot when people code expert advisors with a money management style that increases lot sizes such as Martingale. Eventually the lot size gets too big and you do not have enough margin to place the trade. This can also https://docs.mql4.com/constants/errorswarnings/enum_trade_return_codes happen over time if your account balance gets too low or if you select too large of a lot size. The error occurs when you try to place the trade, thus it is an "ordersend error". To prevent this error you can check your account free margin before attempting to place a trade. To do this you will use the function, AccountFreeMarginCheck(): double AccountFreeMarginCheck(string http://thetrademachine.com/blog/2010/01/02/ordersend-error-134-err_not_enough_money/ symbol, int cmd, double volume) Returns available margin that remains after the specified position has been opened at the current price on the current account. If the free margin is insufficient, an error 134 (ERR_NOT_ENOUGH_MONEY) will be generated. Parameters: symbol - Symbol for trading operation. cmd - Operation type. It can be either OP_BUY or OP_SELL. volume - Number of lots. an example would be: if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0){ // there is not enough margin in the account, so do not trade return(); } Another function you can use to find the remaining margin is: double AccountFreeMargin( ) This returns free margin value of the current account. The following example prints out the free margin for your account: Print("Free margin is = ",AccountFreeMargin()); Tags: Metatrader Errors This entry was posted on Saturday, January 2nd, 2010 at 12:33 pm and is filed under Metatrader. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Next Post: Party Like Its 1999 Previous Post: Buying Tops and Selling Bottoms Comments are closed. Copyright © 2009 The Trade Machine
Closing and Deleting Orders Modification of Orders Use the opportunities of MQL5 in MetaTrader 5 Want to study new MQL5? Read MQL5 Reference Download MetaTrader 4 Client Terminal Opening and Placing Orders Trade requests for opening and placing pending orders are formed using http://www.mtprogramming.com/mql4/trading/ordersend.html the function OrderSend(). Function OrderSend() int OrderSend (string symbol, int cmd, double volume, double price, int slippage, double stoploss,double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE) (please note that here and below, we refer to function header, not to an example of how to use function call in a program). Let's consider in more details what this function consists of. OrderSend is the function name. The function returns the ticket number ('ticket' error 1 is the unique number of an order) that is assigned to the order by the trade server, or -1, if the trade request has been rejected by either the server or the client terminal. In order to get information about the reasons for rejection of the trade request, you should use the function GetLastError() (below we will consider some of the most common errors). symbol is the name of the traded security. Each symbol ordersend error 134 corresponds with the value of a string variable. For example, for the currency pair of Euro/US dollar, this value is "EURUSD". If the order is being opened for a foregone symbol, then this parameter can be specified explicitly: "EURUSD", "EURGBP", etc. However, if you are going to use the Expert Advisor in the window of any other symbol, you can use the standard function Symbol(). This function returns a string value that corresponds with the name of the symbol, in the window of which the EA or script is being executed. cmd is the type of operation. The type of operation can be specified as a predefined constant or its value, and according to the type of the trade. volume is the amount of lots. For market orders, you must always check the account for the sufficiency. For pending orders, the amount of lots is not limited. price is the open price. It is specified according to the requirements and limitations accepted for making trades (see Order Characteristics and Rules for Making Trades). If the price requested for opening of market orders has not been found in the price thread or if it has considerably outdated, the trade request is rejected. However, if the price is outdated, but present in the price thread and if its deviation from the cu