However, a new problem emerged that i'm needing help with.
When i load my EA onto a chart, immediately within seconds i get a email of the info i wanted to receive, but after that first email, my EA stops placing pending orders after the first pending orders expire or if price triggers a pending order and either hits my stop loss / take profit level. My EA stopped placing pending orders after i placed this code in the body of the on tick function:
// In Global Scopestaticdatetime lastdealtime = 0;
//----------------------------------------------------------------------------------------------------------//Send email alerts of last closed deals symbol & loss or profit amount in USD//----------------------------------------------------------------------------------------------------------- //--- request trade historyHistorySelect(0,TimeCurrent());
uint total_deals=HistoryDealsTotal();
ulong ticket_history_deal=0;
int counter=0;
string text="";
//--- for all dealsfor(uint i=total_deals-1; i>=0; i--){
//--- try to get deals ticket_history_dealif((ticket_history_deal=HistoryDealGetTicket(i))>0){
long deal_ticket =HistoryDealGetInteger(ticket_history_deal,DEAL_TICKET);
long deal_time =HistoryDealGetInteger(ticket_history_deal,DEAL_TIME);
long deal_type =HistoryDealGetInteger(ticket_history_deal,DEAL_TYPE);
long deal_entry =HistoryDealGetInteger(ticket_history_deal,DEAL_ENTRY);
long deal_magic =HistoryDealGetInteger(ticket_history_deal,DEAL_MAGIC);
double deal_commission =HistoryDealGetDouble(ticket_history_deal,DEAL_COMMISSION);
double deal_swap =HistoryDealGetDouble(ticket_history_deal,DEAL_SWAP);
double deal_profit =HistoryDealGetDouble(ticket_history_deal,DEAL_PROFIT);
string deal_symbol =HistoryDealGetString(ticket_history_deal,DEAL_SYMBOL);
datetime m_from_date = 0;
uchar lastdeal = 1;
//--- if((_Symbol==deal_symbol || _Symbol=="") && (Magic==deal_magic || Magic<0)){
if(deal_entry==DEAL_ENTRY_OUT && deal_time>lastdealtime){
counter++;
string time=TimeToString((datetime)deal_time,TIME_DATE|TIME_MINUTES|TIME_SECONDS);
SendMail(__FILE__, Symbol()+", $ "+DoubleToString(deal_commission+deal_swap+deal_profit,2));
lastdealtime = (datetime)deal_time;
if(counter==lastdeal){
m_from_date=(datetime)deal_time;
break;
}
}
}
}
}
and once i remove this code above and recompile it to test the EA on a live chart, it works normally and places pending orders every 2 minutes(expiry time 120 seconds) on the 1 minute chart.
Can someone please help me solve this. Why is my EA not placing orders whenever a signal is generated and how can i fix this? Thank you in advance!
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
This was my previous problem https://www.mql5.com/en/forum/435434#comment_42935818 which has been solved
However, a new problem emerged that i'm needing help with.
When i load my EA onto a chart, immediately within seconds i get a email of the info i wanted to receive, but after that first email, my EA stops placing pending orders after the first pending orders expire or if price triggers a pending order and either hits my stop loss / take profit level. My EA stopped placing pending orders after i placed this code in the body of the on tick function:
and once i remove this code above and recompile it to test the EA on a live chart, it works normally and places pending orders every 2 minutes(expiry time 120 seconds) on the 1 minute chart.
Can someone please help me solve this. Why is my EA not placing orders whenever a signal is generated and how can i fix this? Thank you in advance!