Make the function boolean so it can check if the order was executed successfully or not.
bool ShortPositionOpen() { MqlTradeRequest mrequest; // Will be used for trade requests MqlTradeResult mresult; // Will be used for results of trade requests ZeroMemory(mrequest); ZeroMemory(mresult); double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask price double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid price if(!PositionSelect(_Symbol)) { mrequest.action = TRADE_ACTION_DEAL; // Immediate order execution mrequest.price = NormalizeDouble(Bid,_Digits); // Lastest Bid price mrequest.sl = StopLoss; // Stop Loss mrequest.tp = TakeProfit; // Take Profit mrequest.symbol = _Symbol; // Symbol mrequest.volume = Lot; // Number of lots to trade mrequest.magic = 0; // Magic Number mrequest.type= ORDER_TYPE_SELL; // Sell order mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type mrequest.deviation=1; // Deviation from current price return(OrderSend(mrequest,mresult)); // Send order } return(false); }
Ernst Van Der Merwe:
Make the function boolean so it can check if the order was executed successfully or not.
Thank you very much, it worked!
Best Regards
You could use MQL5\Include\Trade\Trade.mqh library. So, you would avoid this kind of mistakes. Regards.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register