Hi,
I tried to generate some
strategies with SQ4 Beta 8, and generate the MQL codes MT5. When trying
to open a position, it uses the following codes to get the quote price
in openPosition() function
double curPrice = price > 0 ? price : SymbolInfoDouble(correctSymbol(symbol), isLongOrder(type) ? SYMBOL_ASK : SYMBOL_BID);
It often generates the following error message:
2018.04.15 16:09:05.588 Core 2 2015.05.15 01:00:00 failed buy stop 1.00 AUDUSD at 0.80585 [Invalid price]
2018.04.15 16:09:05.588 Core 2 2015.05.15 01:00:00 Alert: The order request could not be completed. Error no.: 4756
and the OrderSend failed.
I fixed this with the following change:
MqlTick last_tick;
double
curPrice = price > 0 ? price :
SymbolInfoDouble(correctSymbol(symbol), isLongOrder(type) ? SYMBOL_ASK :
SYMBOL_BID); // Original code
Alert("-----SLPT: ", slPrice, ", ", ptPrice, ", Price Ori:=", curPrice);
SymbolInfoTick(_Symbol,last_tick);
curPrice = isLongOrder(type) ? last_tick.ask : last_tick.bid;
Alert("-----SLPT: ", slPrice, ", ", ptPrice, ", Price Updated:=", curPrice);
The output message becomes:
2018.04.15 16:13:22.119 Core 2 2015.06.29 00:00:00 Alert: -----SLPT: 0.0, 0.0, Price Ori:=0.766433
2018.04.15 16:13:22.119 Core 2 2015.06.29 00:00:00 Alert: -----SLPT: 0.0, 0.0, Price Updated:=0.76246
Obviously, the price is off by around 200 points if the original quotation method
is used. I think it's a wrong way to get price quotes.
Please fix this issue in next beta or release.
Thank!