i am getting a Sell/buy Failed with Error #4051
Invalid lots amount for OrderSend function.
i am still very new to coding and i am trying to fix these errors, but the ea places the buy&sell trades just fine. so i dont know what is wrong with the Ordersend line. could someone please give me some Help.
Fix Line 375 To :
int buy=OrderSend(Symbol(),OP_BUY,ll,Ask,0,ssl,0,EA_Name,m,0,clrNONE);
-
int buy=OrderSend(Symbol(),OP_BUY,ll,Ask,0,ssl,0,EA_Name,m,0,clrNONE);
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time, post in the correct place. The moderators will likely move this thread there soon. -
ssl=Ask-ssl*Point;
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
-
Use the debugger or print out your variables, including _LastError and prices and
find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
Read the error, Your Lot is too big as It is fixed value try to use 0.01 if it worked I will show you how to check Lots value before assigning it.
Try to change your codes to
int sell=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,ssl,0,EA_Name,m,0,clrNONE); int buy=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,ssl,0,EA_Name,m,0,clrNONE);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i am getting a Sell/buy Failed with Error #4051
Invalid lots amount for OrderSend function.
i am still very new to coding and i am trying to fix these errors, but the ea places the buy&sell trades just fine. so i dont know what is wrong with the Ordersend line. could someone please give me some Help.