SendNotification with P&L - page 2 12 New comment krishna Gaherwar 2013.04.05 14:58 #11 phi.nuts: Ups, my bad, we have to select it first using HistoryDealSelect. I check around, apparently we have to wait until MT5 is updated with trading history, in my case I wait for a sec. Maybe I have lousy connection :(So the code will be like this.Dearkindly correct some error is there. error in line 39.47 and 58 void ShortPositionClose() { 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(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) { mrequest.action = TRADE_ACTION_DEAL; // Immediate order execution mrequest.price = NormalizeDouble(Ask,_Digits); // Latest ask price mrequest.sl = 0; // Stop Loss mrequest.tp = 0; // Take Profit mrequest.symbol = _Symbol; // Symbol mrequest.volume = Lot; // Number of lots to trade mrequest.magic = 0; // Magic Number mrequest.type = ORDER_TYPE_BUY; // Buy order mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type mrequest.deviation=5; // Deviation from current price OrderSend(mrequest,mresult); // Send order double OutCome = 0.0; long Ticket = mresult.deal; Sleep(1000); // <<============================ wait ! ResetLastError(); if (HistoryDealSelect(Ticket)) { OutCome = HistoryDealGetDouble(Ticket,DEAL_PROFIT); } else { Print("hist deal select fail ",GetLastError()); } string Text = "BBWP Closed a Short position with P&L : "+OutCome; Print(TimeCurrent()," Print 3 Outcome ",OutCome," Ticket ",Ticket); SendNotification(Text); } } //+------------------------------------------------------------------+ How to close an Errors, bugs, questions Questions from Beginners MQL5 Simon Gniadkowski 2013.04.05 15:02 #12 saibabashirdi: Dearkindly correct some error is there. error in line 39.47 and 58 <CODE REMOVED>Please edit your post . . . please use the SRC button to post code: How to use the SRC button. 12 New comment
Ups, my bad, we have to select it first using HistoryDealSelect.
I check around, apparently we have to wait until MT5 is updated with trading history, in my case I wait for a sec. Maybe I have lousy connection :(
So the code will be like this.
Dear
kindly correct some error is there. error in line 39.47 and 58
void ShortPositionClose()Dear
kindly correct some error is there. error in line 39.47 and 58
<CODE REMOVED>