I am using MT5, demo account.
I have a EA that will do PositionOpen for buy and sell and I found that all my buy position failed and get requote message. Here is my code for buy and sell position:
Here is the log about the error:
From the log you can see that sell position is okay, anyone knows the reason?
What is the value of your "last" variable. It's incorrect, a BUY position is opened at ask price, not at bid :
20181018_050041 INFO MakeBuyRequest:181 lots: 0.010000 price: 1.614860 sl: 1.613860 tp: 1.615360 bid: 1.614860 ask: 1.615060
Thank you so much, it seems fixed the problem. I used the last price as the price for buy order and sell order like this:
double GetLastPrice() { MqlRates current_rates[1]; ResetLastError(); if(CopyRates(Symbol(), Period(), 0, 1, current_rates) != 1) { g_Logger.PrintInfo(StringFormat("%s:%d CopyRates copy error, Code = %d", __FUNCTION__, __LINE__, GetLastError())); return 0; } return current_rates[0].close; }
And now I do this and the problem is fixed. Thank you so much,
double price = SymbolInfoDouble(Symbol(), SYMBOL_ASK); if (!g_Trader.PositionOpen(Symbol(), ORDER_TYPE_BUY, g_Lots, price, sl, tp)) { string str; MqlTradeRequest request; MqlTradeResult result; g_Trader.Result(result); g_Trader.Request(request); g_Logger.PrintError(StringFormat("%s:%d Buy PositionOpen error %s error_code %d", __FUNCTION__, __LINE__, g_Trader.FormatRequestResult(str, request, result), GetLastError())); } else { g_Logger.PrintInfo(StringFormat("%s:%d Success Buy Request", __FUNCTION__, __LINE__)); }
Thank you so much, it seems fixed the problem. I used the last price as the price for buy order and sell order like this:
And now I do this and the problem is fixed. Thank you so much,
- 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 using MT5, demo account.
I have a EA that will do PositionOpen for buy and sell and I found that all my buy position failed and get requote message. Here is my code for buy and sell position:
Here is the log about the error:
From the log you can see that sell position is okay, anyone knows the reason?
More logs from MT5 and my EA's log: