need help for calculated total pips for order closed today (Mql5)
Any Help?
need help for calculated total pips for order closed today (Mql5)
Any Help?
double TotalPipClosed = 0;
ulong Deal_Ticket; // deal ticket
ulong Order_Ticket; // ticket of the order the deal was executed on
datetime Deal_Execution_Time; // time of a deal execution
long Deal_Type ; // type of a trade operation
long History_Position_ID; // position ID
double History_Volume; // operation volume
string History_Symbol; // symbol of the deal
//--- set the start and end date to request the history of deals
datetime Today = 1 * PeriodSeconds(PERIOD_D1);// iTime(_Symbol, PERIOD_D1, 0); // from the today open
datetime EndOfToday = TimeCurrent(); // till the current moment
//--- request the history of deals in the specified period
HistorySelect(Today, EndOfToday);
//--- total number in the list of deals
int Deals = HistoryDealsTotal();
//--- now process each trade
for(int i = 0; i < Deals; i++)
{
Deal_Ticket = HistoryDealGetTicket(i);
History_Volume = HistoryDealGetDouble(Deal_Ticket, DEAL_VOLUME);
Deal_Execution_Time = (datetime)HistoryDealGetInteger(Deal_Ticket, DEAL_TIME);
Order_Ticket = HistoryDealGetInteger(Deal_Ticket, DEAL_ORDER);
Deal_Type = HistoryDealGetInteger(Deal_Ticket, DEAL_TYPE);
History_Symbol = HistoryDealGetString(Deal_Ticket, DEAL_SYMBOL);
History_Position_ID = HistoryDealGetInteger(Deal_Ticket, DEAL_POSITION_ID);
if ((Deal_Type == POSITION_TYPE_BUY) || (Deal_Type == POSITION_TYPE_SELL))
{
TotalPipClosed += ((HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) - HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_IN) / _Point;
}
}
still failure to get totalpips for orderclosed for current day.
where the mistake there ?
our immediate (obvious) problem is in this line:
TotalPipClosed += ((HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) - HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_IN) / _Point
Break this down a bit . . .
(HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT)
. . . is a condition, that returns true/false, or in this case 1 or 0.
The same is true for:
HistoryDealGetInteger(Deal_Ticket, DEAL_ENTRY) == DEAL_ENTRY_IN
Neither of these will give you pips.
Maybe look at the function HistoryDealGetDouble() with the parameter DEAL_PROFIT.
Good luck.
you mean using HistoryDealGetDouble to get deal profit and then divide with deal volume ??
i cant find OrderClosePrice on mql5…
and what if my acc currency isnt usd, maybe jpy or gbp.
so how to convert it to actual pips gained ?