Log files suddenly 4-5 GB, what is going on??

 
I have a serious problem that came up suddenly and I have no idea what to do. I try to optimize this EA but the further it optimizes the slower it goes. So I stop it, and check the log files, and every time the log file is 4-5 GB in size. Is there something in my expert causing this? Or is this something wrong with metatrader?


   extern string Account_Settings = "---------- Account Settings";
   extern double Risk_Percent=0.20;
   extern string General_Settings = "---------- General Settings";
   extern double fast=34;
   extern double slow=78;
   extern int currency_momentum=58;
   extern int trend_momentum=38;
   extern int Modechange_Pip=35;
   extern int MaxpipfromEMAH=35;
   extern int MaxpipfromEMAM=15;
   extern string Stop_Settings = "---------- Stop Settings";
   extern bool use_stop=false;
   extern double Buy_maxhoursNeg=28;
   extern double Buy_maxpipsNeg=30;
   extern double Sell_maxhoursNeg=7;
   extern double Sell_maxpipsNeg=50;
   extern string System_Settings = "----------System Settings-----WARNING!----DO NOT CHANGE!----";
   extern double Spike_Define=3.1;
   extern int RangePoint=6;
   extern double Candle_Multiply=1.5;
   extern double JumpWidth_Percen=0.25;
   extern double RangeChange_Percen=1;
   extern int Trending_TimeFrame=PERIOD_H1;
   extern int Ranging_TimeFrame=PERIOD_M15;

   string Trend,Buy,Sell,TradeComm;
   double Close1,Close2,Close3,Close4,Close5,Close6,Open1,Open2,Open3,Open4,Open5,Open6,
          Fast1,Fast2,Fast3,Fast4,Fast5,Fast6,Slow1,Slow2,Slow3,Slow4,Slow5,Slow6,
          Average,FastW,Currency_momentumA,Currency_momentumB,Currency_momentumC,
          Trend_momentumFastA,Trend_momentumFastB,Trend_momentumFastC,Trend_momentumFastD,
          Trend_momentumSlowA,Trend_momentumSlowB,fastma,slowma,
          Width1,Width2,Width3,Width4,Width5,Width6,
          WidthW1,WidthW2,WidthW3,WidthW4,WidthW5,WidthW6;
   int TF,Trendd,MaxpipfromEMA,Ranging,TFTime=0;

   int init() 
    {
   
    double FastTrend=iMA(NULL,Trending_TimeFrame,fast,0,MODE_EMA,PRICE_CLOSE,1);
    double SlowTrend=iMA(NULL,Trending_TimeFrame,slow,0,MODE_EMA,PRICE_CLOSE,1);
    double AveCandle=(((MathAbs(iLow(NULL,Trending_TimeFrame,1)-iHigh(NULL,Trending_TimeFrame,1))) + 
                       (MathAbs(iLow(NULL,Trending_TimeFrame,2)-iHigh(NULL,Trending_TimeFrame,2))) +
                       (MathAbs(iLow(NULL,Trending_TimeFrame,3)-iHigh(NULL,Trending_TimeFrame,3))) + 
                       (MathAbs(iLow(NULL,Trending_TimeFrame,4)-iHigh(NULL,Trending_TimeFrame,4))) +
                       (MathAbs(iLow(NULL,Trending_TimeFrame,5)-iHigh(NULL,Trending_TimeFrame,5))) + 
                       (MathAbs(iLow(NULL,Trending_TimeFrame,6)-iHigh(NULL,Trending_TimeFrame,6))) +
                       (MathAbs(iLow(NULL,Trending_TimeFrame,7)-iHigh(NULL,Trending_TimeFrame,7))) + 
                       (MathAbs(iLow(NULL,Trending_TimeFrame,8)-iHigh(NULL,Trending_TimeFrame,8))))/8);
                       
    if((MathAbs(FastTrend-SlowTrend)<=RangePoint*Point))
        {
        TF=Ranging_TimeFrame;
        MaxpipfromEMA=MaxpipfromEMAM;
        Ranging++;
        fastma=fast*RangeChange_Percen;
        slowma=slow*RangeChange_Percen;
        }
        else
        {
        TF=Trending_TimeFrame;
        MaxpipfromEMA=MaxpipfromEMAH;
        Ranging=0;
        fastma=fast;
        slowma=slow;
        }
        return(0);
     }
   
   void PreFetch() 
      {
      Close1=iClose(NULL,TF,1);   Open1=iOpen(NULL,TF,1);    Width1=MathAbs(Fast1-Slow1);    
      Close2=iClose(NULL,TF,2);   Open2=iOpen(NULL,TF,2);    Width2=MathAbs(Fast2-Slow2);    
      Close3=iClose(NULL,TF,3);   Open3=iOpen(NULL,TF,3);    Width3=MathAbs(Fast3-Slow3);    
      Close4=iClose(NULL,TF,4);   Open4=iOpen(NULL,TF,4);    Width4=MathAbs(Fast4-Slow4);    
      Close5=iClose(NULL,TF,5);   Open5=iOpen(NULL,TF,5);    Width5=MathAbs(Fast5-Slow5);    
      Close6=iClose(NULL,TF,6);   Open6=iOpen(NULL,TF,6);    Width6=MathAbs(Fast6-Slow6); 
      
      Fast1=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,1);    Slow1=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,1);
      Fast2=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,2);    Slow2=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,2);
      Fast3=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,3);    Slow3=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,3);
      Fast4=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,4);    Slow4=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,4);
      Fast5=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,5);    Slow5=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,5);
      Fast6=iMA(NULL,TF,fastma,0,MODE_EMA,PRICE_CLOSE,6);    Slow6=iMA(NULL,TF,slowma,0,MODE_EMA,PRICE_CLOSE,6);
      
      WidthW1=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,1)-Slow1); 
      WidthW2=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,2)-Slow2);  
      WidthW3=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,3)-Slow3);  
      WidthW4=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,4)-Slow4);  
      WidthW5=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,5)-Slow5);  
      WidthW6=MathAbs(iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,6)-Slow6);   
                                                                                    
      Average=iMA(NULL,TF,3,0,MODE_EMA,PRICE_CLOSE,1);
      FastW=iMA(NULL,TF,fastma*3.8,0,MODE_EMA,PRICE_CLOSE,1);
      Currency_momentumA=iCustom(NULL,TF,"OSMAMA",4,6,currency_momentum,1,currency_momentum,0,1);
      Currency_momentumB=iCustom(NULL,TF,"OSMAMA",4,6,currency_momentum,1,currency_momentum,1,1);
      Currency_momentumC=iCustom(NULL,TF,"OSMAMA",4,6,currency_momentum,1,currency_momentum,0,3);
      Trend_momentumFastA=iCustom(NULL,TF,"OSMAMA",4,6,trend_momentum,1,trend_momentum,0,1);
      Trend_momentumFastB=iCustom(NULL,TF,"OSMAMA",4,6,trend_momentum,1,trend_momentum,0,2);
      Trend_momentumFastC=iCustom(NULL,TF,"OSMAMA",4,6,trend_momentum,1,trend_momentum,0,3);
      Trend_momentumFastD=iCustom(NULL,TF,"OSMAMA",4,6,trend_momentum,1,trend_momentum,1,1);
      Trend_momentumSlowA=iCustom(NULL,TF,"OSMAMA",6,8,slowma*3,currency_momentum*3,currency_momentum*3,0,1);
      Trend_momentumSlowB=iCustom(NULL,TF,"OSMAMA",6,8,slowma*3,currency_momentum*3,currency_momentum*3,0,5);
      }


   int start()
      {
      double Averagepips,Opentime,Stopip;
      int i,open,Spike,SpikeW,Buyjump,Selljump,BuyjumpR,SelljumpR,Ticket,Cnt,Can;
   
      if(TFTime!=iTime(Symbol(),TF,1)) 
         {
         PreFetch();
         TFTime=iTime(Symbol(),TF,1);
         }  
  
   
      int total=OrdersTotal();
      double AcctLeverage=AccountLeverage();
      double CurrencyLotSize=MarketInfo(Symbol(),MODE_LOTSIZE);
      double lot=AccountEquity()*Risk_Percent/(CurrencyLotSize/AcctLeverage);
   
      for(i=0;i<total;i++)
         {
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
            {
            if(OrderSymbol()==Symbol())
               {
              open++;
               }
            }
         }
   
      if((MathAbs(Close1-Open1)>((Width1*Spike_Define))) || (MathAbs(Close2-Open2)>((Width2*Spike_Define))) || 
         (MathAbs(Close3-Open3)>((Width3*Spike_Define))) || (MathAbs(Close4-Open4)>((Width4*Spike_Define))) || 
         (MathAbs(Close5-Open5)>((Width5*Spike_Define))))
         {
         Spike++;
         }
      if((MathAbs(Close1-Open1)>((WidthW1*Spike_Define))) || (MathAbs(Close2-Open2)>((WidthW2*Spike_Define))) ||
         (MathAbs(Close3-Open3)>((WidthW3*Spike_Define))) || (MathAbs(Close4-Open4)>((WidthW4*Spike_Define))) ||
         (MathAbs(Close5-Open5)>((WidthW5*Spike_Define))))
         {
         SpikeW++;
         }
   
      if((Currency_momentumA>0) && (Average>Slow1) && (Trend=="sell"))
         {
         Trend="endtrend";
         }
     if((Currency_momentumA<0) && (Average<Slow1) && (Trend=="buy"))
         {
         Trend="endtrend";
         }
   //****************************************************************************************** 

   //*********************Jump Detector**************************************       
      
      if(((Open2>=Fast2) && (Close1<=Slow1)) || ((Open3>=Fast3) && (Close2<=Slow2)) || 
         ((Open4>=Fast4) && (Close3<=Slow3)) || ((Open5>=Fast5) && (Close4<=Slow4)) || 
         ((Open6>=Fast6) && (Close5<=Slow5)))
            {
            Selljump++;
            }
      if(((Open2<=Fast2) && (Close1>=Slow1)) || ((Open3<=Fast3) && (Close2>=Slow2)) || 
         ((Open4<=Fast4) && (Close3>=Slow3)) || ((Open5<=Fast5) && (Close4>=Slow4)) ||  
         ((Open6<=Fast6) && (Close5>=Slow5)))
            {
            Buyjump++;
            }
      if(((Open1>=Fast1) && (Close1<=Slow1)) || ((Open2>=Fast2) && (Close2<=Slow2)) || 
         ((Open3>=Fast3) && (Close3<=Slow3)) || ((Open4>=Fast4) && (Close4<=Slow4)) || 
         ((Open5>=Fast5) && (Close5<=Slow5)))
            {
            Selljump++;
            SelljumpR++;
            }
       if(((Open1<=Fast1) && (Close1>=Slow1)) || ((Open2<=Fast2) && (Close2>=Slow2)) || 
          ((Open3<=Fast3) && (Close3>=Slow3)) || ((Open4<=Fast4) && (Close4>=Slow4)) || 
          ((Open5<=Fast5) && (Close5>=Slow5)))
            {
            Buyjump++;
            BuyjumpR++;
            }
            
       
            
      
   
      if((open<1) && (fast<slow))
            {
  
            if((((Selljump>0) && (Ranging<1)) || ((SelljumpR>0) && (Ranging>0))) && (Spike<1) && (Fast1>Slow1)) 
                  {
                  if((Currency_momentumA<0) && ((Currency_momentumC>0) || 
                                                      ((Trend_momentumSlowA<Trend_momentumSlowB) && (Trend_momentumFastA<0))))
                        if((MathAbs(Slow1-Close1)<Width1*1.62) || (MathAbs(Slow1-Close1)<MaxpipfromEMA*Point)) 
                        
                              if((Currency_momentumA<Currency_momentumB) && (Trend_momentumFastA<Trend_momentumFastD))
                                    {
                                    Ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,1,0,Green);
                                    Trend="sell";
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }
            if((((Buyjump>0) && (Ranging<1)) || ((BuyjumpR>0) && (Ranging>0))) && (Spike<1) && (Fast1<Slow1)) 
                  {
                  if((Currency_momentumA>0) && ((Currency_momentumC<0) || 
                                                      ((Trend_momentumSlowA>Trend_momentumSlowB) && (Trend_momentumFastA>0))))
                        if((MathAbs(Slow1-Close1)<Width1*1.62) || (MathAbs(Slow1-Close1)<MaxpipfromEMA*Point)) 
                        
                              if((Currency_momentumA>Currency_momentumB) && (Trend_momentumFastA>Trend_momentumFastD))
                                    {
                                    Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,10,0,0,0,1,0,Green);
                                    Trend="buy";
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }
                  
            if((Trend=="sell") && (Ranging<1) && (Average<Fast1) && (Fast1<Slow1)) 
                  {
                  if((Trend_momentumFastA<0) && (Trend_momentumFastC>0)) 
               
                        if(((Currency_momentumA<Currency_momentumB) && (Currency_momentumA<0) && (Trend_momentumFastA<Trend_momentumFastD)) || 
                                    (Trend_momentumSlowA<Trend_momentumSlowB))
                              if(MathAbs(Fast1-Close1)<MaxpipfromEMA*Point)
                                    {
                                    Ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,1,0,Green);
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }
            if((Trend=="buy") && (Ranging<1) && (Average>Fast1) && (Fast1>Slow1)) 
                  {
                  if((Trend_momentumFastA>0) && (Trend_momentumFastC<0)) 
               
                        if(((Currency_momentumA>Currency_momentumB) && (Currency_momentumA>0) && (Trend_momentumFastA>Trend_momentumFastD)) || 
                                    (Trend_momentumSlowA>Trend_momentumSlowB))
                              if(MathAbs(Fast1-Close1)<MaxpipfromEMA*Point)
                                    {
                                    Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,10,0,0,0,1,0,Green);
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }
        
            if((Width1<=2*Point) && (MathAbs(FastW-Slow1)>=(RangePoint*Point)))
                  { 
                  if((Currency_momentumA<0) && (Trend_momentumFastA<0) && (Trend_momentumSlowA<Trend_momentumSlowB))
              
                        if(MathAbs(Close1-Fast1)<MaxpipfromEMA*Point)
               
                              if(SpikeW<1) 
                                    {
                                    Ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,1,0,Green);
                                    Trend="sell";
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }
            if((Width1<=2*Point) && (MathAbs(FastW-Slow1)>=(RangePoint*Point)))
                  { 
                  if((Currency_momentumA<0) && (Trend_momentumFastA<0) && (Trend_momentumSlowA<Trend_momentumSlowB))
              
                        if(MathAbs(Close1-Fast1)<MaxpipfromEMA*Point)
               
                              if(SpikeW<1) 
                                    {
                                    Ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,1,0,Green);
                                    Trend="sell";
                                    PlaySound("alert.wav");
                                    return(0);
                                    }
                  }  
            }
      
  
      if(use_stop==true)
         {
         for(i=0;i<total;i++)
            {
            OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
               {
               if((OrderType()==OP_BUY) && (Average<OrderOpenPrice()) && (Ranging>0))
                   {
                   Averagepips=(MathAbs(OrderOpenPrice()-Average))*10000.0;
                   Opentime=(TimeCurrent()-OrderOpenTime())/3600.0;
                   Stopip=(Opentime/(Buy_maxhoursNeg))*(Opentime*(Buy_maxpipsNeg/(Buy_maxhoursNeg)))-Buy_maxpipsNeg;
                   if(Stopip<0)
                        {
                        if(MathAbs(Averagepips/(Stopip/Opentime))>Opentime)
                           {
                           Can++;
                           }
                        }
                   if(Stopip>0)
                        {
                        Can++;
                        }
                   }
               if((OrderType()==OP_SELL) && (Average>OrderOpenPrice()) && (Ranging>0))
                  {
                  Averagepips=(MathAbs(Average-OrderOpenPrice()))*10000.0;
                  Opentime=(TimeCurrent()-OrderOpenTime())/3600.0;
                  Stopip=((-Opentime/(Sell_maxhoursNeg))*(Opentime*(Sell_maxpipsNeg/(Sell_maxhoursNeg)))+Sell_maxpipsNeg);
                  if(Stopip>0)
                        {
                        if((Averagepips/(Stopip/Opentime))>Opentime)
                           {
                           Can++;
                           }
                       }
                 if(Stopip<0)
                       {
                       Can++;
                       }
                   }
               } 
           } 
       }
       
      for(Cnt=0;Cnt<total;Cnt++)
         {
         OrderSelect(Cnt, SELECT_BY_POS, MODE_TRADES);
            {
            if(OrderType()==OP_BUY) 
               {
                if((Currency_momentumA<0) && (Currency_momentumA<Currency_momentumB) && (Close1<Fast1) && 
                  (Trend_momentumFastA<Trend_momentumFastD) && (Spike<1)) 
                     {
                     OrderClose(OrderTicket(),OrderLots(),Bid,10,Blue);
                     PlaySound("alert.wav");
                     return(0);
                     }
               if((Can>0) && (Spike<1)) 
                     {
                     OrderClose(OrderTicket(),OrderLots(),Bid,10,Blue);
                     PlaySound("alert.wav");
                     return(0);
                     }
                 }
              if(OrderType()==OP_SELL) 
                 {
                 if((Currency_momentumA>0) && (Currency_momentumA>Currency_momentumB) && (Close1>Fast1) && 
                    (Trend_momentumFastA>Trend_momentumFastD) && (Spike<1))
                     {
                     OrderClose(OrderTicket(),OrderLots(),Ask,10,Blue);
                     PlaySound("alert.wav");
                     return(0);
                     }
                 if((Can>0) && (Spike<1))
                     {
                     OrderClose(OrderTicket(),OrderLots(),Ask,10,Blue);
                     PlaySound("alert.wav");
                     return(0);
                     }
                  }
               }
            }
      }
 
I got ride of the comments and let it optimize again all the way, and by the end the log file was 32 GB.

Since my EA switches between the 15 minute charts and the 1-hour charts depending on
   if((MathAbs(FastTrend-SlowTrend)<=RangePoint*Point))



would that be a problem? And of so how could I fix it so I could still backtest it?

 
I got ride of the comments and let it optimize again all the way, and by the end the log file was 32 GB.

Since my EA switches between the 15 minute charts and the 1-hour charts depending on
   if((MathAbs(FastTrend-SlowTrend)<=RangePoint*Point))



would that be a problem? And of so how could I fix it so I could still backtest it?


That thread might help: http://www.forex-tsd.com/metatrader-4/5288-log-files-3-8-gb-generated-mt4-00-build-201-a.html
 
I have a serious problem that came up suddenly and I have no idea what to do. I try to optimize this EA but the further it optimizes the slower it goes. So I stop it, and check the log files, and every time the log file is 4-5 GB in size. Is there something in my expert causing this? Or is this something wrong with metatrader?

May be you have FAT32 instead NTFS?
Maximum file size in FAT32 someting about 4GB
 
No unfortunately I've already looked at that thread and all they advise to do is get rid of any print or comment functions, which I already have.