MetaTrader 4 Build 574 with Updated MQL4 Language and Market of Applications Released - page 30

 
angevoyageur:
Can you give some details about what you are talking about ? Provide some code to reproduce the problem ?

Thanks for replying angevoyageur.

I have an EA that I've loaded on 582 and it's just sitting there on the chart not opening any trades. No error messages in the Journal or Experts tab (loaded successfully and initialized).

It works fine on 509.

Obviously I don't want to post the 800 lines of code here, but where to start debugging when (the new MT4) isn't providing any error messages.

I tried the provided 'Moving Average' EA, and that opened and closed trades on the Metaquotes server, so we know trades can be opened.


key point though, is "Where is the documentation, e.g., 'extern' replaced by 'input', start replaced by 'ontick'.

 

Perhaps you should reconsider this live launch in business hours when there is no stable beta 4 days before the launch.

We can live 2 more weeks with the current MT4.

 

Why the is it prohibited to make a recursive call to the indicators now (build 582 - strict or no strict mode does not matter)? What is the purpose of that? Wasn't it the responsibility of the coders to make working code?

Here is one simple example that uses the same indicator not once but 3 times (to calculate normal values, to get the number of changed bars of the target time frame when in multi time frame mode and to do multi time frame calculations) that worked perfectly well till this last build which prohibits it to work in multi time frame mode. And that is just one example of such a multi time frame indicator that will not work any more (and there are hundreds of similar ones). This restriction has no cause in any common coding errors. If the code for this indicator was not written properly it simply would not work properly and nobody would use an indicator that is not working. This is a great disappointment and it, if it stays like this, will put us back 10 years in the ways how the things were done then and how the things are done today. Not even metatrader 5 has that restriction

#property indicator_separate_window
#property indicator_buffers    5
#property indicator_color1     clrLimeGreen
#property indicator_color2     clrOrange
#property indicator_color3     clrLimeGreen
#property indicator_color4     clrOrange
#property indicator_color5     clrOrange
#property indicator_style1     STYLE_DOT
#property indicator_style2     STYLE_DOT
#property indicator_width3     2
#property indicator_width4     2
#property indicator_width5     2

//
//
//
//
//

enum prices
{
   pr_close,   // Close
   pr_open,    // Open
   pr_high,    // High
   pr_low,     // Low
   pr_median,  // Median
   pr_typical, // Typical
   pr_weighted // Weighted
};
enum timeFrames
{
   tf_current = 0,     // current time frame
   tf_m1      = 1,     // 1 minute
   tf_m5      = 5,     // 5 minutes
   tf_m15     = 15,    // 15 minutes
   tf_m30     = 30,    // 30 minutes
   tf_h1      = 60,    // 1 hour
   tf_h4      = 240,   // 4 hours
   tf_d1      = 1440,  // daily
   tf_w1      = 10080, // weekly
   tf_mn      = 43200  // monthly
};

extern timeFrames TimeFrame   = tf_current;
extern int        Length      = 32;
extern prices     Price       = pr_typical;
extern double     HighLowStep = 0.5;

//
//
//
//
//

double rsx[];
double rsxDa[];
double rsxDb[];
double slope[];
double max[];
double min[];

//
//
//
//
//

string indicatorFileName;
int    timeFrame;
bool   returnBars;
bool   calculateValue;

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

#define _tfCalc 99
#define _tfRetb 98
int init()
{
   IndicatorBuffers(6);
      SetIndexBuffer(0,max); SetIndexEmptyValue(0,0);
      SetIndexBuffer(1,min);
      SetIndexBuffer(2,rsx);
      SetIndexBuffer(3,rsxDa);
      SetIndexBuffer(4,rsxDb);
      SetIndexBuffer(5,slope);
      
       //
       //
       //
       //
       //
     
        indicatorFileName = WindowExpertName();
        calculateValue    = (TimeFrame==_tfCalc); if (calculateValue) return(0);
        returnBars        = (TimeFrame==_tfRetb); if (returnBars)     return(0);
        timeFrame         = (int)MathMax(TimeFrame,Period()); 
        
      //
      //
      //
      //
      // 
     
   IndicatorShortName(timeFrameToString(timeFrame)+" corridor Rsx ("+(string)Length+")");
return(0);
}

//
//
//
//
//

int deinit() { return(0); }

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

double wrkBuffer[][13];

