What error message do you get? Error_Codes. The_Book.
Dear vx,
Close[0] is always the Bid portion of the price. Are you sure, that this is what you want?
What is the value of GetLastError() after the failure? What's in your logs regarding this EA?
Dear vx,
Close[0] is always the Bid portion of the price. Are you sure, that this is what you want?
What is the value of GetLastError() after the failure? What's in your logs regarding this EA?
Dear NoTomatoes:
Thank you for your reply.
1. Close[0] here, I just want to send the order once the price reaches 1.3096.maybe i can get this by the code"OrderSend(Symbol(),OP_BUYSTOP,0.5,1.3096,3,1.3096-7*Point,0,"OP_BUYSTOP",1,0,Green)",yes?
2. GetLastError() returns 129 which means "invalid price".
Thank you for your guide.
Error message is 129 which means "Invalid price".
Thank you for your guide.
Error message is 129 which means "Invalid price".
You cannot place pending orders at current prices.
You can't place a BUYSTOP at Bid unless the Spread is 0.0 but you can place a BUYSTOP at Ask if your STOPLEVEL is 0.0
To vx0532 please read, understand and absorb this: Requirements and Limitations in Making Trades
The code is as below:
if(Close[0]>=1.3096) OrderSend(Symbol(),OP_BUYSTOP,2,Bid,3,Bid-7*Point,0,0,0,0,Red); if(Close[0]<=1.3089) OrderSend(Symbol(),OP_SELLSTOP,0.5,Ask,3,Ask-5*Point,Ask+2*Point,0,0,0,Green);
Play videoPlease edit your post.
For large amounts of code, attach it.
- What are Function return values ? How do I use them ? - MQL4 forum
- Not adjusting for 4/5 digit brokers, not adjusting for ECN brokers
- Not checking trade limits
- Wrong number of arguments in the BuyStop
- Using market price for Stops/limits (See #4)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The code is as below:
if(Close[0]>=1.3096)
OrderSend(Symbol(),OP_BUYSTOP,2,Bid,3,Bid-7*Point,0,0,0,0,Red);
if(Close[0]<=1.3089)
OrderSend(Symbol(),OP_SELLSTOP,0.5,Ask,3,Ask-5*Point,Ask+2*Point,0,0,0,Green);
I want made EA which will send new order to buy "2" lots when the price reaches 1.3096 or sell "0.5" lots when the price reaches 1.3089 and also set the "stoploss" and "takeprofit".
But I find this EA never works after I have execute it when the price reaches 1.3096 or 1.3089, why? is there some problem about it?
In addition, when I attach a correct EA to the chart and set "EA" open, and then I close MT4 sofeware; now the correct EA still work?
Thank you.