Download MetaTrader 5
To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
taro300
71
taro300 2014.04.16 06:05 

Why MT4(build 625) hang-up?


=== Step ===

(1) create a new chart

(2) drag and drop Expert Advisor ( testEA ) onto the chart

(3) repeat key press ( key is 'j' or 'k' )

(4) MT4 hang-up


<< text code (Expert Advisor) -- testEA.mq4 >>

int OnInit() {
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
   return;
}

void OnTick()
{
   return;
}


void
OnChartEvent(
   const int id,         // Event ID
   const long& lparam,   // Parameter of type long event
   const double& dparam, // Parameter of type double event
   const string& sparam  // Parameter of type string events
)
{
   switch (id) {
   
   case CHARTEVENT_KEYDOWN:
      if (lparam == 'J' || lparam == 'j') {
         ENUM_TIMEFRAMES new_timeframe = PERIOD_CURRENT;
         switch (Period()) {
         case PERIOD_M5:   new_timeframe = PERIOD_M1; break;
         case PERIOD_M15:  new_timeframe = PERIOD_M5; break;
         case PERIOD_M30:  new_timeframe = PERIOD_M15; break;
         case PERIOD_H1:   new_timeframe = PERIOD_M30; break;
         case PERIOD_H4:   new_timeframe = PERIOD_H1; break;
         case PERIOD_D1:   new_timeframe = PERIOD_H4; break;
         case PERIOD_W1:   new_timeframe = PERIOD_D1; break;
         case PERIOD_MN1:  new_timeframe = PERIOD_W1; break;
         }
         if (new_timeframe != PERIOD_CURRENT) {
            ChartSetSymbolPeriod(0, NULL, new_timeframe);
         }
      } else if (lparam == 'K' || lparam == 'k') {
         new_timeframe = PERIOD_CURRENT;
         switch (Period()) {
         case PERIOD_M1:   new_timeframe = PERIOD_M5; break;
         case PERIOD_M5:   new_timeframe = PERIOD_M15; break;
         case PERIOD_M15:  new_timeframe = PERIOD_M30; break;
         case PERIOD_M30:  new_timeframe = PERIOD_H1; break;
         case PERIOD_H1:   new_timeframe = PERIOD_H4; break;
         case PERIOD_H4:   new_timeframe = PERIOD_D1; break;
         case PERIOD_D1:   new_timeframe = PERIOD_W1; break;
         case PERIOD_W1:   new_timeframe = PERIOD_MN1; break;
         }
         if (new_timeframe != PERIOD_CURRENT) {
            ChartSetSymbolPeriod(0, NULL, new_timeframe);
         }
      }
      break;

   }
}
Keith Watford
Moderator
8027
Keith Watford 2014.04.16 06:48  
void
OnChartEvent(
             const int id,         // Event ID
             const long& lparam,   // Parameter of type long event
             const double& dparam, // Parameter of type double event
             const string& sparam  // Parameter of type string events
             )
  {
  int new_timeframe;
   switch(id) 
     {

      case CHARTEVENT_KEYDOWN:
         if(lparam=='J' || lparam=='j')
           {
            //ENUM_TIMEFRAMES new_timeframe=PERIOD_CURRENT;
            switch(Period()) 
              {
               case PERIOD_M1:   new_timeframe = PERIOD_M1; break;
               case PERIOD_M5:   new_timeframe = PERIOD_M1; break;
               case PERIOD_M15:  new_timeframe = PERIOD_M5; break;
               case PERIOD_M30:  new_timeframe = PERIOD_M15; break;
               case PERIOD_H1:   new_timeframe = PERIOD_M30; break;
               case PERIOD_H4:   new_timeframe = PERIOD_H1; break;
               case PERIOD_D1:   new_timeframe = PERIOD_H4; break;
               case PERIOD_W1:   new_timeframe = PERIOD_D1; break;
               case PERIOD_MN1:  new_timeframe = PERIOD_W1; break;
              }
            if(new_timeframe!=PERIOD_CURRENT) 
              {
               ChartSetSymbolPeriod(0,NULL,new_timeframe);
              }
              } 
              else if(lparam=='K' || lparam=='k') {
            new_timeframe= PERIOD_CURRENT;
            switch(Period()) 
              {
               case PERIOD_M1:   new_timeframe = PERIOD_M5; break;
               case PERIOD_M5:   new_timeframe = PERIOD_M15; break;
               case PERIOD_M15:  new_timeframe = PERIOD_M30; break;
               case PERIOD_M30:  new_timeframe = PERIOD_H1; break;
               case PERIOD_H1:   new_timeframe = PERIOD_H4; break;
               case PERIOD_H4:   new_timeframe = PERIOD_D1; break;
               case PERIOD_D1:   new_timeframe = PERIOD_W1; break;
               case PERIOD_W1:   new_timeframe = PERIOD_MN1; break;
               case PERIOD_MN1:  new_timeframe = PERIOD_MN1; break;
              }
            if(new_timeframe!=PERIOD_CURRENT) 
              {
               ChartSetSymbolPeriod(0,NULL,new_timeframe);
              }
           }
         break;

     }
  }
