ObjectSetText not working anymore.

 
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
double winrate=0;
double totaltr=0;
double pf=0;
double profit=0;
double balance=0;
  int ordershistory;
  double profitordin[1000];
 int x;
 int i;
 int ticket;
 double z=0;
double t=0;
double y=0;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
 
  
  
//--- indicator buffers mapping
 
  
//---
   return(INIT_SUCCEEDED);
  }
void OnStart()
{
ordershistory= OrdersHistoryTotal();
 x= OrdersTotal();
   ObjectCreate(0,"text3",OBJ_LABEL,0,0,0);
 ObjectSet("text3",OBJPROP_XDISTANCE,987);
 ObjectSet("text3",OBJPROP_YDISTANCE,6);
 
  ObjectCreate(0,"text4",OBJ_LABEL,0,0,0);
 ObjectSet("text4",OBJPROP_XDISTANCE,987);
 ObjectSet("text4",OBJPROP_YDISTANCE,26);
 
  ObjectCreate(0,"text5",OBJ_LABEL,0,0,0);
 ObjectSet("text5",OBJPROP_XDISTANCE,1161);
 ObjectSet("text5",OBJPROP_YDISTANCE,656);

  ordershistory= OrdersHistoryTotal();

  x= OrdersTotal();

//atasare profit  la vector
 for (i=0;i<=ordershistory;i++)  
 {
 ticket=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY );
  
 profitordin[i]=OrderProfit();
  
}
  
  double grossloss=0;
double grossprofit=0;
int wins=0;  
int zero=0;
for (i=0;i<ordershistory;i++)  
{
   if (profitordin[i]>0) 
   {wins++;
   grossprofit=grossprofit+profitordin[i];
   }
   if (profitordin[i]<0) 
   {grossloss=grossloss+profitordin[i];}
  if (profitordin[i]==0) zero++;
  
}

pf=(-1)*grossprofit/grossloss;


y=ordershistory-zero;
z=wins;
winrate=z/y;
profit=grossprofit+grossloss;


t=AccountBalance();
 ObjectSetText("text3","Winrate  "+DoubleToStr(winrate,2)+" PF  "+DoubleToStr(pf,2)+"  TradesTotal "+DoubleToStr(y,0),10,NULL,White);
ObjectSetText("text4","Daily Profit  "+DoubleToStr(profit,2)+"  Account "+DoubleToStr(t,2),10,NULL,White);
ObjectSetText("text5","delta live",10,NULL,White);
// setare text  




}

int deinit()
{
ObjectDelete(0,"text3");
ObjectDelete(0,"text4");
ObjectDelete(0,"text5");
return 0;

}

it's a script that shows statistics of the account in some text labels. it's not working although yesterday worked when i made it. it seems that somehow it doesn't reach the objectsettext command . deinit also not working. objectcreate works. this script compiles without errors. that's my problem.

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. Indonesian Member I want to know how...
 
it tries to copy the closed orders profits into an array and use it further for grossloss, grossprofit , winrate , totaltrades , pf . it doesn't show anything today. yesterday worked fine.
 
  1. The script creates the objects in OnStart. Script then exits and deletes them in OnDeinit. You shouldn't see anything, ever.
  2. for (i=0;i<=ordershistory;i++)  
     {
     ticket=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY );
    OrderSelect does not return a ticket. The last iteration will always fail. Check your return codes for errors, report them. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
Reason: