Open a position error?
- Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- What is STOP_LIMIT, Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
- You are not adjusting SL, TP, and slippage for 4/5 digit brokers. double pip = StringFind(_Symbol,"JPY") < 0 ? 0.01 : 0.0001;
int slippage = 3 * int(pip / _Point); - Did you normalize lots properly?
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
- book.mql4.com
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
whroeder1:
- Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- What is STOP_LIMIT, Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
- You are not adjusting SL, TP, and slippage for 4/5 digit brokers. double pip = StringFind(_Symbol,"JPY") < 0 ? 0.01 : 0.0001;
int slippage = 3 * int(pip / _Point); - Did you normalize lots properly?
Many thanks for your answer, just some questions:
1. How can I check retur codes?
2. Can I use this cose to normalize SL and TP?
NormalizeDouble(Ask+SL*Point,Digits)
Thanks in advance
cpr:
1. How can I check retur codes? 2. Can I use this cose to normalize SL and TP? |
|
Hi all,
I'm writing a simple code to open a position BUY and SELL...just to learn, but it doesn't work. Anyone can tell me why? I have declared all variables (SL, TP and lots) and the code has been compiled succesfully...but it doesn't open positions...
Thanks in advance
{
//---
OrderSend(Symbol(),OP_BUY, lots, MarketInfo(Symbol(),MODE_ASK), 3, MarketInfo(Symbol(),MODE_ASK)-(SL*Point), MarketInfo(Symbol(),MODE_ASK)+(TP*Point), "Buy Trade", magic, 0, Blue);
OrderSend(Symbol(),OP_SELL, lots, MarketInfo(Symbol(),MODE_BID), 3, MarketInfo(Symbol(),MODE_BID)+(SL*Point), MarketInfo(Symbol(),MODE_BID)-(TP*Point), "Sell Trade", magic, 0, Red);
//---
return(INIT_SUCCEEDED);
}