//+------------------------------------------------------------------+
Alain Verleyen
Moderator
28702
Alain Verleyen 2014.04.16 22:05  
taro300:

Why MT4(build 625) hang-up?


=== Step ===

(1) create a new chart

(2) drag and drop Expert Advisor ( testEA ) onto the chart

(3) repeat key press ( key is 'j' or 'k' )

(4) MT4 hang-up


<< text code (Expert Advisor) -- testEA.mq4 >>


It's just running fine for me.

Edit : I am using build 628.

Alain Verleyen
Moderator
28702
Alain Verleyen 2014.04.16 22:07  
GumRai:

Which problem are you trying to correct with these modifications ?
Keith Watford
Moderator
8027
Keith Watford 2014.04.17 05:21  
angevoyageur:
Which problem are you trying to correct with these modifications ?

Well I included the additional cases so to avoid "Not all control paths return a value", although it could probably be better done with a default.

int new_timeframe can just be left at ENUM_TIMEFRAMES new_timeframe=PERIOD_CURRENT;

but it needed to be moved because it was declared locally to the first if and so had no value in the 2nd if

The code as posted will not compile in 625.

void
OnChartEvent(
             const int id,         // Event ID
             const long& lparam,   // Parameter of type long event
             const double& dparam, // Parameter of type double event
             const string& sparam  // Parameter of type string events
             )
  {
  int new_timeframe;
   switch(id) 
     {

      case CHARTEVENT_KEYDOWN:
         if(lparam=='J' || lparam=='j')
           {
            //ENUM_TIMEFRAMES new_timeframe=PERIOD_CURRENT;
            switch(Period()) 
              {
               case PERIOD_M1:   new_timeframe = PERIOD_M1; break;
               case PERIOD_M5:   new_timeframe = PERIOD_M1; break;
               case PERIOD_M15:  new_timeframe = PERIOD_M5; break;
               case PERIOD_M30:  new_timeframe = PERIOD_M15; break;
               case PERIOD_H1:   new_timeframe = PERIOD_M30; break;
               case PERIOD_H4:   new_timeframe = PERIOD_H1; break;
               case PERIOD_D1:   new_timeframe = PERIOD_H4; break;
               case PERIOD_W1:   new_timeframe = PERIOD_D1; break;
               case PERIOD_MN1:  new_timeframe = PERIOD_W1; break;
              }
            if(new_timeframe!=PERIOD_CURRENT) 
              {
               ChartSetSymbolPeriod(0,NULL,new_timeframe);
              }
              } 
              else if(lparam=='K' || lparam=='k') {
            new_timeframe= PERIOD_CURRENT;
            switch(Period()) 
              {
               case PERIOD_M1:   new_timeframe = PERIOD_M5; break;
               case PERIOD_M5:   new_timeframe = PERIOD_M15; break;
               case PERIOD_M15:  new_timeframe = PERIOD_M30; break;
               case PERIOD_M30:  new_timeframe = PERIOD_H1; break;
               case PERIOD_H1:   new_timeframe = PERIOD_H4; break;
               case PERIOD_H4:   new_timeframe = PERIOD_D1; break;
               case PERIOD_D1:   new_timeframe = PERIOD_W1; break;
               case PERIOD_W1:   new_timeframe = PERIOD_MN1; break;
               case PERIOD_MN1:  new_timeframe = PERIOD_MN1; break;
              }
            if(new_timeframe!=PERIOD_CURRENT) 
              {
               ChartSetSymbolPeriod(0,NULL,new_timeframe);
              }
           }
         break;

     }
  }
taro300
71
taro300 2014.04.17 11:39  

I was changed source code.

But MT4 was hang-up. (>_<)/


<< MT4 hang-up >>



>
Alain Verleyen
Moderator
28702
Alain Verleyen 2014.04.17 22:00  
GumRai:

Well I included the additional cases so to avoid "Not all control paths return a value", although it could probably be better done with a default.

There is not such problem with this code.

int new_timeframe can just be left at ENUM_TIMEFRAMES new_timeframe=PERIOD_CURRENT;

but it needed to be moved because it was declared locally to the first if and so had no value in the 2nd if

The code as posted will not compile in 625.

Ok it compiles fine without #property strict, not with it. But in all case it doesn't hang up MT4 for me.
Keith Watford
Moderator
8027
Keith Watford 2014.04.17 22:43  
angevoyageur:
There is not such problem with this code.Ok it compiles fine without #property strict, not with it. But in all case it doesn't hang up MT4 for me.


I commented out #property strict and yes, seems to be working properly in 625, no hang ups.
Repions
99
Repions 2014.04.28 16:42  

i have problem with B625.. in OnChartEvent()


CHARTEVENT_OBJECT_DRAG not trigered at all..

taro300
71
taro300 2014.05.04 20:03  

Bug was fixed.

It did not hang-up in MT4 build 646.

/
To add comments, please log in or register