int start()
{
   int i,r,counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1); 
         if (returnBars) { rsx[0] = limit+1; return(0); }
         
   //
   //
   //
   //
   //
   
   if (calculateValue || timeFrame==Period())
   {
     double Kg = (3.0)/(2.0+Length); 
     double Hg = 1.0-Kg;
     if (slope[limit]==-1) CleanPoint(limit,rsxDa,rsxDb);
     if (ArrayRange(wrkBuffer,0) != Bars) ArrayResize(wrkBuffer,Bars);
     for(i=limit, r=Bars-i-1; i>=0; i--, r++)
     {
        wrkBuffer[r][12] = iMA(NULL,0,1,0,MODE_SMA,(int)Price,i);
        if (i==(Bars-1)) { for (int c=0; c<12; c++) wrkBuffer[r][c] = 0; max[i] = 0; min[i] = 0; continue; }  

        //
        //
        //
        //
        //
      
        double mom = wrkBuffer[r][12]-wrkBuffer[r-1][12];
        double moa = MathAbs(mom);
        for (int k=0; k<3; k++)
        {
           int kk = k*2;
              wrkBuffer[r][kk+0] = Kg*mom                + Hg*wrkBuffer[r-1][kk+0];
              wrkBuffer[r][kk+1] = Kg*wrkBuffer[r][kk+0] + Hg*wrkBuffer[r-1][kk+1]; mom = 1.5*wrkBuffer[r][kk+0] - 0.5 * wrkBuffer[r][kk+1];
              wrkBuffer[r][kk+6] = Kg*moa                + Hg*wrkBuffer[r-1][kk+6];
              wrkBuffer[r][kk+7] = Kg*wrkBuffer[r][kk+6] + Hg*wrkBuffer[r-1][kk+7]; moa = 1.5*wrkBuffer[r][kk+6] - 0.5 * wrkBuffer[r][kk+7];
        }
        if (moa != 0)
             rsx[i] = MathMax(MathMin((mom/moa+1.0)*50.0,100.00),0.00); 
        else rsx[i] = 50;
        max[i] = MathMax(rsx[i],max[i+1]-HighLowStep);
        min[i] = MathMin(rsx[i],min[i+1]+HighLowStep);
      
        //
        //
        //
        //
        //
      
        rsxDa[i] = EMPTY_VALUE;
        rsxDb[i] = EMPTY_VALUE;
        slope[i] = slope[i+1];
            if (rsx[i]>rsx[i+1])  slope[i] = 1;
            if (rsx[i]<rsx[i+1])  slope[i] =-1;
            if (slope[i]==-1) PlotPoint(i,rsxDa,rsxDb,rsx); 
     }      
     return(0);
     }
     
     //
     //
     //
     //
     //
   
     limit = (int)MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,_tfRetb,0,0)*timeFrame/Period()));
     if (slope[limit]==-1) CleanPoint(limit,rsxDa,rsxDb);
     for (i=limit;i>=0; i--)
     {
        int y = iBarShift(NULL,timeFrame,Time[i]);
           min[i]   = iCustom(NULL,timeFrame,indicatorFileName,_tfCalc,Length,Price,HighLowStep,0,y);
           max[i]   = iCustom(NULL,timeFrame,indicatorFileName,_tfCalc,Length,Price,HighLowStep,1,y);
           rsx[i]   = iCustom(NULL,timeFrame,indicatorFileName,_tfCalc,Length,Price,HighLowStep,2,y);
           slope[i] = iCustom(NULL,timeFrame,indicatorFileName,_tfCalc,Length,Price,HighLowStep,5,y);
           rsxDa[i] = EMPTY_VALUE;
           rsxDb[i] = EMPTY_VALUE;
           if (slope[i]==-1) PlotPoint(i,rsxDa,rsxDb,rsx);
     }
     return(0);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

//
//
//
//
//

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (first[i+1] == EMPTY_VALUE)
      {
         if (first[i+2] == EMPTY_VALUE) {
                first[i]   = from[i];
                first[i+1] = from[i+1];
                second[i]  = EMPTY_VALUE;
            }
         else {
                second[i]   =  from[i];
                second[i+1] =  from[i+1];
                first[i]    = EMPTY_VALUE;
            }
      }
   else
      {
         first[i]  = from[i];
         second[i] = EMPTY_VALUE;
      }
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//
//
//
//
//

string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

PS: enum options are still having inverted order when used from the drop down box

 
davidb_012:

Thanks for replying angevoyageur.

I have an EA that I've loaded on 582 and it's just sitting there on the chart not opening any trades. No error messages in the Journal or Experts tab (loaded successfully and initialized).

It works fine on 509.

Obviously I don't want to post the 800 lines of code here, but where to start debugging when (the new MT4) isn't providing any error messages.

I tried the provided 'Moving Average' EA, and that opened and closed trades on the Metaquotes server, so we know trades can be opened.


key point though, is "Where is the documentation, e.g., 'extern' replaced by 'input', start replaced by 'ontick'.


Ah, solved one problem with EA. Trying to open 0.01 lots on Metaquotes server. Doesn't like it. 0.1 and all was fine (without recompiling).

Second point....my offline Renko EA (with ver 852) is working with no mods, but didn't with ver 874. Thanks MQ. Done something to make old EAs work.

 

A script is not a script . . .

I've just written a test script to test capturing screen shots . . . I'm having problems with screen shot being captured under 582 from an EA running in the Strategy Tester, WindowScreenShot() returns true but the file is nowhere to be found . . . anyway, I created this simple script . . .

//+------------------------------------------------------------------+
//|                                         TestWindowScreenShot.mq4 |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  } //int init()


