Order Send Failed With Error #134
Contents |
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
Mql4 Error Codes
enough money in your account to place an order with the given lot mql4 error 130 size. What should you do? Ordersend error 134 tends to happen a lot when people code expert advisors with mql4 error 4109 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
Mql4 Error 4051
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
Mql4 Ordersend Error 130
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
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 ordermodify error 1 print the error description you can use the ErrorDescription() function,
Mql4 Error 4108
defined in stdlib.mqh. Example: #include
register 13118 WHRoeder 2010.09.08 20:36 I had a typo in my EA that resulted in opening many orders, so the margin exhaustion is expected. But since the code does check margin, the 134 was https://forum.mql4.com/35056 not. RefreshRates(); ... /* However, the broker doesn't care about the at.risk/account balance. They * care about margin. Margin used=lots used*marginPerLot and that must be * less than free margin available. */ marginFree= AccountFreeMargin()*0.95, // Allow some slack marginPerLot= MarketInfo( Symbol(), MODE_MARGINREQUIRED ), // So I use, the lesser of either. size = MathMin(marginFree / marginPerLot, at.risk / maxLossPerLot); ... doubleminLot= MarketInfo(Symbol(), MODE_MINLOT); Print( "mf=",marginFree," mql4 error mpl=",marginPerLot," lm=",marginFree/marginPerLot," ls=",size," min=",minLot ); ... doubleLotStep = MarketInfo(Symbol(), MODE_LOTSTEP); size =MathMax( minLot, MathFloor(size*adjFact/LotStep)*LotStep ) The journal displays: EURUSD,M1: OrderSend error 134 Tester: PrevBalance: 9455.32, PrevPL: 2958.73, PrevEquity 12414.05, PrevMargin: 12015.81, NewMargin: 12417, FreeMargin: -3.41 Tester: not enough money for buy 0.30 EURUSD at 1.23443 EURUSD,M1: mf=378.3239 mpl=1234.34 lm=0.3065 ls=0.3065 min=0.01 The output from the Print shows free margin was $378 and generated a maximum lot size order send failed of 0.30. But the tester doesn't agree with MarketInfo. At the end of the routine, I added: size =MathMax( minLot, MathFloor(size*adjFact/LotStep)*LotStep ); double AFMC=AccountFreeMarginCheck(Symbol(), op.code, size); Print("afmc=",AFMC); and AFMC matches the tester's FreeMargin output. similar ERR_STRING_PARAMETER_EXPECTED 4062 String parameter expected. Automated Trading Championship 2008: Registration Is Over! Simple Adviser EMA WMA RSI Automated Trading Championship 2008: Registration Is Over! AccountFreeMarginCheck 1 fulfillthedream 2011.07.25 22:34 # Hey, I am having the same problem as well. It seems that my code is being trigged and buying massive amounts of units over and over again on the same candle stick instead of being triggered by the trend happening within the candle stick. Since I am new to this there must be something I am missing. If I only want 1 indication of a buy/sell within a candle stick how do I properly exit out of the code once a signal has been triggered in the evaluation candle stick? I am currently using the Bars() as my counter which from my understand is counting the bars within a graph and not the ticks? But when I test this I dont think this is the case. Am I on the right track here? similar Candle stick c