//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }//int deinit()


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
   {
   int SizeX, SizeY;
   string Path, AddDash = "-", Filename;
   datetime Now;
   int GLError;
   
   Now = TimeCurrent();
   
   SizeX = 800;
   SizeY = 600;
   
//   SizeX = ChartGetInteger(0, CHART_WIDTH_IN_PIXELS);
//   SizeY = ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS);
   

   Path = "shots\\";
      
   Filename = ( StringConcatenate( Symbol(), TimeYear(Now), AddDash, TimeMonth(Now), 
      AddDash,  TimeDay(Now) ) );
   
   Print("ChartGrab - Path: ", Path, " Filename: ",Filename, ".gif" );
   
   bool getshot = ( WindowScreenShot( StringConcatenate( Path, Filename, ".gif" ), SizeX, SizeY) );
   if (!getshot)
      {
      GLError = GetLastError();
      Print(StringConcatenate("ChartGrab: ChartGrab failed  . . .", GLError )); 
      }   return(0);
   } //int start()

it works as expected under 509, so I compile it under ME 883 and run it in build 582 . . .

2014.01.30 19:34:49.744 'TestWindowScreenShot' is not script and cannot be executed

. . . oh yes it is ! !

 
RaptorUK:

A script is not a script . . .

I've just written a test script to test capturing screen shots . . . I'm having problems with screen shot being captured under 582 from an EA running in the Strategy Tester, WindowScreenShot() returns true but the file is nowhere to be found . . . anyway, I created this simple script . . .

it works as expected under 509, so I compile it under ME 883 and run it in build 582 . . .

. . . oh yes it is ! !

So I made this into an EA . . . added a GlobalVariableGet() so it doesn't grab a chart for each tick and ran it n the Strategy Tester . . .

2014.01.30 19:51:34.467 2013.12.02 00:04 TestWindowScreenShot EURUSD,H1: ChartGrab - Path: shots\ Filename: EURUSD2013-12-2.gif

2014.01.30 19:51:33.965 2013.12.02 00:04 TestWindowScreenShot EURUSD,H1: ChartGrab - Path: shots\ Filename: EURUSD2013-12-2.gif

2014.01.30 19:51:33.474 2013.12.02 00:04 TestWindowScreenShot EURUSD,H1: ChartGrab - Path: shots\ Filename: EURUSD2013-12-2.gif

2014.01.30 19:51:32.979 2013.12.02 00:04 TestWindowScreenShot EURUSD,H1: ChartGrab - Path: shots\ Filename: EURUSD2013-12-2.gif

2014.01.30 19:51:32.488 2013.12.02 00:04 TestWindowScreenShot EURUSD,H1: ChartGrab - Path: shots\ Filename: EURUSD2013-12-2.gif

. . . and then on a live chart . . .

2014.01.30 19:53:13.963 TestWindowScreenShot EURUSD,M1: ChartGrab - Path: shots\ Filename: EURUSD2014-1-30.gif

2014.01.30 19:53:06.287 TestWindowScreenShot EURUSD,M1: ChartGrab - Path: shots\ Filename: EURUSD2014-1-30.gif

I can't find these files on my hard drive . . .

 
The question is . . . what other mql4 functions don't work ?
 
I also tried the "new" ChartScreenShot() and this didn't work either . . . unless I created the subdirectory that was specified in the path, then it worked.
 

I'm just now running into this difference in behavior: I have indies that create a lot of objects, so one easy way to ensure each has a unique name-per-bar is to include the object OBJ_TIME1 in the object name.

509 and 509 ex4 behavior: string objName = StringConcatenate("_P4L_",Time[0]); // objName = "_P4L_1391115600"


582 behavior:

string objName = StringConcatenate("_P4L_",Time[0]); // objName = "_P4L_2014.01.30 21:00:00"

string objName = StringConcatenate("_P4L_",IntegerToString(Time[0])); // objName = "_P4L_1391115600"

I might not care most times because for short names, either one works. But I have other examples that use TIME1 and TIME2 and even also TIME3, so the extra characters are killing me. It exceeds the max ObjectName length and breaks my code.

Anyone see any problem using my workaround, "IntegerToString(Time[0])" ?

P.s. Filed a service ticket.

 
davidb_012:

Thanks for replying angevoyageur.

I have an EA that I've loaded on 582 and it's just sitting there on the chart not opening any trades. No error messages in the Journal or Experts tab (loaded successfully and initialized).

It works fine on 509.

Obviously I don't want to post the 800 lines of code here, but where to start debugging when (the new MT4) isn't providing any error messages.

I tried the provided 'Moving Average' EA, and that opened and closed trades on the Metaquotes server, so we know trades can be opened.


key point though, is "Where is the documentation, e.g., 'extern' replaced by 'input', start replaced by 'ontick'.

There is no online documentation for mql4 yet. You can either use the Help file from metaeditor (F1) or check the mql5 documentation.

About your issue, is your EA working with 509 on Metaquotes server too ? Maybe it can comes from different trading parameters ?

Reason: